MicroBlaze Processor Reference Guide www.xilinx.com 127
UG081 (v6.0) June 1, 2006 1-800-255-7778
Instructions
R
rsub
Arithmetic Reverse Subtract
Description
The contents of register rA is subtracted from the contents of register rB and the result is
placed intoregister rD. Bit 3of the instruction (labeled as K inthe figure) is set to a onefor
the mnemonic rsubk. Bit 4 of the instruction (labeled as C in the figure) is set to a one for
the mnemonic rsubc. Both bits are set to a one for the mnemonic rsubkc.
When an rsub instruction hasbit 3set (rsubk,rsubkc), the carry flag will Keepits previous
value regardlessof the outcome ofthe execution of theinstruction. If bit 3 iscleared (rsub,
rsubc), then the carry flag will be affected by the execution of the instruction.
When bit 4 of the instruction is set to a one (rsubc, rsubkc), the content of the carry flag
(MSR[C]) affects the execution of the instruction. When bit 4 is cleared (rsub, rsubk), the
contentofthecarryflag doesnotaffecttheexecution oftheinstruction(providinganormal
subtraction).
Pseudocode
if C = 0 then
(rD) (rB) + (rA) + 1
else
(rD) (rB) + (rA) + MSR[C]
if K = 0 then
MSR[C] CarryOut
Registers Altered
rD
MSR[C]
Latency
1 cycle
Notes
In subtractions, Carry = (Borrow). When the Carry is set by a subtraction, it means that
there is no Borrow, and when the Carry is cleared, it means that there is a Borrow.
rsub
rD, rA, rB Subtract
rsubc
rD, rA, rB Subtract with Carry
rsubk
rD, rA, rB Subtract and Keep Carry
rsubkc
rD, rA, rB Subtract with Carry and Keep Carry
0 0 0 K C 1 rD rA rB 0 0 0 0 0 0 0 0 0 0 0
0 6 11 16 21 31