RRA

From C64-Wiki
Jump to navigationJump to search

RRA is the mnemonic for the illegal opcode machine language instruction which rotates one bit in memory then add memory to accumulator with carry. Bit 0 is shifted out into the carry flag and Carry flag is shifted into bit 7 by the ROR. Then an ADC is performed with memory and all flags are set according to the ADC.

This illegal opcode is a combination of two operations with the same addressing mode: ROR, ADC

Addressing modes[edit | edit source]

Opcode Addressing
mode
Assembler
format
Length
in bytes
Number of
cycles
Dec Hex
103 67 Zeropage RRA nn 2 5
119 77 Zeropage,X RRA nn,X 2 6
111 6F Absolute RRA nnnn 3 6
127 7F Absolute,X RRA nnnn,X 3 7
123 7B Absolute,Y RRA nnnn,Y 3 7
99 63 Indexed-indirect RRA (nn,X) 2 8
115 73 Indirect-indexed RRA (nn),Y 2 8

RRA supports the 7 different addressing modes shown in the table at right. In the assembler formats listed, nn represents a single-byte (8-bit) figure, and nnnn is a two-byte (16-bit) address.

CPU flags[edit | edit source]

RRA affects 4 of the CPU's status flags:

  • The negative flag is set if the result is negative, i.e. has it's most significant bit set (not in decimal mode).
  • The overflow flag is set if the operation results in an overflow (not in decimal mode).
  • The zero flag is set if the result is zero, or cleared if it is non-zero (not in decimal mode).
  • The carry flag is set if the addition resulted in an outgoing carry.