Difference between revisions of "K65 Instructions"
From KK's Wiki
(Created page with "{| ! Opcode ! K65 Syntax ! Description |- |ADC |a+# |add with carry |- |AND |a&# |and (with accumulator) |- |ASL |#<< |arithmetic shift left |- BCC .... branch on carry clear...") |
|||
Line 1: | Line 1: | ||
− | {| | + | {| class="wikitable" style="text-align: center;" |
− | ! Opcode | + | ! rowspan="2" | Opcode |
− | ! | + | ! rowspan="2" | Description |
− | ! | + | ! colspan="9" | K65 Syntax |
|- | |- | ||
− | | | + | | width="7%" | Acc |
− | | | + | | width="7%" | Implied |
− | | | + | | width="7%" | Imm |
+ | | width="7%" | Mem | ||
+ | | width="7%" | Mem,X | ||
+ | | width="7%" | Mem,Y | ||
+ | | width="7%" | (Mem,X) | ||
+ | | width="7%" | (Mem),Y | ||
+ | | width="7%" | (Mem) | ||
|- | |- | ||
− | | | + | | ADC || style="text-align: left;" | add with carry || || || a+imm || a+mem || a+mem,x || a+mem,y || a+(mem,x) || a+(mem),y || |
− | | | + | |
− | | | + | |
|- | |- | ||
− | | | + | | AND || style="text-align: left;" | and (with accumulator) || || || a&imm || a&mem || a&mem,x || a&mem,y || a&(mem,x) || a&(mem),y || |
− | | | + | |
− | | | + | |
|- | |- | ||
− | + | | ASL || style="text-align: left;" | arithmetic shift left || a<< || || || mem<< || mem,x<< || || || || | |
|- | |- | ||
− | | | + | | BCC || style="text-align: left;" | branch on carry clear || colspan="9" | >={ ... } ''or'' < goto label ''or'' { ... } < ''or'' c+{ ... } ''or'' c- goto label ''or'' { ... } c- |
|- | |- | ||
− | | | + | | BCS || style="text-align: left;" | branch on carry set || colspan="9" | <{ ... } ''or'' >= goto label ''or'' { ... } >= ''or'' c-{ ... } ''or'' c+ goto label ''or'' { ... } c+ |
|- | |- | ||
− | | | + | | BEQ || style="text-align: left;" | branch on equal (zero set) || colspan="9" | { ... } ''or'' == goto label ''or'' { ... } == |
|- | |- | ||
− | | | + | | BIT || style="text-align: left;" | bit test || || || || a?mem || || || || || |
|- | |- | ||
− | | | + | | BMI || style="text-align: left;" | branch on minus (negative set) || colspan="9" | >=0{ ... } ''or'' <0 goto label ''or'' { ... } <0 |
|- | |- | ||
− | | | + | | BNE || style="text-align: left;" | branch on not equal (zero clear) || colspan="9" | =={ ... } ''or'' != goto label ''or'' { ... } != |
|- | |- | ||
− | | | + | | BPL || style="text-align: left;" | branch on plus (negative clear) || colspan="9" | <0{ ... } ''or'' >=0 goto label ''or'' { ... } >=0 |
|- | |- | ||
− | | | + | | BRK || style="text-align: left;" | interrupt || || ''TBD'' || || || || || || || |
|- | |- | ||
− | | | + | | BVC || style="text-align: left;" | branch on overflow clear || colspan="9" | <<={ ... } ''or'' >>= goto label ''or'' { ... } >>= ''or'' o+{ ... } ''or'' o- goto label ''or'' { ... } o- |
|- | |- | ||
− | | | + | | BVS || style="text-align: left;" | branch on overflow set || colspan="9" | >>={ ... } ''or'' <<= goto label ''or'' { ... } <<= ''or'' o-{ ... } ''or'' o+ goto label ''or'' { ... } o+ |
|- | |- | ||
− | | | + | | CLC || style="text-align: left;" | clear carry || || c- || || || || || || || |
|- | |- | ||
− | | | + | | CLD || style="text-align: left;" | clear decimal || || d- || || || || || || || |
|- | |- | ||
− | | | + | | CLI || style="text-align: left;" | clear interrupt disable || || i- || || || || || || || |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
|- | |- | ||
− | | | + | | CLV || style="text-align: left;" | clear overflow || || o- || || || || || || || |
− | | | + | |
− | | | + | |
|- | |- | ||
− | | | + | | CMP || style="text-align: left;" | compare (with accumulator) || || || a?imm || a?mem || a?mem,x || a?mem,y || a?(mem,x) || a?(mem),y || |
− | | | + | |
− | | | + | |
|- | |- | ||
− | | | + | | CPX || style="text-align: left;" | compare with X || || || x?imm || x?mem || || || || || |
− | | | + | |- |
− | | | + | | CPY || style="text-align: left;" | compare with Y || || || y?imm || y?mem || || || || || |
+ | |- | ||
+ | | DEC || style="text-align: left;" | decrement || || || || mem-- || mem,x-- || || || || | ||
+ | |- | ||
+ | | DEX || style="text-align: left;" | decrement X || || x-- || || || || || || || | ||
+ | |- | ||
+ | | DEY || style="text-align: left;" | decrement Y || || y-- || || || || || || || | ||
+ | |- | ||
+ | | EOR || style="text-align: left;" | exclusive or (with accumulator) || || || a^imm || a^mem || a^mem,x || a^mem,y || a^(mem,x) || a^(mem),y || | ||
+ | |- | ||
+ | | INC || style="text-align: left;" | increment || || || || mem++ || mem,x++ || || || || | ||
+ | |- | ||
+ | | INX || style="text-align: left;" | increment X || || x++ || || || || || || || | ||
+ | |- | ||
+ | | INY || style="text-align: left;" | increment Y || || y++ || || || || || || || | ||
+ | |- | ||
+ | | JMP || style="text-align: left;" | jump || || || || goto mem || || || || || goto (mem) | ||
+ | |- | ||
+ | | JSR || style="text-align: left;" | jump subroutine || || || || call mem || || || || || | ||
+ | |- | ||
+ | | LAS || style="text-align: left;" | || || || || || || || || || | ||
+ | |- | ||
+ | | LDA || style="text-align: left;" | load accumulator || || || a=imm || a=mem || a=mem,x || a=mem,y || a=(mem,x) || a=(mem),y || | ||
+ | |- | ||
+ | | LDX || style="text-align: left;" | load X || || || x=imm || x=mem || || x=mem,y || || || | ||
+ | |- | ||
+ | | LDY || style="text-align: left;" | load Y || || || y=imm || y=mem || y=mem,x || || || || | ||
+ | |- | ||
+ | | LSR || style="text-align: left;" | logical shift right || a>> || || || mem>> || mem,x>> || || || || | ||
+ | |- | ||
+ | | NOP || style="text-align: left;" | no operation || colspan="9" | * ''(for single NOP)'' ''or'' *''<number>'' ''(to wait <number> of cycles)'' | ||
+ | |- | ||
+ | | ORA || style="text-align: left;" | or with accumulator || || || a|imm || a|mem || a|mem,x || a|mem,y || a|(mem,x) || a|(mem),y || | ||
+ | |- | ||
+ | | PHA || style="text-align: left;" | push accumulator || || a!! || || || || || || || | ||
+ | |- | ||
+ | | PHP || style="text-align: left;" | push processor status (SR) || || flag!! || || || || || || || | ||
+ | |- | ||
+ | | PLA || style="text-align: left;" | pull accumulator || || a?? || || || || || || || | ||
+ | |- | ||
+ | | PLP || style="text-align: left;" | pull processor status (SR) || || flag?? || || || || || || || | ||
+ | |- | ||
+ | | ROL || style="text-align: left;" | rotate left || a<<< || || || mem<<< || mem,x<<< || || || || | ||
+ | |- | ||
+ | | ROR || style="text-align: left;" | rotate right || a>>> || || || mem>>> || mem,x>>> || || || || | ||
+ | |- | ||
+ | | RRA || style="text-align: left;" | || || || || || || || || || | ||
+ | |- | ||
+ | | RTI || style="text-align: left;" | return from interrupt || || ''TBD'' || || || || || || || | ||
+ | |- | ||
+ | | RTS || style="text-align: left;" | return from subroutine || || return || || || || || || || | ||
+ | |- | ||
+ | | SBC || style="text-align: left;" | subtract with carry || || || a-imm || a-mem || a-mem,x || a-mem,y || a-(mem,x) || a-(mem),y || | ||
+ | |- | ||
+ | | SEC || style="text-align: left;" | set carry || || c+ || || || || || || || | ||
+ | |- | ||
+ | | SED || style="text-align: left;" | set decimal || || d+ || || || || || || || | ||
+ | |- | ||
+ | | SEI || style="text-align: left;" | set interrupt disable || || i- || || || || || || || | ||
+ | |- | ||
+ | | STA || style="text-align: left;" | store accumulator || || || || mem=a || mem,x=a || mem,y=a || (mem,x)=a || (mem),y=a || | ||
+ | |- | ||
+ | | STX || style="text-align: left;" | store X || || || || mem=x || || || || || | ||
+ | |- | ||
+ | | STY || style="text-align: left;" | store Y || || || || mem=y || || || || || | ||
+ | |- | ||
+ | | TAX || style="text-align: left;" | transfer accumulator to X || || x=a || || || || || || || | ||
+ | |- | ||
+ | | TAY || style="text-align: left;" | transfer accumulator to Y || || y=a || || || || || || || | ||
+ | |- | ||
+ | | TSX || style="text-align: left;" | transfer stack pointer to X || || x=s || || || || || || || | ||
+ | |- | ||
+ | | TXA || style="text-align: left;" | transfer X to accumulator || || a=x || || || || || || || | ||
+ | |- | ||
+ | | TXS || style="text-align: left;" | transfer X to stack pointer || || s=x || || || || || || || | ||
+ | |- | ||
+ | | TYA || style="text-align: left;" | transfer Y to accumulator || || a=y || || || || || || || | ||
+ | |- | ||
+ | |} | ||
+ | {| class="wikitable" style="text-align: center;" | ||
+ | ! colspan="11" | Undocumented 6502 opcodes | ||
+ | |- | ||
+ | ! rowspan="2" | Opcode | ||
+ | ! rowspan="2" | Description | ||
+ | ! colspan="9" | K65 Syntax | ||
+ | |- | ||
+ | | width="7%" | Acc | ||
+ | | width="7%" | Implied | ||
+ | | width="7%" | Imm | ||
+ | | width="7%" | Mem | ||
+ | | width="7%" | Mem,X | ||
+ | | width="7%" | Mem,Y | ||
+ | | width="7%" | (Mem,X) | ||
+ | | width="7%" | (Mem),Y | ||
+ | | width="7%" | (Mem) | ||
+ | |- | ||
+ | | ANC || style="text-align: left;" | A <- A & imm, C <- bit 7 || || || a&.imm || || || || || || | ||
+ | |- | ||
+ | | ARR || style="text-align: left;" | A <- (A & imm) ror>>> || || || ''TBD'' || || || || || || | ||
+ | |- | ||
+ | | ASR || style="text-align: left;" | A <- (A & imm) >> 1 || || || ''TBD'' || || || || || || | ||
+ | |- | ||
+ | | AXS || style="text-align: left;" | X <- (A & X) - imm (no borrow) || || || x&=a-imm || || || || || || | ||
+ | |- | ||
+ | | DCP || style="text-align: left;" | decrement mem, then compare Acc to mem || || || || a?--mem || a?--mem,x || a?--mem,y || a?--(mem,x) || a?--(mem),y || | ||
+ | |- | ||
+ | | ISC || style="text-align: left;" | increment mem, then subtract mem from Acc (with borrow) || || || || a - ++mem || a - ++mem,x || a - ++mem,y || a - ++(mem,x) || a - ++(mem),y || | ||
+ | |- | ||
+ | | LAX || style="text-align: left;" | load to Acc and X || || || || a=x=mem || || a=x=mem,y || a=x=(mem,x) || a=x=(mem),y || | ||
+ | |- | ||
+ | | RLA || style="text-align: left;" | mem <- mem <<<, A <- A & mem || || || || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || | ||
+ | |- | ||
+ | | SAX || style="text-align: left;" | mem = A & X || || || || mem=a&x || || || (mem,x)=a&x || || | ||
+ | |- | ||
+ | | SLO || style="text-align: left;" | mem <- mem << 1, A <- A | mem || || || || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || | ||
+ | |- | ||
+ | | SRE || style="text-align: left;" | mem <- mem >> 1, A <- A ^ mem || || || || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || | ||
|- | |- | ||
− | |||
− | |||
− | |||
|} | |} |
Revision as of 11:24, 11 December 2014
Opcode | Description | K65 Syntax | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Acc | Implied | Imm | Mem | Mem,X | Mem,Y | (Mem,X) | (Mem),Y | (Mem) | ||
ADC | add with carry | a+imm | a+mem | a+mem,x | a+mem,y | a+(mem,x) | a+(mem),y | |||
AND | and (with accumulator) | a&imm | a&mem | a&mem,x | a&mem,y | a&(mem,x) | a&(mem),y | |||
ASL | arithmetic shift left | a<< | mem<< | mem,x<< | ||||||
BCC | branch on carry clear | >={ ... } or < goto label or { ... } < or c+{ ... } or c- goto label or { ... } c- | ||||||||
BCS | branch on carry set | <{ ... } or >= goto label or { ... } >= or c-{ ... } or c+ goto label or { ... } c+ | ||||||||
BEQ | branch on equal (zero set) | { ... } or == goto label or { ... } == | ||||||||
BIT | bit test | a?mem | ||||||||
BMI | branch on minus (negative set) | >=0{ ... } or <0 goto label or { ... } <0 | ||||||||
BNE | branch on not equal (zero clear) | =={ ... } or != goto label or { ... } != | ||||||||
BPL | branch on plus (negative clear) | <0{ ... } or >=0 goto label or { ... } >=0 | ||||||||
BRK | interrupt | TBD | ||||||||
BVC | branch on overflow clear | <<={ ... } or >>= goto label or { ... } >>= or o+{ ... } or o- goto label or { ... } o- | ||||||||
BVS | branch on overflow set | >>={ ... } or <<= goto label or { ... } <<= or o-{ ... } or o+ goto label or { ... } o+ | ||||||||
CLC | clear carry | c- | ||||||||
CLD | clear decimal | d- | ||||||||
CLI | clear interrupt disable | i- | ||||||||
CLV | clear overflow | o- | ||||||||
CMP | compare (with accumulator) | a?imm | a?mem | a?mem,x | a?mem,y | a?(mem,x) | a?(mem),y | |||
CPX | compare with X | x?imm | x?mem | |||||||
CPY | compare with Y | y?imm | y?mem | |||||||
DEC | decrement | mem-- | mem,x-- | |||||||
DEX | decrement X | x-- | ||||||||
DEY | decrement Y | y-- | ||||||||
EOR | exclusive or (with accumulator) | a^imm | a^mem | a^mem,x | a^mem,y | a^(mem,x) | a^(mem),y | |||
INC | increment | mem++ | mem,x++ | |||||||
INX | increment X | x++ | ||||||||
INY | increment Y | y++ | ||||||||
JMP | jump | goto mem | goto (mem) | |||||||
JSR | jump subroutine | call mem | ||||||||
LAS | ||||||||||
LDA | load accumulator | a=imm | a=mem | a=mem,x | a=mem,y | a=(mem,x) | a=(mem),y | |||
LDX | load X | x=imm | x=mem | x=mem,y | ||||||
LDY | load Y | y=imm | y=mem | y=mem,x | ||||||
LSR | logical shift right | a>> | mem>> | mem,x>> | ||||||
NOP | no operation | * (for single NOP) or *<number> (to wait <number> of cycles) | ||||||||
ORA | or with accumulator | imm | mem | mem,x | mem,y | (mem,x) | (mem),y | |||
PHA | push accumulator | a!! | ||||||||
PHP | push processor status (SR) | flag!! | ||||||||
PLA | pull accumulator | a?? | ||||||||
PLP | pull processor status (SR) | flag?? | ||||||||
ROL | rotate left | a<<< | mem<<< | mem,x<<< | ||||||
ROR | rotate right | a>>> | mem>>> | mem,x>>> | ||||||
RRA | ||||||||||
RTI | return from interrupt | TBD | ||||||||
RTS | return from subroutine | return | ||||||||
SBC | subtract with carry | a-imm | a-mem | a-mem,x | a-mem,y | a-(mem,x) | a-(mem),y | |||
SEC | set carry | c+ | ||||||||
SED | set decimal | d+ | ||||||||
SEI | set interrupt disable | i- | ||||||||
STA | store accumulator | mem=a | mem,x=a | mem,y=a | (mem,x)=a | (mem),y=a | ||||
STX | store X | mem=x | ||||||||
STY | store Y | mem=y | ||||||||
TAX | transfer accumulator to X | x=a | ||||||||
TAY | transfer accumulator to Y | y=a | ||||||||
TSX | transfer stack pointer to X | x=s | ||||||||
TXA | transfer X to accumulator | a=x | ||||||||
TXS | transfer X to stack pointer | s=x | ||||||||
TYA | transfer Y to accumulator | a=y |
Undocumented 6502 opcodes | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Opcode | Description | K65 Syntax | ||||||||
Acc | Implied | Imm | Mem | Mem,X | Mem,Y | (Mem,X) | (Mem),Y | (Mem) | ||
ANC | A <- A & imm, C <- bit 7 | a&.imm | ||||||||
ARR | A <- (A & imm) ror>>> | TBD | ||||||||
ASR | A <- (A & imm) >> 1 | TBD | ||||||||
AXS | X <- (A & X) - imm (no borrow) | x&=a-imm | ||||||||
DCP | decrement mem, then compare Acc to mem | a?--mem | a?--mem,x | a?--mem,y | a?--(mem,x) | a?--(mem),y | ||||
ISC | increment mem, then subtract mem from Acc (with borrow) | a - ++mem | a - ++mem,x | a - ++mem,y | a - ++(mem,x) | a - ++(mem),y | ||||
LAX | load to Acc and X | a=x=mem | a=x=mem,y | a=x=(mem,x) | a=x=(mem),y | |||||
RLA | mem <- mem <<<, A <- A & mem | TBD | TBD | TBD | TBD | TBD | ||||
SAX | mem = A & X | mem=a&x | (mem,x)=a&x | |||||||
SLO | mem <- mem << 1, A <- A | mem | TBD | TBD | TBD | TBD | TBD | ||||
SRE | mem <- mem >> 1, A <- A ^ mem | TBD | TBD | TBD | TBD | TBD |