beautypg.com

Drop_r (drop from stack and return) – Echelon Neuron User Manual

Page 97

background image

DROP_R (Drop from Stack and Return)

The DROP_R instructions drop a value from the data stack and perform a

return from call operation:

The DROP_R TOS instruction drops TOS and performs a return from

call

The DROP_R NEXT instruction drops NEXT and performs a return

from call

The DROP_R instruction uses the direct addressing mode.
Note that the DROP_R TOS instruction is equivalent to the DEALLOC #1

instruction.
The DROP_R instruction applies to Series 3100, 5000, and 6000 devices.

Syntax:
The DROP instruction requires a single operand to specify which stack element

to drop:

DROP_R TOS

DROP_R NEXT

Table 31 describes the attributes of the DROP_R instruction.

Table 31. DROP_R Instruction

Instruction

Hexadecimal

Opcode

Instruction

Size (Bytes)

CPU Cycles

Required

Affect on

Carry Flag

DROP_R TOS

7F

1

6

None

DROP_R NEXT F5

1

5

None


Example:
The following example implements a function named set_mode, which uses

conditional compilation to perform different tasks for different modes. If the

mode MODE1 is defined, the function consumes the TOS value by using the POP

instruction. If the mode MODE1 is not defined, the function uses the DROP_R

TOS instruction to drop the mode argument from the data stack and return to

the function’s caller.

set_mode ; (mode)

IFDEF MODE1

; Limit to 0 or 1

and #h'1

pop _mode ; ()

ret ; return to caller

ELSE

drop_r tos ; ()

ENDIF

Neuron Assembly Language Reference

87