RRC

From Intellivision Wiki
Revision as of 09:09, 4 December 2010 by Mr z (talk | contribs) (Protected "RRC" ([edit=autoconfirmed] (indefinite) [move=autoconfirmed] (indefinite)))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Instruction NameRotate Right Through Carry
MnemonicRRC
CP1610 Clock Cycles6 or 8
InterruptibleNo
Opcode Range$0070-$0077
Input FlagsOverflow Flag, Carry Flag
Output FlagsSign Flag, Zero Flag, Overflow Flag, Carry Flag

The Rotate Right Through Carry (RRC) instruction rotates the bits in the specified register by one or two bits. For a single rotate, the Carry Flag is set to the value of bit 0, the value is shifted to the right by one bit, and bit 15 becomes the previous value of the Carry Flag. For a double rotate, the Carry Flag is set to the value of bit 0, the Overflow Flag is set to the value of bit 1, the value is shifted to the right by two bits, bit 14 becomes the previous value of the Carry Flag, and bit 15 becomes the previous value of the Overflow Flag. The resulting value is stored back to the specified register, and the Sign Flag and Zero Flag are set or cleared according to the new value in the register. The number of clock cycles used depends on the number of shifts specified. A single rotate will use 6 clock cycles and a double rotate will use 8 clock cycles.

RRC Instruction Diagram

The opcode format is as follows.

   0000:0000:0111:1srr
where: s indicates the number of places to rotate such that: s == 0 indicates to rotate once s == 1 indicates to rotate twice
rr indicates the target register such that: rrr == 000 indicates register R0 rrr == 001 indicates register R1 rrr == 010 indicates register R2 rrr == 011 indicates register R3