home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / 3x400 / includes.lzh / PUSHPOP.RPG < prev    next >
Text File  |  1988-08-19  |  1KB  |  27 lines

  1.      CSR         PUSH      BEGSR
  2.      C           SI        IFGE TOS                        TOP OF STACK?
  3.       *   If the Stack Pointer is equal to the Stack Limit (top of Stack)
  4.       *   then send the message "** TOS **" back to the caller.
  5.      C                     MOVE TOP       STACK
  6.      C                     ELSE
  7.       *   Increment the Stack Pointer by a factor of 1.
  8.      C                     ADD  1         SI               INCREMENT SI
  9.       *   Put the stack-variable onto the stack.
  10.      C                     MOVE STACK     S,SI
  11.      C                     END
  12.      CSR                   ENDSR
  13.       /SPACE
  14.      CSR         POP       BEGSR
  15.      C           SI        IFLE 0                          TOP OF STACK?
  16.       *   If the Stack Pointer is equal to 0, then
  17.       *   send the bottom of stack message "** TOS **"
  18.       *   back to the caller.
  19.      C                     MOVE TOP       STACK
  20.      C                     ELSE
  21.       *   Put the stack element into the stack-variable.
  22.      C                     MOVE S,SI      STACK
  23.       *   Decrement the Stack Pointer by a factor of 1.
  24.      C                     SUB  1         SI               INCREMENT SI
  25.      C                     END
  26.      CSR                   ENDSR
  27.