lecNew-21-Procedure

lecNew-21-Procedure - WPI ECE2801 Foundations of Embedded...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
WPI ECE2801 Foundations of Embedded Computer Systems Lecture 21: Procedures
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE2801: Foundations of Embedded Systems Lecture 21 CPU Registers R1: SP (Stack Pointer) Stack – an area of memory reserved for data and address storage LIFO stack (Last In First Out) push (data), call (address) pop (data), ret (address) Change of sequential execution : jump, call, interrupt grows downward must match pushes and pops, calls and returns! (overflow, underflow issues)
Background image of page 2
EE2801: Foundations of Embedded Systems Lecture 21 Stack Operation Note : SP points to the last USED location (filled!) SP is always decremented/incremented by two, independent of the byte suffix. Example: PUSH SR ; save Status Register POP.B 0(R7) ; the low byte of the stack is moved to the byte ; which is pointed to by R7. PUSH #FOO ; memory location 0x210 is labeled FOO, push 0x0210 POP R7 PUSH src *POP dst Operation: PUSH: SP-2 →SP, src → @SP *POP: @SP → dst, SP+2 → SP (MOV @SP+, dst or MOV.B @SP+, dst) Status Bit affected: None
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EE2801: Foundations of Embedded Systems Lecture 21 Procedures Procedure, Subroutine, Module: a sequence of computer instructions for performing a specified task that can be used repeatedly; it has one entry point, has one exit point, and has no jumps outside of itself Like functions in C Intended to perform specific, small function Meant to be reused myProc ; beginning of procedure should have label ; code goes here RET ; procedure MUST have a return statement
Background image of page 4
EE2801: Foundations of Embedded Systems Lecture 21 Calling a Procedure Note: Procedure CALLs and RETs automatically affect Stack and PC.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/12/2009 for the course ECE 2801 taught by Professor Jarvis during the Spring '08 term at WPI.

Page1 / 18

lecNew-21-Procedure - WPI ECE2801 Foundations of Embedded...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online