Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 3 - Branching & Subroutines

Similar presentations


Presentation on theme: "Lab 3 - Branching & Subroutines"— Presentation transcript:

1 Lab 3 - Branching & Subroutines
MPC8360 Micro Controllers Lab 3 - Branching & Subroutines Fall , 2010

2 LIFO = Last In First Out Stack Data Structure Pop Push Data 4
Stack Pointer Data 3 Stack Pointer Data 2 Stack Pointer Data 1 Stack Pointer Stack Pointer Stack

3 Pseudo code Basic Subroutine Call Warning For R3 =1 to 100 Push R3
Push Parameter bl Sub1 Pop Result Pop R3 Sub1: Pop Parameter …. Push Result bclr Warning Pseudo code Param Result R3 LR Stack

4 Main Program Structure
….. Push used registers Push Push subroutine parameters Push Call subroutine bl Sub1 Pop return parameters Pop Pop used registers Pop

5 Subroutine Structure Label Sub1: Pop parameters Pop
Subroutine code ….. Push return parameters Push Return bclr

6 Subroutine Calling a Subroutine
Push LR Push Registers Push Parameter bl Sub2 Pop Result Pop Registers Pop LR bclr Sub2: Pop Parameter …. Push Result bclr Param Result Regs LR OLD Data LR Stack

7 Stack implementation The Stack will be implemented in the memory.
Each student will decide the address of his stack (somewhere in 0x0001_ x0100_0000) Use R31 as the Stack Pointer (SP) Push & Pop should not be implemented as subroutines No need to check for Overflow / Underflow Do not use Step-Over when debugging

8 General Notes Make sure to bring the codes you have written in previous labs. Please READ the exercise before you start working on it !! Please assign final reports in *.doc (office 2003) format only

9 Quick Overview


Download ppt "Lab 3 - Branching & Subroutines"

Similar presentations


Ads by Google