10_EEL4742-Notes#10 - EEL 4742 Embedded Systems Note#10...

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

EEL 4742- Embedded Systems Note#10 Stack is a data structure such that last in is the first out (similar to a plate of the dishes) The stack pointer register (SP) is used to keep track of where in memory the last item on the stack is located. Every time an item is placed on the stack, it is decremented by 1 word (2 bytes). push.w SRC SP SP-2 push.b SRC mem[SP] SRC pop.w dest dest mem[SP] pop.b dest SP SP+2 The SP is always decremented by 2 even if a byte is placed on the stack. This way the data put of the stack is always in word format (2 bytes). ______________________________________________________________________________ Subroutines- provides a means of writing structured programs, they are similar to functions in C. Call address ret. address ________ ________ ________ ________ ret. Ret PC mem[SP] SP SP+2 call #label go to address label call Label go to address mem[label] call Rs go to address of the value stored in Rs , mem[Rs] call o(Rs) go to address of mem[o+Rs] ______________________________________________________________________________ Since call/ subroutine use the stack (SP), the stack pointer must be initialized in the beginning of the program. Every time something is put on the stack, the SP is decremented.
Image of page 1

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

Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '11
  • Weeks
  • Subroutine, Return statement, Control flow, stack pointer

{[ 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