8 - data types, What’s in this chapter, Argument stack – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 101: Control stack, Data types

Advertising
background image

8

Chapter

8 -1

Data Types

This chapter describes:

On page:

argument stack

8 -1

control stack

8 -1

string data types

8 -2

numeric data types

8 -3

backplane conversion data types

8 -4

what’s next?

8 -9

The argument stack (A-stack) stores all constants that the BASIC module
is currently using. Operations (see Chapter 9) such as add, subtract,
multiply, and divide always operate on the first two numbers of the
argument stack and return the result to the stack. The argument stack is
203 bytes long. The BASIC module stores all constants and variables as
floating point. Each floating point number placed in the stack requires 6
bytes of storage. The argument stack can hold up to 33 floating point
numbers before overflowing.

In addition, the PUSH command (page 11 -30) saves data to the argument
stack and the POP (page 11 -28) command restores data from the stack.
PUSHes and POPs are typically associated with call routines. Pushes and
Pops are mechanisms you use to transfer information to and from call
routines. PUSH makes a copy of the variable you PUSHed, then puts that
copy on the top of the argument stack. POP takes the value on the top of
the argument stack and copies it to the variable you POPped.

The control stack (C-stack) stores all information associated with loop
control (ex. DO-WHILE, DO-UNTIL, FOR-NEXT, etc.) The control
stack is 157 bytes long. DO-WHILE and DO-UNTIL loops use 3 bytes of
the control stack. FOR-NEXT loops use 17 bytes of the the control stack.
Calculate the number of operations you are using times the number of
bytes each operation uses to determine how many levels you can nest.

For example, if you have no GOSUBs to return from, no DO-UNTIL or
FOR-NEXT loops running you can nest DO-WHILE loops 52 levels
(157/3). Or if you have no GOSUBs to return from, no DO-UNTIL or
DO-WHILE loops running you can nest FOR-NEXT loops 9 levels
(157/17). Typically your program uses several different combinations of
statements that use the C-stack memory.

What’s in This Chapter?

Argument Stack

Control Stack

Advertising