satsub


Subtracts saturated.

[Syntax]

-

satsub reg1, reg2

-

satsub imm, reg2

-

satsub reg1, reg2, reg3

 

The following can be specified for imm:

-

Absolute expression having a value of up to 32 bits

-

Relative expression

[Function]

-

Syntax "satsub reg1, reg2"

Subtracts the value of the register specified by the first operand from the value of the register specified by the second operand, and stores the result in the register specified by the third operand. If the result exceeds the maximum positive value of 0x7FFFFFFF, however, 0x7FFFFFFF is stored in the register specified by the second operand. Likewise, if the result exceeds the maximum negative value of 0x80000000, 0x80000000 is stored in the register specified by the second operand. In both cases, the SAT flag is set to 1

-

Syntax "satsub imm, reg2"

Subtracts the value of the absolute expression or relative expression specified by the first operand from the value of the register specified by the second operand, and stores the result in the register specified by the second operand. If the result exceeds the maximum positive value of 0x7FFFFFFF, however, 0x7FFFFFFF is stored in the register specified by the second operand. Likewise, if the result exceeds the maximum negative value of 0x80000000, 0x80000000 is stored in the register specified by the second operand. In both cases, the SAT flag is set to 1.

-

Syntax "satsub reg1, reg2, reg3"

Subtracts the value of the register specified by the first operand from the value of the register specified by the second operand, and stores the result in the register specified by the second operand. If the result exceeds the maximum positive value of 0x7FFFFFFF, however, 0x7FFFFFFF is stored in the register specified by the second operand. Likewise, if the result exceeds the maximum negative value of 0x80000000, 0x80000000 is stored in the register specified by the third operand. In both cases, the SAT flag is set to 1.

[Description]

-

If the instruction is executed in syntax "satsub reg1, reg2" or "satsub reg1, reg2, reg3", the assembler generates one satsub machine instruction.

-

If the instruction is executed in syntax "satsub imm, reg2", the assembler executes instruction expansion to generate one or more machine instructionsNote.

(a)

0

satsub  0, reg
satsub  r0, reg

(b)

Absolute expression having a value in the range of -32,768 to +32,767

satsub  imm16, reg
satsubi imm16, reg, reg

(c)

Absolute expression having a value exceeding the range of -32,768 to +32,767

If all the lower 16 bits of the value of imm are 0

satsub  imm, reg
movhi   HIGHW(imm), r0, r1
satsub  r1, reg

Else

satsub  imm, reg
mov     imm, r1
satsub  r1, reg

(d)

Relative expression having !label or %label, or that having $label for a label having a definition in the sdata/sbss-attribute section

satsub  !label, reg
satsubi !label, reg, reg
satsub  %label, reg
satsubi %label, reg, reg
satsub  $label, reg
satsubi $label, reg, reg

(e)

Relative expression having #label or label, or that having $label for a label having no definition in the sdata/sbss-attribute section

satsub  #label, reg
mov     #label, r1
satsub  r1, reg
satsub  label, reg
mov     label, r1
satsub  r1, reg
satsub  $label, reg
mov     $label, r1
satsub  r1, reg

Note

The satsub machine instruction does not take an immediate value as an operand.

[Flag]

CY

1 if a borrow occurs from MSB (Most Significant Bit), 0 if not

OV

1 if Integer-Overflow occurs, 0 if not

S

1 if the result is negative, 0 if not

Z

1 if the result is 0, 0 if not

SAT

1 if OV = 1, - if not

[Caution]

-

If the instruction is executed in syntax "satsub reg1, reg2" or "satsub imm, reg2", if r0 is specified as the second operand, the assembler outputs the following message and stops assembling.

E0550240 : Illegal operand (cannot use r0 as destination in RH850 mode).