update and improve emulator

This commit is contained in:
Redo
2024-08-11 02:39:37 -06:00
parent 5f78ead08b
commit 4ae98df548
53 changed files with 6200 additions and 1434 deletions

View File

@@ -7,271 +7,219 @@ Instructions are encoded as the opcode, followed by any immediate values.
Each instruction is described in order of: Mnemonic, Opcode, Clock cycles, Description
Control (C):
rst 00 1 Clear all registers and set I=0
hlt F0 1 Halt non-interrupt execution
run F1 1 Resume non-interrupt execution
brk F3 1 Trigger interrupt
irt F4 1 Return from interrupt
nop FF 1 Do nothing
ien F5 1 Enbale interrupts
idi F6 1 Disable interrupts
RST 41 3 Clear all registers and flags, load the Program Counter from memory addresses $FFFC-$FFFD, and execute the code at the address given by those bytes
BRK 00 3 Trigger an interrupt from software, saving the current Program Counter in the V register and jumping to the Interrupt Vector stored at memory addresses $FFFE-$FFFF
RTI 40 1 Return from an interrupt, resuming normal execution where it left off when the interrupt occurred
NOP EA 1 Do nothing
CLI 58 1 Enable interrupts to be triggered by external hardware
SEI 78 1 Disable interrupts being triggered by external hardware
HLT 18 1 Clear the Run Flag, preventing the CPU from running until an interrupt is triggered
RUN 38 1 Set the Run Flag, allowing the CPU to run once the current interrupt finishes
16-bit Inc/Dec (I):
inc p 12 1 P++
dec p 15 1 P--
inc q 13 1 Q++
dec q 16 1 Q--
8-bit Unary Arithmetic (U):
INC A F6 1 Increment the A register, and set the Carry Flag and Zero Flag according to the result
DEC A D6 1 Decrement the A register, and set the Carry Flag and Zero Flag according to the result
ICC A 57 1 Add the Carry Flag to the A register, and set the Carry Flag and Zero Flag according to the result
INC B FE 1 Increment the B register, and set the Carry Flag and Zero Flag according to the result
DEC B DE 1 Decrement the B register, and set the Carry Flag and Zero Flag according to the result
ICC B 5F 1 Add the Carry Flag to the B register, and set the Carry Flag and Zero Flag according to the result
INC C FA 1 Increment the C register, and set the Carry Flag and Zero Flag according to the result
DEC C DA 1 Decrement the C register, and set the Carry Flag and Zero Flag according to the result
ICC C 5B 1 Add the Carry Flag to the C register, and set the Carry Flag and Zero Flag according to the result
INC zpg E6 4 Increment the value at an given 8-bit address, and set the Carry Flag and Zero Flag according to the result
DEC zpg C6 4 Decrement the value at an given 8-bit address, and set the Carry Flag and Zero Flag according to the result
ICC zpg 47 4 Add the Carrry Flag to the value at an given 8-bit address, and set the Carry Flag and Zero Flag according to the result
8-bit Unary (U):
inc a 10 1 A++, set flags
dec a 11 1 A--, set flags
icc a 1B 1 A+=CF, set flags
inc b 19 1 B++, set flags
dec b 1A 1 B--, set flags
icc b 1C 1 B+=CF, set flags
inc c 17 1 C++, set flags
dec c 18 1 C--, set flags
icc c 1D 1 C+=CF, set flags
tst a 14 1 Set flags according to A-0
tst b 1E 1 Set flags according to B-0
tst c 1F 1 Set flags according to C-0
inc *s+imm8 2B 4 *(S+imm8)++, set flags
dec *s+imm8 2C 4 *(S+imm8)--, set flags
icc *s+imm8 2D 4 *(S+imm8)+=CF, set flags
tst *s+imm8 2E 3 Set flags according to *(S+imm8)-0
8-bit Arithmetic and Logic (A):
ADD # 6B 2 Add a given 8-bit value to the value in the A register, and set the Carry Flag and Zero Flag according to the result
ADC # 69 2 Add a given 8-bit value plus the Carry Flag to the value in the A register, and set the Carry Flag and Zero Flag according to the result
CMP # C9 2 Set the Carry Flag and Zero Flag according to the result of subtracting a given 8-bit value from the value in the A register
AND # 29 2 Bitwise AND the value in the A register with a given 8-bit value, and set the Zero Flag according to the result
ORA # 09 2 Bitwise OR the value in the A register with a given 8-bit value, and set the Zero Flag according to the result
EOR # 49 2 Bitwise Exclusive OR the value in the A register with a given 8-bit value, and set the Zero Flag according to the result
ASL # 15 2 Bit-shift the value in the A register left by a given number of bits, and set the Zero Flag according to the result
LSR # 55 2 Bit-shift the value in the A register right by a given number of bits, and set the Zero Flag according to the result
ROL # 35 2 Bit-rotate the value in the A register left by a given number of bits, and set the Zero Flag according to the result
ROR # 75 2 Bit-rotate the value in the A register right by a given number of bits, and set the Zero Flag according to the result
ADD zpg 67 3 Add the value in memory at a given 8-bit address to the value in the A register, and set the Carry Flag and Zero Flag according to the result
SUB zpg E7 3 Subtract the value in memory at a given 8-bit address from the value in the A register, and set the Carry Flag and Zero Flag according to the result
ADC zpg 65 3 Add the value in memory at a given 8-bit address plus the Carry Flag to the value in the A register, and set the Carry Flag and Zero Flag according to the result
SBC zpg E5 3 Subtract the value in memory at a given 8-bit address from the value in the A register including the Carry Flag, and set the Carry Flag and Zero Flag according to the result
CMP zpg C5 3 Set the Carry Flag and Zero Flag according to the result of subtracting the value in memory at a given 8-bit address from the value in the A register
AND zpg 25 3 Bitwise AND the value in the A register with the value in memory at a given 8-bit address, and set the Carry Flag and Zero Flag according to the result
ORA zpg 05 3 Bitwise OR the value in the A register with the value in memory at a given 8-bit address, and set the Carry Flag and Zero Flag according to the result
EOR zpg 45 3 Bitwise Exclusive OR the value in the A register with the value in memory at a given 8-bit address, and set the Carry Flag and Zero Flag according to the result
ADD B 7F 1 Add the value in the B register to the value in the A register, and set the Carry Flag and Zero Flag according to the result
SUB B FF 1 Subtract the value in the B register from the value in the A register, and set the Carry Flag and Zero Flag according to the result
ADC B 7D 1 Add the value in the B register plus the Carry Flag to the value in the A register, and set the Carry Flag and Zero Flag according to the result
SBC B FD 1 Subtract the value in the B register form the value in the A register including the Carry Flag, and set the Carry Flag and Zero Flag according to the result
CMP B DD 1 Set the Carry Flag and Zero Flag according to the result of subtracting the value in the B register from the value in the A register
AND B 3D 1 Bitwise AND the value in the A register with the value in the B register, and set the Carry Flag and Zero Flag according to the result
ORA B 1D 1 Bitwise OR the value in the A register with the value in the B register, and set the Carry Flag and Zero Flag according to the result
EOR B 5D 1 Bitwise Exclusive OR the value in the A register with the value in the B register, and set the Carry Flag and Zero Flag according to the result
ADD C 7B 1 Add the value in the C register to the value in the A register, and set the Carry Flag and Zero Flag according to the result
SUB C FB 1 Subtract the value in the C register from the value in the A register, and set the Carry Flag and Zero Flag according to the result
ADC C 79 1 Add the value in the C register plus the Carry Flag to the value in the A register, and set the Carry Flag and Zero Flag according to the result
SBC C F9 1 Subtract the value in the C register form the value in the A register including the Carry Flag, and set the Carry Flag and Zero Flag according to the result
CMP C D9 1 Set the Carry Flag and Zero Flag according to the result of subtracting the value in the C register from the value in the A register
AND C 39 1 Bitwise AND the value in the A register with the value in the C register, and set the Carry Flag and Zero Flag according to the result
ORA C 19 1 Bitwise OR the value in the A register with the value in the C register, and set the Carry Flag and Zero Flag according to the result
EOR C 59 1 Bitwise Exclusive OR the value in the A register with the value in the C register, and set the Carry Flag and Zero Flag according to the result
Conditional Branches (B):
BNE rel D0 2 If the result of the last math operation was not 0, Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program; Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the programc
BEQ rel F0 2 If the result of the last math operation was 0, Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program; Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the programc
BLT rel 90 2 If the result of the last math operation was negative, Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program; Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the programc
BGE rel B0 2 If the result of the last math operation was positive or 0, Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program; Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the programc
BGT rel 30 2 If the result of the last math operation was positive, Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program; Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the programc
BLE rel 10 2 If the result of the last math operation was negative or 0, Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program; Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the programc
BRA rel 98 2 Add a signed 8-bit offset to the Program Counter, jumping forward or backward in the program
16-bit Arithmetic (X):
adp imm8 4A 2 P+=imm8 signed
adq imm8 4B 2 Q+=imm8 signed
ads imm8 4C 2 S+=imm8 signed
adp b E6 1 P+=B signed
adq b E7 1 Q+=B signed
ads b E8 1 S+=B signed
8-bit Arithmetic/Logic (A):
add imm8 24 2 A+=imm8, set flags
adb imm8 72 2 B+=imm8, set flags
adc imm8 73 2 C+=imm8, set flags
acc imm8 78 2 A+=imm8+CF, set flags
cmp imm8 71 2 set flags according to A-imm8
and imm8 74 2 A&=imm8, set zero flag
ior imm8 75 2 A|=imm8, set zero flag
xor imm8 76 2 A^=imm8, set zero flag
shl imm8 D0 2 A<<=imm8, set zero flag
shr imm8 D1 2 A>>=imm8, set zero flag
rol imm8 D2 2 A<<<=imm8, set zero flag
ror imm8 D3 2 A>>>=imm8, set zero flag
sra imm8 D4 2 A>>a=imm8, set zero flag
add *s+imm8 AE 3 A+=*(S+imm8), set flags
adb *s+imm8 9B 3 B+=*(S+imm8), set flags
adc *s+imm8 9C 3 C+=*(S+imm8), set flags
sub *s+imm8 AF 3 A-=*(S+imm8), set flags
sbb *s+imm8 9D 3 B-=*(S+imm8), set flags
sbc *s+imm8 9E 3 C-=*(S+imm8), set flags
acc *s+imm8 B5 3 A+=*(S+imm8)+CF, set flags
scc *s+imm8 B7 3 A-=*(S+imm8)+CF, set flags
cmp *s+imm8 B0 3 set flags according to A-*(S+imm8)
and *s+imm8 B1 3 A&=*(S+imm8), set zero flag
ior *s+imm8 B2 3 A|=*(S+imm8), set zero flag
xor *s+imm8 B3 3 A^=*(S+imm8), set zero flag
shl *s+imm8 D5 3 A<<=*(S+imm8), set zero flag
shr *s+imm8 D6 3 A<<=*(S+imm8), set zero flag
rol *s+imm8 D7 3 A<<<=*(S+imm8), set zero flag
ror *s+imm8 D8 3 A>>>=*(S+imm8), set zero flag
sra *s+imm8 D9 3 A>>a=*(S+imm8), set zero flag
add b A0 1 A+=B, set flags
adc b 9F 1 C+=B, set flags
sub b A1 1 A-=B, set flags
sbc b B6 1 C-=B, set flags
acc b B8 1 A+=B+CF, set flags
scc b B9 1 A-=B+CF, set flags
cmp b A2 1 set flags according to A-B
and b A3 1 A&=B, set zero flag
ior b A4 1 A|=B, set zero flag
xor b A5 1 A^=B, set zero flag
shl b DA 1 A<<=B, set zero flag
shr b DB 1 A>>=B, set zero flag
rol b DC 1 A<<<=B, set zero flag
ror b DD 1 A>>>=B, set zero flag
sra b DE 1 A>>a=B, set zero flag
add c A7 1 A+=C, set flags
adb c BD 1 B+=C, set flags
sub c A8 1 A-=C, set flags
sbb c BC 1 B-=C, set flags
acc c BA 1 A+=C+CF, set flags
scc c BB 1 A-=C+CF, set flags
cmp c A9 1 set flags according to A-C
and c AA 1 A&=C, set zero flag
ior c AB 1 A|=C, set zero flag
xor c AC 1 A^=C, set zero flag
shl c DF 1 A<<=C, set zero flag
shr c 4D 1 A>>=C, set zero flag
rol c 3E 1 A<<<=C, set zero flag
ror c 3F 1 A>>>=C, set zero flag
sra c 2F 1 A>>a=C, set zero flag
adb a BE 1 B+=A, set flags
sbb a BF 1 B-=A, set flags
adc a 4E 1 C+=A, set flags
sbc a 4F 1 C-=A, set flags
ADX # E8 2 Add a given 8-bit value to the 16-bit X register
ADY # C8 2 Add a given 8-bit value to the 16-bit Y register
ADX ## 8A 3 Add a given 16-bit value to the 16-bit X register
ADY ## 88 3 Add a given 16-bit value to the 16-bit Y register
ADX A FC 1 Add the 8-bit signed value in the A register to the 16-bit X register
ADY A DC 1 Add the 8-bit signed value in the A register to the 16-bit Y register
Jumps (J):
jmp imm16 60 3 I=imm16
jsr imm16 63 3 I=imm16, Q=I
jss imm16 E2 5 I=imm16, *(S++++)=I-1
jmp p 64 1 I=P
jmp q 66 1 I=Q
jsr p 65 1 I=P, Q=I
jsr q 67 1 I=Q, Q=I
jss p E4 3 I=P, *(S++++)=I-1
jss q E5 3 I=Q, *(S++++)=I-1
rts E1 3 I=*(----S)+1
jpr imm8 31 2 I+=imm8
jnz imm8 30 2 I+=imm8 if !Zero
jpz imm8 32 2 I+=imm8 if Zero
jlt imm8 33 2 I+=imm8 if !Carry
jge imm8 34 2 I+=imm8 if Carry
jgt imm8 35 2 I+=imm8 if !Zero & Carry
jle imm8 36 2 I+=imm8 if Zero | !Carry
JMP abs CC 3 Jump - Set the Program Counter to a given 16-bit value, executing the code at that address
JSR abs 20 5 Jump to Subroutine - Save the Program Counter on the Stack, then set it to a given 16-bit value, executing the code at that address
JMP [ind] 6C 5 Load a subroutine pointer from memory at a given 16-bit address, then jump to that subroutine, saving the return address on the stack.
JSR [ind] 2C 7 Load a code pointer from memory at a given 16-bit address, then jump to that code.
JMP [ind,A] 4C 5 Load a subroutine pointer from memory at a given 16-bit address, then jump to that subroutine, saving the return address on the stack.
JSR [ind,A] 0C 7 Load a code pointer from memory at a given 16-bit address, then jump to that code.
JMP X 64 1 Set the Program Counter to the 16-bit value in the X register, executing the code at that address
JMP Y 44 1 Set the Program Counter to the 16-bit value in the Y register, executing the code at that address
JSR X 24 3 Save the Program Counter on the Stack, then set it to the 16-bit value in the X register, executing the code at that address
JSR Y 04 3 Save the Program Counter on the Stack, then set it to the 16-bit value in the Y register, executing the code at that address
RTS 60 3 Retrieve the Program Counter from the stack, returning to where the last JSR instruction was executed
Stack (S):
psh a 40 2 *(S++)=A
psh b 44 2 *(S++)=B
psh c 45 2 *(S++)=C
psh f E9 2 *(S++)=F
psh p 41 3 *(S++++)=P
psh q 46 3 *(S++++)=Q
pop a 42 2 A=*(--S)
pop b 47 2 B=*(--S)
pop c 48 2 C=*(--S)
pop f EA 2 F=*(--S)
pop p 43 3 P=*(----S)
pop q 49 3 Q=*(----S)
psh imm8 3B 3 *(S++)=imm8
phw imm16 3C 5 *(S++++)=imm16
PHA 48 2 Push the value in the A register onto the Stack
PHB 5C 2 Push the value in the B register onto the Stack
PHC 1C 2 Push the value in the C register onto the Stack
PHP 08 2 Push a byte containing the Carry Flag and Zero Flag onto the Stack
PHX 54 3 Push the 16-bit value in the X register onto the Stack
PHY 14 3 Push the 16-bit value in the Y register onto the Stack
PLA 68 2 Pull a byte from the Stack, and store it in the A register
PLB 7C 2 Pull a byte from the Stack, and store it in the B register
PLC 3C 2 Pull a byte from the Stack, and store it in the C register
PLP 28 2 Pull a byte from the Stack, and use it to set the Carry Flag and Zero flag
PLX 74 3 Pull two bytes from the stack, and store the resulting 16-bit value in the X register
PLY 34 3 Pull two bytes from the stack, and store the resulting 16-bit value in the Y register
8-bit Load/Store (B):
lda imm8 20 2 A=imm8, update zero flag
ldb imm8 26 2 B=imm8, update zero flag
ldc imm8 27 2 C=imm8, update zero flag
lda *s+imm8 28 3 A=*s+imm8, update zero flag
ldb *s+imm8 29 3 B=*s+imm8, update zero flag
ldc *s+imm8 2A 3 C=*s+imm8, update zero flag
sta *s+imm8 96 3 *s+imm8=A
stb *s+imm8 97 3 *s+imm8=B
stc *s+imm8 98 3 *s+imm8=C
lda *imm16 51 4 A=*imm16, update zero flag
ldb *imm16 56 4 B=*imm16, update zero flag
ldc *imm16 57 4 C=*imm16, update zero flag
sta *imm16 50 4 *imm16=A
stb *imm16 58 4 *imm16=B
stc *imm16 59 4 *imm16=C
lda *p+imm16 01 4 A=*P+imm16, update zero flag
ldb *p+imm16 F7 4 B=*P+imm16, update zero flag
ldc *p+imm16 FE 4 C=*P+imm16, update zero flag
lda *q+imm16 EB 4 A=*Q+imm16, update zero flag
ldb *q+imm16 08 4 B=*Q+imm16, update zero flag
ldc *q+imm16 09 4 C=*Q+imm16, update zero flag
sta *p+imm16 0A 4 *P+imm16=A
stb *p+imm16 0B 4 *P+imm16=B
stc *p+imm16 0C 4 *P+imm16=C
sta *q+imm16 0D 4 *Q+imm16=A
stb *q+imm16 0E 4 *Q+imm16=B
stc *q+imm16 0F 4 *Q+imm16=C
lda *p 53 2 A=*P, update zero flag
ldb *p 5E 2 B=*P, update zero flag
ldc *p 5F 2 C=*P, update zero flag
lda *q 55 2 A=*Q, update zero flag
ldb *q 61 2 B=*Q, update zero flag
ldc *q 62 2 C=*Q, update zero flag
sta *p 52 2 *P=A
stb *p 5A 2 *P=B
stc *p 5B 2 *P=C
sta *q 54 2 *Q=A
stb *q 5C 2 *Q=B
stc *q 5D 2 *Q=C
lda *p++ C6 2 A=*P++, update zero flag
ldb *p++ C7 2 B=*P++, update zero flag
ldc *p++ C8 2 C=*P++, update zero flag
lda *q++ C9 2 A=*Q++, update zero flag
ldb *q++ CA 2 B=*Q++, update zero flag
ldc *q++ CB 2 C=*Q++, update zero flag
sta *p++ C0 2 *P++=A
stb *p++ C1 2 *P++=B
stc *p++ C2 2 *P++=C
sta *q++ C3 2 *Q++=A
stb *q++ C4 2 *Q++=B
stc *q++ C5 2 *Q++=C
LDA # A9 2 Set the A register to a given 8-bit value
LDB # AB 2 Set the B register to a given 8-bit value
LDC # 2B 2 Set the C register to a given 8-bit value
LDA zpg A5 3 Set the A register to the value in memory at a given 8-bit address, and set the Zero Flag according to the value loaded
LDB zpg A7 3 Set the B register to the value in memory at a given 8-bit address, and set the Zero Flag according to the value loaded
LDC zpg 27 3 Set the C register to the value in memory at a given 8-bit address, and set the Zero Flag according to the value loaded
STA zpg 85 3 Store the value in the A register in memory at an given 8-bit address
STB zpg 87 3 Store the value in the B register in memory at an given 8-bit address
STC zpg 07 3 Store the value in the C register in memory at an given 8-bit address
LDA abs ED 4 Set the A register to the value in memory at a given 16-bit address, and set the Zero Flag according to the value loaded
LDB abs EF 4 Set the B register to the value in memory at a given 16-bit address, and set the Zero Flag according to the value loaded
LDC abs 6F 4 Set the C register to the value in memory at a given 16-bit address, and set the Zero Flag according to the value loaded
STA abs CD 4 Store the value in the A register in memory at a given 16-bit address
STB abs CF 4 Store the value in the B register in memory at a given 16-bit address
STC abs 4F 4 Store the value in the C register in memory at a given 16-bit address
LDA X A1 2 Set the A register to the value in memory at the address in X, and set the Zero Flag according to the value loaded
LDB X A3 2 Set the B register to the value in memory at the address in X, and set the Zero Flag according to the value loaded
LDC X 23 2 Set the C register to the value in memory at the address in X, and set the Zero Flag according to the value loaded
LDA Y B1 2 Set the A register to the value in memory at the address in Y, and set the Zero Flag according to the value loaded
LDB Y B3 2 Set the B register to the value in memory at the address in Y, and set the Zero Flag according to the value loaded
LDC Y 33 2 Set the C register to the value in memory at the address in Y, and set the Zero Flag according to the value loaded
STA X 81 2 Store the value in the A register in memory at the address in X
STB X 83 2 Store the value in the B register in memory at the address in X
STC X 03 2 Store the value in the C register in memory at the address in X
STA Y 91 2 Store the value in the A register in memory at the address in Y
STB Y 93 2 Store the value in the B register in memory at the address in Y
STC Y 13 2 Store the value in the C register in memory at the address in Y
LDA X+ E1 2 Set the A register to the value in memory at the address in X, increment the X register, and set the Zero Flag according to the value loaded
LDB X+ E3 2 Set the B register to the value in memory at the address in X, increment the X register, and set the Zero Flag according to the value loaded
LDC X+ 63 2 Set the C register to the value in memory at the address in X, increment the X register, and set the Zero Flag according to the value loaded
LDA Y+ F1 2 Set the A register to the value in memory at the address in Y, increment the Y register, and set the Zero Flag according to the value loaded
LDB Y+ F3 2 Set the B register to the value in memory at the address in Y, increment the Y register, and set the Zero Flag according to the value loaded
LDC Y+ 73 2 Set the C register to the value in memory at the address in Y, increment the Y register, and set the Zero Flag according to the value loaded
STA X+ C1 2 Store the value in the A register in memory at the address in X, and increment the X register
STB X+ C3 2 Store the value in the B register in memory at the address in X, and increment the X register
STC X+ 43 2 Store the value in the C register in memory at the address in X, and increment the X register
STA Y+ D1 2 Store the value in the A register in memory at the address in Y, and increment the Y register
STB Y+ D3 2 Store the value in the B register in memory at the address in Y, and increment the Y register
STC Y+ 53 2 Store the value in the C register in memory at the address in Y, and increment the Y register
LDA X,ofs BD 3 Set the A register to the value in memory at the address (X plus a given 8-bit offset), and set the Zero Flag according to the value loaded
LDB X,ofs BF 3 Set the B register to the value in memory at the address (X plus a given 8-bit offset), and set the Zero Flag according to the value loaded
LDC X,ofs 3F 3 Set the C register to the value in memory at the address (X plus a given 8-bit offset), and set the Zero Flag according to the value loaded
LDA Y,ofs B9 3 Set the A register to the value in memory at the address (Y plus a given 8-bit offset), and set the Zero Flag according to the value loaded
LDB Y,ofs BB 3 Set the B register to the value in memory at the address (Y plus a given 8-bit offset), and set the Zero Flag according to the value loaded
LDC Y,ofs 3B 3 Set the C register to the value in memory at the address (Y plus a given 8-bit offset), and set the Zero Flag according to the value loaded
STA X,ofs 9D 3 Store the value in the A register in memory at the address (X plus a given 8-bit offset)
STB X,ofs 9F 3 Store the value in the A register in memory at the address (X plus a given 8-bit offset)
STC X,ofs 1F 3 Store the value in the A register in memory at the address (X plus a given 8-bit offset)
STA Y,ofs 99 3 Store the value in the A register in memory at the address (Y plus a given 8-bit offset)
STB Y,ofs 9B 3 Store the value in the A register in memory at the address (Y plus a given 8-bit offset)
STC Y,ofs 1B 3 Store the value in the A register in memory at the address (Y plus a given 8-bit offset)
16-bit Load/Store (W):
ldp imm16 21 3 P=imm16
ldq imm16 23 3 Q=imm16
lds imm16 25 3 S=imm16
ldv imm16 22 3 V=imm16
ldp *s+imm8 7A 4 P=*S+imm8
ldq *s+imm8 7B 4 Q=*S+imm8
stp *s+imm8 7E 4 *S+imm8=P
stq *s+imm8 7F 4 *S+imm8=Q
ldp *imm16 68 5 P=*imm16
ldq *imm16 6A 5 Q=*imm16
stp *imm16 6C 5 *imm16=P
stq *imm16 6E 5 *imm16=Q
ldp *p+imm16 EC 5 P=*P+imm16
ldq *p+imm16 EE 5 Q=*P+imm16
ldp *q+imm16 F8 5 P=*Q+imm16
ldq *q+imm16 FA 5 Q=*Q+imm16
stq *p+imm16 06 5 *P+imm16=Q
stp *q+imm16 FC 5 *Q+imm16=P
ldp *p 92 3 P=*P
ldq *p 93 3 Q=*P
ldp *q 94 3 P=*Q
ldq *q 95 3 Q=*Q
stp *q 7C 3 *Q=P
stq *p 7D 3 *P=Q
ldq *p++ CC 3 Q=*P++++
ldp *q++ CD 3 P=*Q++++
stp *q++ CE 3 *Q++++=P
stq *p++ CF 3 *P++++=Q
LDX ## AA 3 Set the X register to a given 16-bit value
LDY ## A8 3 Set the X register to a given 16-bit value
LDX zpg A6 4 Set the X register to the 16-bit value in memory at a given 8-bit address
LDY zpg A4 4 Set the Y register to the 16-bit value in memory at a given 8-bit address
STX zpg 86 4 Store the 16-bit value in the X register in memory at an given 8-bit address
STY zpg 84 4 Store the 16-bit value in the Y register in memory at an given 8-bit address
LDX abs AE 5 Set the X register to the 16-bit value in memory at a given 16-bit address
LDY abs AC 5 Set the Y register to the 16-bit value in memory at a given 16-bit address
STX abs 8E 5 Store the 16-bit value in the X register in memory at a given 16-bit address
STY abs 8C 5 Store the 16-bit value in the X register in memory at a given 16-bit address
LDX X,ofs BE 4 Set the X register to the 16-bit value in memory at the address (X plus a given 8-bit offset)
LDX Y,ofs BA 4 Set the Y register to the 16-bit value in memory at the address (X plus a given 8-bit offset)
LDY X,ofs BC 4 Set the X register to the 16-bit value in memory at the address (Y plus a given 8-bit offset)
LDY Y,ofs B8 4 Set the Y register to the 16-bit value in memory at the address (Y plus a given 8-bit offset)
STX Y,ofs 9A 4 Store the 16-bit value in the X register in memory at the address (Y plus a given 8-bit offset)
STY X,ofs 9C 4 Store the 16-bit value in the Y register in memory at the address (X plus a given 8-bit offset)
LDX X A2 3 Set the X register to the 16-bit value in memory at the address in X
LDY X A0 3 Set the Y register to the 16-bit value in memory at the address in X
LDX Y B2 3 Set the X register to the 16-bit value in the Y registerin16
LDY Y E2 3 Set the Y register to the 16-bit value in the Y registerin16
STX Y 92 3 Store the 16-bit value in the X register in memory at the address in Y
STY X 80 3 Store the 16-bit value in the Y register in memory at the address in X
LDX Y+ F2 3 Set the X register to the 16-bit value in the Y registerin16, the 16-bit value in the Y registerinc16
LDY X+ E0 3 Set the Y register to the 16-bit value in memory at the address in X, the 16-bit value in the X registerinc16
STX Y+ D2 3 Store the 16-bit value in the X register in memory at the address in Y, the 16-bit value in the Y registerinc16
STY X+ C0 3 Store the 16-bit value in the Y register in memory at the address in X, the 16-bit value in the X registerinc16
Moves (M):
lda b 80 1 A=B
lda c 81 1 A=C
ldb a 82 1 B=A
ldb c 83 1 B=C
ldc a 84 1 C=A
ldc b 85 1 C=B
lda pl 86 1 A=P&FF
lda ph 87 1 A=P>>8
lda ql 88 1 A=Q&FF
lda qh 89 1 A=Q>>8
ldb pl 37 1 B=P&FF
ldc ph 38 1 C=P>>8
ldb ql 39 1 B=Q&FF
ldc qh 3A 1 C=Q>>8
ldp q 8A 1 P=Q
ldp s 8B 1 P=S
ldp v 8C 1 P=V
ldp i 8D 1 P=I
ldp cb 91 1 P=(C<<8)+B
ldq cb E0 1 Q=(C<<8)+B
ldq p 8E 1 Q=P
lds p 8F 1 S=P
ldv p 90 1 V=P
TBA 97 1 Copy the value in the B register into the A register
TCA 17 1 Copy the value in the C register into the A register
TAB B7 1 Copy the value in the A register into the B register
TCB D7 1 Copy the value in the C register into the B register
TAC 37 1 Copy the value in the A register into the C register
TBC F7 1 Copy the value in the B register into the C register
TYX B4 1 Copy the 16-bit value in the Y register into the 16-bit X register
TXY 94 1 Copy the 16-bit value in the X register into the 16-bit Y register
TVX B6 1 Copy the 16-bit Interrupt Return Address into the X register
TXV 96 1 Copy the 16-bit value in the X register into the 16-bit Interrupt Return Address register
TAS 95 1 Copy the value in the A register into the 8-bit Stack Pointer register
TSA B5 1 Copy the 8-bit Stack Pointer into the A register
Opcodes used: 244/255
Opcodes used: 189/256
0123456789ABCDEF
00 | CB----WWBBBBBBBB
10 | UUIIUIIUUUUUUUUU
20 | BWWWAWBBBBBUUUUA
30 | JJJJJJJMMMMSSSAA
40 | SSSSSSSSSSXXXAAA
50 | BBBBBBBBBBBBBBBB
60 | JBBJJJJJWWWWWWWW
70 | -AAAAAA-A-WWWWWW
80 | MMMMMMMMMMMMMMMM
90 | MMWWWWBBB--AAAAA
A0 | AAAAAA-AAAAAA-AA
B0 | AAAA-AAAAAAAAAAA
C0 | BBBBBBBBBBBBWWWW
D0 | AAAAAAAAAAAAAAAA
E0 | MJJJJJXXXSSBWWWW
F0 | CCCCCCCBWWWWWWBC
00 | CC-BJA-BSA--JJ--
10 | B--BSA-MCA-BSA-B
20 | JJ-BJA-BSA-BJJ--
30 | B--BSA-MCA-BSA-B
40 | CC-BJA-USA--JJ-B
50 | ---BSA-UCA-USA-U
60 | J--BJA-ASA-AJJ-B
70 | ---BSA--CA-ASA-A
80 | WB-BWBWBX-X-WWWW
90 | BBWBMMMMBBWBWB-B
A0 | WBWBWBWBWBWBWWWW
B0 | BBWBMMMMWBWBWBWB
C0 | WB-B-AU-XA--JB-B
D0 | BBWB--UM-AU-XAU-
E0 | WBWB-AUAX-C--B-B
F0 | BBWB--UM-AUAXAUA