loop


Loop (Loop)

[Syntax]

-

loop reg1, disp16

 

The following can be specified as disp16:

-

Absolute expression having a value of up to 16 bits

-

Relative expression having a PC offset reference of label

-

label (PC offset)

[Function]

Updates the general-purpose register reg1 by adding -1 from its contents. If the contents after this update are not 0, the following processing is performed. If the contents are 0, the system continues to the next instruction.

-

The result of logically shifting the 15-bit immediate data 1 bit to the left and zero-extending it to word length is subtracted from the current PC value, and then the control is transferred.

-

-1 (0xFFFFFFFF) is added to general-purpose register reg1. The carry flag is updated in the same way as when the add instruction, not the sub instruction, is executed.

Remark

"0" is implicitly used for bit 0 of the 16-bit displacement. Note that, because the current PC value used for calculation is the address of the first byte of this instruction, if the displacement value is 0, the branch destination is this instruction.

[Description]

-

If any of the following is specified for disp16, the assembler generates one loop machine instruction.

(a)

Absolute expression having a value in the range of 0 to 65535

(b)

Relative expression that has a PC offset reference of a label

[Flag]

CY

"1" if a carry occurs from MSB in the reg1 operation; otherwise, "0"

OV

"1" if an overflow occurs in the reg1 operation; otherwise, "0"

S

"1" if reg1 is negative; otherwise, "0"

Z

"1" if reg1 is 0; otherwise, "0"

SAT

---

[Caution]

-

If an absolute expression having a value exceeding the range of 0 to 65535 is specified as disp16, the assembler outputs the following message and stops assembling.

E0550230 : Illegal operand (range error in displacement).

-

If an absolute expression having an odd-numbered value is specified as disp16, the assembler outputs the following message and stops assembling.

E0550226 : Illegal operand (must be even displacement).

 

-

If r0 is specified as reg1 in the loop instruction, the assembler outputs the following message and stops assembling.

E0550239 : Illegal operand (cannot use r0 as source in RH850 mode).