Chapter 08 - Stacks

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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight 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
Background image of page 2
BYU CS/ECEn 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
BYU CS/ECEn Chapter 8 - Stacks 4 Levels of Transformation Problems Algorithms Language (Program) Machine (ISA) Architecture Microarchitecture Circuits Devices Programmable Computer Specific Manufacturer Specific
Background image of page 4
BYU CS/ECEn 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
BYU CS/ECEn 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
Background image of page 6
BYU CS/ECEn 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
BYU CS/ECEn Chapter 8 - Stacks 8 Computer Memory – Up or Down? x0000 xFFFF Up Down xFFFF x0000 Down Up The Stack 1996 1998 1982 1995
Background image of page 8
BYU CS/ECEn 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
Background image of page 9

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

View Full DocumentRight Arrow Icon
BYU CS/ECEn Chapter 8 - Stacks 10 Subroutines n A subroutine is a program fragment
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 31

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

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

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