'{$STAMP BS2} '{$PBASIC 2.5} ' Author: Jeffrey Sung ' Last Update: January 16, 2004 ' Subject: Programming Microcontrollers/Robotics ' Version: 1.41 ' Description: An array implementation of a stack stackData VAR Word myCount VAR Word myCount=0 MINIMUM CON 0 'Minimum array index MAXIMUM CON 1000 '(The absolute maximum is 2047, but EEPROM is also used for program storage) main: LOWER con 0 HIGHER con 10 x VAR Word DEBUG "Begin",CR FOR x=LOWER TO HIGHER DEBUG "x=",DEC x," " stackData=x+15 DEBUG "stackData=",DEC stackData,cr GOSUB push next label: GOSUB isEmpty IF stackData=1 THEN outsideTheLabel GOSUB pop DEBUG "Popped ",DEC stackData,CR GOTO label outsideTheLabel: DEBUG "Done",CR END peekTop: READ myCount,stackData RETURN pop: IF myCount