{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lecture22 - CTermSpring2010...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Foundations of Embedded Systems C Term Spring 2010 Lecture #22:  Functions, the Stack & the HW Multiplier Reading for Today: User's Guide Ch 7 Reading for Next Class: MSP430 User's Guide Ch 2 HW#6 (on web) Due Next Thursday in class Lab #4 (on web): Report due Friday 3/5/2010 by 12 pm EXAM #3 – Friday 3/5/2010 Last Class:   More on conditional jumps >> Implementing procedures in assembly language and their effects on the stack Function CALLs and RET auto-magically affect Stack and PC CALL   dest    ; PUSH PC onto stack then sets PC =  dest   ; At the end of function, RET pops the PC from the top of    ; the stack. Execution resumes with next instruction MOV  R4, R6   What exactly is the Stack and how does it work? >> The Stack is temporary storage used in the course of program execution  Specifically during calls to Functions and Interrupts  >> The Stack is a Last In First Out (LIFO) data structure >> R1 = Stack Pointer (SP) holds the address of current Top of the Stack >> Words (16-bit words only) are placed on the stack using PUSH   src >> Words are recalled from the stack using POP   dest main MOV #0A00h, SP MOV #1234h, R7 PUSH R7 ; Memory location 0x210 is labeled FOO PUSH #FOO ... POP R10 ... POP R7
Image of page 1

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

View Full Document Right Arrow Icon
Function Etiquette: >> One point of entry, one exit (RET statement!) --> DO NOT jump out of functions!
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern