Statement: push[expr – Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 75

Advertising
background image

Operating Functions

Chapter 5

5–38

Mode: COMMAND AND/OR RUN
Type: ASSIGNMENT

The arithmetic expression, or expressions, following the PUSH statement
are evaluated and then placed in sequence on the BASIC Module’s
ARGUMENT STACK. This statement, in conjunction with the POP
statement, provides a simple means of passing parameters to assembly
language routines. In addition, the PUSH and POP statements are used to
pass parameters to BASIC subroutines and to “SWAP” variables. The last
value PUSHed onto the ARGUMENT STACK is the first value POPed off
the ARGUMENT STACK.

Variations: You can push more than one expression onto the ARGUMENT
stack with a single PUSH statement. The expressions are followed by a
comma: PUSH[expr],[expr],......... [expr]. The last value PUSHed onto the
ARGUMENT STACK is the last expression [expr] encountered in the
PUSH STATEMENT.

Examples:

SWAPPING

CALL

VARIABLES

ROUTINE

u10 A=10

u10 PUSH 3

u20 B=20

u20 CALL 10

u30 PRINT A,B u30 POP W

u40 PUSH A,B u40 REM PUSH VALUE ON STACK, CALL

u50 POP A,B

u50 REM CONVERSION, POP RESULT IN W

u60 PRINT A,B u60 END

u70 END

uRUN

10

20

20

10

READY
u

5.4.25
Statement: PUSH[expr]

Advertising