instructionList.txt
List of all instructions in the 8608 architecture.

Instructions are encoded as the opcode, followed by any immediate values.
16-bit immediates are encoded in big-endian byte order.

Each instruction is described in order of: Mnemonic, Opcode, Clock cycles, Description

Control (C):
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

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 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
SUB #        EB  2  Subtract a given 8-bit value from 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
SBC #        E9  2  Subtract a given 8-bit value from the value in the A register including the Carry Flag,  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):
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 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):
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 #        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):
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):
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: 191/256
     0123456789ABCDEF
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-AUAXACA-B-B
F0 | BBWB--UM-AUAXAUA
