Squonk, a related recent topic is "Simplest subset of 6502" which you did not post in, so I don't know if you saw it.Squonk wrote:
Most CPUs implement this set of hardware primitive functions to obtain a better efficiency:
- CLR: clear all bits (not supported by the 6502, but can be emulated by AND with a 0 value)
or LDA #0, or even LDX #0 or LDY #0, all taking two clocks, and two bytes, just as AND #0 does, but do not require the ALU.Quote:
- ADD: arithmetic addition (not supported by the 6502; one must clear the carry CLC before an addition with carry)
- SUB: arithmetic subtraction (not supported by the 6502, one must set the carry SEC before an subtraction with carry)
IMO, if there aren't enough op codes available to implement all the addressing modes of the operations both with and without the carry flag, ADC and SBC are much more useful. Even in single-byte arithmetic operations, there are many situations where you already know what the status of the C flag will be, and you don't have to set or clear it. In multi-byte arithmetic, you don't want the SEC or CLC except for the first byte handled, ie, the low byte.Quote:
This primitive operation set is often completed by derived operations, such as:
[...]
- ROL: logical bitwise rotate left (supported by the 6502)
- ROR: logical bitwise rotate right (supported by the 6502)
and:Quote:
Very often, arithmetic and rotations operations are derived in variants that include an input carry bit:
[..]
- RLC: logical bitwise rotate left through carry (not supported by the 6502)
- RRC: logical bitwise rotate right through carry (not supported by the 6502)
Note that the 6502's ROL and ROR do rotate through C.