beautypg.com

Add_r (add and return) – Echelon Neuron User Manual

Page 76

background image

ADD_R (Add and Return)

The ADD_R instruction adds two numbers and performs a return-from-call

operation. The ADD_R instruction uses the implicit addressing mode. The

ADD_R instruction retrieves both TOS and NEXT from the data stack and adds

them together. TOS and NEXT are consumed, and the result is placed in TOS.

The operation modifies the Carry flag as result of the unsigned addition. The

return-from-call operation loads the instruction pointer (IP) with the return

address from the return stack.
The ADD_R instruction applies to Series 3100, 5000, and 6000 devices.

Syntax:
The ADD_R instruction requires no operands:

ADD_R

Table 12 describes the attributes of the ADD_R instruction.

Table 12. ADD_R Instruction

Instruction

Hexadecimal

Opcode

Instruction

Size (Bytes)

CPU Cycles

Required

Affect on

Carry Flag

ADD_R

5C

1

7

Modified


Example:
The following example performs the operation 2+3 and performs the return-from-

call operation. The example assumes that the return stack contains the address

of the caller to which the ADD_R instruction returns.

pushs #2 ; (2, -, -)

pushs #3 ; (3, 2, -)

add_r ; (5, -, -)

The value of TOS after this code executes is 5 because 2+3 = 5. The value of the

Carry flag is modified (cleared) because the unsigned addition did not require an

extra carry bit. After completing the addition, the ADD_R instruction performs

the return-from-call operation.

66

Neuron Assembly Language Instruction Statements