128 www.xilinx.com MicroBlaze Processor Reference Guide
1-800-255-7778 UG081 (v6.0) June 1, 2006
Chapter 4: MicroBlaze Instruction Set Architecture
Arithmetic Reverse Subtract Immediate
The contents of register rA is subtracted from the value of IMM, sign-extended to 32 bits,
and the result is placed into register rD. Bit 3 of the instruction (labeled as K in the ﬁgure)
is set to a one for the mnemonic rsubik. Bit 4 of the instruction (labeled as C in the ﬁgure)
is setto aone forthe mnemonicrsubic. Both bits are setto a one for the mnemonic rsubikc.
When an rsubi instruction has bit 3 set (rsubik, rsubikc), the carry ﬂag will Keep its
previous value regardless of the outcome of the execution of the instruction. If bit 3 is
cleared (rsubi, rsubic), then the carry ﬂag will be affected by the execution of the
instruction. When bit 4 of theinstruction is set to a one (rsubic, rsubikc), the content of the
carry ﬂag (MSR[C]) affects the execution of the instruction. When bit 4 is cleared (rsubi,
rsubik), the content of the carry ﬂag does not affect the execution of the instruction
(providing a normal subtraction).
if C = 0 then
(rD) ← sext(IMM) + (rA) + 1
(rD) ← sext(IMM) + (rA) + MSR[C]
if K = 0 then
MSR[C] ← CarryOut
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.
By default, Type BInstructionswill take the16-bit IMM ﬁeldvalue and sign extendit to 32
bits to use as the immediate operand. This behavior can be overridden by preceding the
Type B instruction with an imm instruction. See the imm instruction for details on using
32-bit immediate values.
rD, rA, IMM Subtract Immediate
rD, rA, IMM Subtract Immediate with Carry
rD, rA, IMM Subtract Immediate and Keep Carry
rD, rA, IMM Subtract Immediate with Carry and Keep Carry
0 0 1 K C 1 rD rA IMM
0 6 11 16 31