beautypg.com

Dec (decrement) – Echelon Neuron User Manual

Page 94

background image

DEC (Decrement)

The DEC instruction decrements the TOS value. The DEC instruction uses the

implicit addressing mode. If the TOS value is zero prior to the decrement, this

instruction sets the Carry flag.
The DEC instruction applies to both Series 3100, 5000, and 6000 devices.

Syntax:
The DEC instruction requires no operands:

DEC

Table 28 describes the attributes of the DEC instruction.

Table 28. DEC Instruction

Instruction

Hexadecimal

Opcode

Instruction

Size (Bytes)

CPU Cycles

Required

Affect on

Carry Flag

DEC

3F

1

2

Modified


Example:
The following example calls assumes that TOS contains a loop-control variable.

The DEC instruction decrements TOS. When TOS becomes zero, the BRZ

instruction branches to the Done label. As long as TOS is not zero, the BR

instruction branches to the Loop label. Thus, this example implements a for

loop construct.

Loop ... ; loop body

dec ; ( n )

brz Done

br Loop

Done ...

ret ; return to caller

84

Neuron Assembly Language Instruction Statements