1,885
edits
Changes
no edit summary
The Rotate Right and Rotate Left (ROR/ROL) instructions are like the LSR/ASL instructions, except that the Carry flag is rotated into one end of the byte, and the bit from the other end is rotated into the Carry flag. For example, ROR will shift C into the high bit and the low bit into C. Therefore, it is possible to perform a multi-byte rotate by stringing together ROR or ROL instructions.
== Bitwise Operations ==
The 6502 offers a basic set of [[Bitwise Operations]], including:
ROR Rotate right - 9-bit rotate (one byte plus C flag)
ROL Rotate left - 9-bit rotate left (one byte plus C flag)
ASL Arithmetic shift left - bit 7 -> C flag, bits 0:6 -> 1:7, 0 -> bit 0
LSR Logical shift right - bit 0 -> C flag, bits 7:1 -> 6:0, 0 -> bit 7
EOR Exclusive-OR (synonym for XOR)
ORA OR (accumulator)
AND AND
A NOT operation can be performed using EOR with an immediate value of #$FF, and this can be combined with ORA and AND instructions to build NOR and NAND operations.
The BIT instruction performs a bitwise AND, sets the Z flag based on the result, and transfers bits 6 and 7 of the operatnd into the N and V flags.