beautypg.com

Stack-effect comments, Multi-byte values, Pointer values – Echelon Neuron User Manual

Page 51: Conditional values

background image

Stack-Effect Comments

In general, the data stack is documented as a set of ordered values from left to

right, with TOS in the first (left-most) position. For example, if the values 1 and

2 were on the data stack, with 1 in TOS and 2 in NEXT, and the current

instruction is a PUSHS instruction to push the value 0 onto the stack, the stack-

effect comment would be (0,1,2), as shown below:

pushs #0 ; (0, 1, 2)

The comment follows the instruction, so that the stack-effect comment shows the

stack layout after the instruction has been executed. In this case, the comment

shows that 0 has been pushed onto the stack, and the previous values 1 and 2

have been moved to the right (down the stack).
Note that this stack-effect comment does not show the entire stack, that is, the

data stack contains more than the three values 0, 1, and 2. Instead, the comment

shows only enough stack elements to clarify how the stack is changed by the

current instruction or function call. You could add an ellipsis (...) or a double

hyphen (--) to the right of the changed values to remind you that there is more

data on the stack (for example, (0,1,2,…)). However, the ellipsis or double

dash is not necessary.
In general, you do not know the actual data values on the stack, but instead you

are pushing and popping variables. Add the variable name (or a portion of it) to

the stack comment, for example:

push interface_type ; (type)

Stack values are unsigned one-byte scalars unless stated otherwise.

Multi-Byte Values

For multi-byte values, add the element’s size, in bytes, to the value in the

comment. Enclose the size in parentheses following the value itself. For

example, for a 16-bit value named address, the comment would read as

address(2). Therefore, the following two stack-effect comments are equivalent:

; (address(2), …)

; (addresslo, addresshi, …)

Pointer Values

For pointer values, use square brackets ([ ]) to indicate that the value is fetched

from an address. For example, the following stack-effect comment describes one

byte from the location address(2):

; ([address(2)])

Conditional Values

Occasionally, stack elements are conditional. For example, the BRNEQ

instruction drops TOS if the comparison (which is part of the BRNEQ operation)

results in equality, but leaves TOS intact otherwise. Use braces ({ }) to indicate

conditional stack elements. For example, the following comment indicates that

Neuron Assembly Language Reference

41