int e l 4.26 DESCRIPTION OF STATEMENTS STATEMENT: POP[var] MODE: COMMAND AND / OR RUN TYPE: ASSIGNMENT The top of the ARGUMENT STACK is assigned to the variable following the POP statement and the ARGUMENT STACK is "-POPPED" (i.e. incremented by 6). Values can be placed on the stack by either the PUSH statement or by assembly language CALLS. NOTE -- If a POP statement is executed and no number is on the ARGUMENT STACK, an A-STACK ERROR will occur. VARIATIONS: More than one variable can be popped off the ARGUMENT stack with a single POP statement. The variables are simply followed by a comma (i.e. POP [var],[var], ..[var]). EXAMPLES: See PUSH statement. COMMENT:
The PUSH and POP statements are unique to MCS BASIC-52. These powerful statements can be used to "get around" the GLOBAL variable problems so often encountered in BASIC PROGRAMS. This problem arises because in BASIC the "main" program and all subroutines used by the main program are required to use the same variable names (i.e. GLOBAL VARIABLES). It is not always convenient to use the same variables in a subroutine as in the main program and you often see programs re-assign a number of variables (i.e. A=Q) before a GOSUB STATEMENT is executed. If the user reserves some variable names JUST for subroutines (i.e.
S1, S2) and passes variables on the stack as shown in the previous example, you will avoid any GLOBAL variable problems in MCS BASIC-52. - 61 -