Back Next

Stack
  Effective address involves a specifically reserved block of memory used 
    as a scratch area accessed in a first in, last out format.

  In some implementation, may be viewed as a form of implied.
    6502: PHA - push accumulator contents onto stack.  1 byte. 
    Both the accumulator and the stack pointer are implied by instruction.

  Others support several compound addressing modes.
    8086: POP {work register or memory or segment register (except CS)}
    Uses Stack segment:stack pointer as a 2nd implied address target.
 
  Some instructions directly target stack
    Push, Pop

  Others manipulate stack as part of a larger task.

    Calls and returns.
      6502: JSR $2000 - set program counter to 2000 after storing current 
        2 byte contents of program counter on stack.

      6502: RTS - pops the top 2 bytes off of stack and puts them into the
        program counter.

    Interrupts/Return calls may push several or pop several bytes from stack.
      such as program counter and status register.


Some systems are stack based (HP calculators) and have a number of stack type instructions which override basic FIFO design. Push, Pop, Swap (switch 2 elements on stack), DUP (duplicate top element), Drop (discard an element). Some of these take arguments to target elements of the stack other than those at the top. Some systems do not support stack commands at all or at user level. IBM 360 standard linkage substitutes stack commands with a user implemented routine.