Chapter 08 - Stacks

Chapter 08 - Stacks - Chapter 8 Stacks 1996 1998 1982 1995...

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

View Full Document Right Arrow Icon
Chapter 8 – Stacks 1996 1998 1982 1995
Image of page 1

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

View Full Document Right Arrow Icon
CS/ECEn 124 Discussion #09 – Exam I Review 2 Exam I n Thursday through Tuesday in Testing Center n Automatic 50% penalty if you miss exam n 54 questions n 8 questions Chapter 1 – Abstraction n 12 questions Chapter 2 – Data Types n 20 questions Chapter 3 – Digital Logic n 7 questions Chapter 4 – The Von Neumann Model n 4 questions Chapter 5 – MSP430 ISA n 5 questions Chapter 6 – MSP430 Microarchitecture n Good idea to have scratch paper on hand n 1 page, handwritten notes n Take the pre-test exam!! n Study slides, homework, and book
Image of page 2
BYU CS/ECEn 124 Chapter 8 - Stacks 3 Topics to Cover… n The Stack n Subroutines n Subroutine Linkage n Saving Registers n Stack Operations n Recursive Subroutines n Activation Records n Example 1: Activation Records
Image of page 3

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

View Full Document Right Arrow Icon
BYU CS/ECEn 124 Chapter 8 - Stacks 4 Levels of Transformation Problems Algorithms Language (Program) Machine (ISA) Architecture Microarchitecture Circuits Devices Programmable Computer Specific Manufacturer Specific
Image of page 4
BYU CS/ECEn 124 Chapter 8 - Stacks 5 Stacks n Stacks are the fundamental data structure of computers today n A stack is a last in, first out (LIFO) abstract data structure. n A true stack is a restricted data structure with two fundamental operations, namely push and pop . n Elements are removed from a stack in the reverse order of their addition. n Memory stacks may be used for random access. The Stack
Image of page 5

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

View Full Document Right Arrow Icon
BYU CS/ECEn 124 Chapter 8 - Stacks 6 MSP430 Stack n Hardware support for stack n Register R1 – Stack Pointer (SP) n Initialized to highest address of available RAM n MSP430F2013  0x0280 (128 bytes) n MSP430F2274  0x0600 (1k bytes) n Stack grows down towards lower memory addresses n Initialize stack at beginning of program STACK .equ 0x0600 ; top of stack reset: mov.w #STACK,SP ; initialize stack pointer The Stack
Image of page 6
BYU CS/ECEn 124 Chapter 8 - Stacks 7 MSP430 Stack n The stack is a word structure n Elements of the stack are 16-bit words. n The LSB of the Stack Pointer is always 0. n The Stack Pointer (SP) points to the last word added to the stack (TOS). n The stack pointer is used by n PUSH – put a value on the stack n POP – retrieve a value off the stack n CALL – put a return address on the stack n RET – retrieve a return address off the stack n RETI – retrieve a return address and status register off the stack n Interrupts – put a return address and status register on the stack The Stack
Image of page 7

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

View Full Document Right Arrow Icon
BYU CS/ECEn 124 Chapter 8 - Stacks 8 Computer Memory – Up or Down? x0000 xFFFF Up Down xFFFF x0000 Down Up The Stack 1996 1998 1982 1995
Image of page 8
BYU CS/ECEn 124 Chapter 8 - Stacks 9 Implementing Stacks in Memory n Unlike a coin stack, in a memory stack, the data does not move in memory, just the pointer to the top of stack. / / / / / / / / / / / / / / / / / / / / TOP Current SP x0280 R1 x0282 x0280 x027E x027C x027A / / / / / / / / #18 / / / / / / / / TOP x0282 x0280 x027E x027C x027A Current SP x027E R1 Push #0x0018 / / / / / / / / #18 #25 #58 TOP x0282 x0280 x027E x027C x027A Current SP x027C R1 Pop R15 #58 -> R15 / / / / / / / / #18 #25 #58 TOP x0282 x0280 x027E x027C x027A Current SP x027A R1 Push #0x0025 Push #0x0058 / / / / / / / / #18 #25 #36 TOP x0282 x0280 x027E x027C x027A Current SP x027A R1 Push #0036 The Stack
Image of page 9

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

View Full Document Right Arrow Icon
BYU CS/ECEn 124 Chapter 8 - Stacks 10 Subroutines n A subroutine is a program
Image of page 10
Image of page 11
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