7-subroutines - Stack temporary storage facility in memory...

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

View Full Document Right Arrow Icon
Stack temporary storage facility in memory Advantage: processor automatically allocates/de-allocates space in memory; uses stack pointer (SP) LIFO (last in ; first out) Stack-related instructions: LDS, STS: load, store SP (LDS used to initialize the stack) INS, DES: increment/decrement SP PSHA, PSHB: push A/B onto stack PSHX, PSHY: push X/Y onto stack PULA, PULB: pull A/B off the stack PULX, PULY: pull X/Y off the stack TSX, TSY: (SP) + 1 X/Y (SP not changed) TXS, TYS: (X/Y) - 1 SP (X/Y not changed)
Background image of page 1

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

View Full DocumentRight Arrow Icon
Definitions Stack pointer: points to next available stack location Stack grows in memory with decreasing addresses SP $A000 Stack after PSHA SP $A000 Stack after PSHX !! X/Y always stored in Big Endian !! PSHA: PULA : PSHX: PULX:
Background image of page 2
Subroutines Reusable program module Main program can call a subroutine from any location After execution of subroutine, main program will continue Subroutine instructions: JSR (jump to subroutine; extended addressing mode)
Background image of page 3

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

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

Page1 / 15

7-subroutines - Stack temporary storage facility in memory...

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

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