Introduction
The logic instructions work on the accumulator, 8 or 16 bits by M. The shifts and rotates work on the accumulator or on memory, and, as the 65C02 does, BIT has an immediate form and TSB and TRB set and clear bits in memory.
The instructions
Each form is written mode opcode, bytes, cycles, then the cycle tags.
| Instruction | Forms | What it does | Flags |
|---|---|---|---|
and | imm 29, 2 or 3, 2 +Mdp 25, 2, 3 +M +DLdp,X 35, 2, 4 +M +DLabs 2D, 3, 4 +Mabs,X 3D, 3, 4 +M +Pabs,Y 39, 3, 4 +M +Plong 2F, 4, 5 +Mlong,X 3F, 4, 5 +M(dp) 32, 2, 5 +M +DL(dp,X) 21, 2, 6 +M +DL(dp),Y 31, 2, 5 +M +DL +P[dp] 27, 2, 6 +M +DL[dp],Y 37, 2, 6 +M +DLsr,S 23, 2, 4 +M(sr,S),Y 33, 2, 7 +M | A = A AND memory. | N Z |
ora | imm 09, 2 or 3, 2 +Mdp 05, 2, 3 +M +DLdp,X 15, 2, 4 +M +DLabs 0D, 3, 4 +Mabs,X 1D, 3, 4 +M +Pabs,Y 19, 3, 4 +M +Plong 0F, 4, 5 +Mlong,X 1F, 4, 5 +M(dp) 12, 2, 5 +M +DL(dp,X) 01, 2, 6 +M +DL(dp),Y 11, 2, 5 +M +DL +P[dp] 07, 2, 6 +M +DL[dp],Y 17, 2, 6 +M +DLsr,S 03, 2, 4 +M(sr,S),Y 13, 2, 7 +M | A = A OR memory. | N Z |
eor | imm 49, 2 or 3, 2 +Mdp 45, 2, 3 +M +DLdp,X 55, 2, 4 +M +DLabs 4D, 3, 4 +Mabs,X 5D, 3, 4 +M +Pabs,Y 59, 3, 4 +M +Plong 4F, 4, 5 +Mlong,X 5F, 4, 5 +M(dp) 52, 2, 5 +M +DL(dp,X) 41, 2, 6 +M +DL(dp),Y 51, 2, 5 +M +DL +P[dp] 47, 2, 6 +M +DL[dp],Y 57, 2, 6 +M +DLsr,S 43, 2, 4 +M(sr,S),Y 53, 2, 7 +M | A = A exclusive-OR memory. | N Z |
bit | imm 89, 2 or 3, 2 +Mdp 24, 2, 3 +M +DLdp,X 34, 2, 4 +M +DLabs 2C, 3, 4 +Mabs,X 3C, 3, 4 +M +P | Z is set when A AND memory is zero. With a memory operand N and V become the top two bits of the memory value (bits 7 and 6, or 15 and 14); the immediate form changes only Z. | N V Z (imm: Z) |
asl | acc 0A, 1, 2dp 06, 2, 5 +2M +DLdp,X 16, 2, 6 +2M +DLabs 0E, 3, 6 +2Mabs,X 1E, 3, 7 +2M | Shift left; bit 0 becomes 0 and the top bit goes to C. | N Z C |
lsr | acc 4A, 1, 2dp 46, 2, 5 +2M +DLdp,X 56, 2, 6 +2M +DLabs 4E, 3, 6 +2Mabs,X 5E, 3, 7 +2M | Shift right; the top bit becomes 0 and bit 0 goes to C. | N Z C |
rol | acc 2A, 1, 2dp 26, 2, 5 +2M +DLdp,X 36, 2, 6 +2M +DLabs 2E, 3, 6 +2Mabs,X 3E, 3, 7 +2M | Rotate left through carry. | N Z C |
ror | acc 6A, 1, 2dp 66, 2, 5 +2M +DLdp,X 76, 2, 6 +2M +DLabs 6E, 3, 6 +2Mabs,X 7E, 3, 7 +2M | Rotate right through carry. | N Z C |
tsb | dp 04, 2, 5 +2M +DLabs 0C, 3, 6 +2M | Test and set bits: Z is set when A AND memory is zero; then memory = memory OR A. | Z |
trb | dp 14, 2, 5 +2M +DLabs 1C, 3, 6 +2M | Test and reset bits: Z as TSB; then memory = memory AND NOT A. | Z |
Not described
Known, not yet covered
- Reference: the bus cycles of each instruction (the read, write and dummy cycles of a read-modify-write), as on the overview.
Links
Reference
- 65816 reference – the Super Famicom Development Wiki’s instruction table
- W65C816S data sheet – Western Design Center