Difference between revisions of "K65 Instructions"

From KK's Wiki
Jump to: navigation, search
(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
! K65 Syntax
+
! rowspan="2" | Description
! Description
+
! colspan="9" | K65 Syntax
 
|-
 
|-
|ADC
+
| width="7%" | Acc
|a+#
+
| width="7%" | Implied
|add with carry
+
| 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)
 
|-
 
|-
|AND
+
| ADC || style="text-align: left;" | &nbsp;add with carry || || || a+imm || a+mem || a+mem,x || a+mem,y || a+(mem,x) || a+(mem),y ||
|a&#
+
|and (with accumulator)
+
 
|-
 
|-
|ASL
+
| AND || style="text-align: left;" | &nbsp;and (with accumulator) || || || a&imm || a&mem || a&mem,x || a&mem,y || a&(mem,x) || a&(mem),y ||
|#<<
+
|arithmetic shift left
+
 
|-
 
|-
BCC .... branch on carry clear >={...}
+
| ASL || style="text-align: left;" | &nbsp;arithmetic shift left || a<< || || || mem<< || mem,x<< || || || ||
 
|-
 
|-
|BCS .... branch on carry set <{...}
+
| BCC || style="text-align: left;" | &nbsp;branch on carry clear || colspan="9" | >={ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; < goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } < &nbsp;&nbsp;''or''&nbsp;&nbsp; c+{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; c- goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } c-
 
|-
 
|-
|BEQ .... branch on equal (zero set) =={...}
+
| BCS || style="text-align: left;" | &nbsp;branch on carry set || colspan="9" | <{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; >= goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } >= &nbsp;&nbsp;''or''&nbsp;&nbsp; c-{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; c+ goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } c+
 
|-
 
|-
|BIT .... bit test a?#
+
| BEQ || style="text-align: left;" | &nbsp;branch on equal (zero set) || colspan="9" | { ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; == goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } ==
 
|-
 
|-
|BMI .... branch on minus (negative set) <0{...}
+
| BIT || style="text-align: left;" | &nbsp;bit test || || || || a?mem || || || || ||
 
|-
 
|-
|BNE .... branch on not equal (zero clear) !={...}
+
| BMI || style="text-align: left;" | &nbsp;branch on minus (negative set) || colspan="9" | >=0{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; <0 goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } <0
 
|-
 
|-
|BPL .... branch on plus (negative clear) >=0{...}
+
| BNE || style="text-align: left;" | &nbsp;branch on not equal (zero clear) || colspan="9" | =={ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; != goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } !=
 
|-
 
|-
|BRK .... interrupt brk
+
| BPL || style="text-align: left;" | &nbsp;branch on plus (negative clear) || colspan="9" | <0{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; >=0 goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } >=0
 
|-
 
|-
|BVC .... branch on overflow clear >>={...}
+
| BRK || style="text-align: left;" | &nbsp;interrupt || || ''TBD'' || || || || || || ||
 
|-
 
|-
|BVS .... branch on overflow set <<={...}
+
| BVC || style="text-align: left;" | &nbsp;branch on overflow clear || colspan="9" | <<={ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; >>= goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } >>= &nbsp;&nbsp;''or''&nbsp;&nbsp; o+{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; o- goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } o-
 
|-
 
|-
|CLC .... clear carry c-
+
| BVS || style="text-align: left;" | &nbsp;branch on overflow set || colspan="9" | >>={ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; <<= goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } <<= &nbsp;&nbsp;''or''&nbsp;&nbsp; o-{ ... } &nbsp;&nbsp;''or''&nbsp;&nbsp; o+ goto label &nbsp;&nbsp;''or''&nbsp;&nbsp; { ... } o+
 
|-
 
|-
|CLD .... clear decimal d-
+
| CLC || style="text-align: left;" | &nbsp;clear carry || || c- || || || || || || ||
 
|-
 
|-
|CLI .... clear interrupt disable i-
+
| CLD || style="text-align: left;" | &nbsp;clear decimal || || d- || || || || || || ||
 
|-
 
|-
|CLV .... clear overflow o-
+
| CLI || style="text-align: left;" | &nbsp;clear interrupt disable || || i- || || || || || || ||
CMP .... compare (with accumulator) a?#
+
CPX .... compare with X a?x
+
CPY .... compare with Y a?y
+
DEC .... decrement #--
+
DEX .... decrement X x--
+
DEY .... decrement Y y--
+
EOR .... exclusive or (with accumulator) a^#
+
INC .... increment #++
+
INX .... increment X x++
+
INY .... increment Y y++
+
JMP .... jump goto ##
+
JSR .... jump subroutine goto (##)
+
LDA .... load accumulator a=#
+
LDX .... load X x=#
+
LDY .... load Y y=#
+
LSR .... logical shift right #>>
+
NOP .... no operation nop
+
ORA .... or with accumulator a|#
+
PHA .... push accumulator a!
+
PHP .... push processor status (SR) sr!
+
PLA .... pull accumulator a?
+
PLP .... pull processor status (SR) sr?
+
ROL .... rotate left #<<<
+
ROR .... rotate right #>>>
+
RTI .... return from interrupt rti
+
RTS .... return from subroutine ret rts
+
SBC .... subtract with carry a-#
+
SEC .... set carry c+
+
SED .... set decimal d+
+
SEI .... set interrupt disable i-
+
STA .... store accumulator #=a
+
STX .... store X #=x
+
STY .... store Y #=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
+
 
+
 
|-
 
|-
|Orange
+
| CLV || style="text-align: left;" | &nbsp;clear overflow || || o- || || || || || || ||
|10
+
|7.00
+
 
|-
 
|-
|Bread
+
| CMP || style="text-align: left;" | &nbsp;compare (with accumulator) || || || a?imm || a?mem || a?mem,x || a?mem,y || a?(mem,x) || a?(mem),y ||
|4
+
|3.00
+
 
|-
 
|-
|Butter
+
| CPX || style="text-align: left;" | &nbsp;compare with X || || || x?imm || x?mem || || || || ||
|1
+
|-
|5.00
+
| CPY || style="text-align: left;" | &nbsp;compare with Y || || || y?imm || y?mem || || || || ||
 +
|-
 +
| DEC || style="text-align: left;" | &nbsp;decrement || || || || mem-- || mem,x-- || || || ||
 +
|-
 +
| DEX || style="text-align: left;" | &nbsp;decrement X || || x-- || || || || || || ||
 +
|-
 +
| DEY || style="text-align: left;" | &nbsp;decrement Y || || y-- || || || || || || ||
 +
|-
 +
| EOR || style="text-align: left;" | &nbsp;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;" | &nbsp;increment || || || || mem++ || mem,x++ || || || ||
 +
|-
 +
| INX || style="text-align: left;" | &nbsp;increment X || || x++ || || || || || || ||
 +
|-
 +
| INY || style="text-align: left;" | &nbsp;increment Y || || y++ || || || || || || ||
 +
|-
 +
| JMP || style="text-align: left;" | &nbsp;jump || || || || goto mem || || || || || goto (mem)
 +
|-
 +
| JSR || style="text-align: left;" | &nbsp;jump subroutine || || || || call mem || || || || ||
 +
|-
 +
| LAS || style="text-align: left;" | &nbsp; || || || || || ||  || || ||
 +
|-
 +
| LDA || style="text-align: left;" | &nbsp;load accumulator || || || a=imm || a=mem || a=mem,x || a=mem,y || a=(mem,x) || a=(mem),y ||
 +
|-
 +
| LDX || style="text-align: left;" | &nbsp;load X || || || x=imm || x=mem || || x=mem,y || || ||
 +
|-
 +
| LDY || style="text-align: left;" | &nbsp;load Y || || || y=imm || y=mem || y=mem,x || || || ||
 +
|-
 +
| LSR || style="text-align: left;" | &nbsp;logical shift right || a>> || || || mem>> || mem,x>> || || || ||
 +
|-
 +
| NOP || style="text-align: left;" | &nbsp;no operation || colspan="9" | * ''(for single NOP)'' &nbsp;&nbsp;''or''&nbsp;&nbsp; *''<number>'' ''(to wait <number> of cycles)''
 +
|-
 +
| ORA || style="text-align: left;" | &nbsp;or with accumulator || || || a|imm || a|mem || a|mem,x || a|mem,y || a|(mem,x) || a|(mem),y ||
 +
|-
 +
| PHA || style="text-align: left;" | &nbsp;push accumulator || || a!! || || || || || || ||
 +
|-
 +
| PHP || style="text-align: left;" | &nbsp;push processor status (SR) || || flag!! || || || || || || ||
 +
|-
 +
| PLA || style="text-align: left;" | &nbsp;pull accumulator || || a?? || || || || || || ||
 +
|-
 +
| PLP || style="text-align: left;" | &nbsp;pull processor status (SR) || || flag?? || || || || || || ||
 +
|-
 +
| ROL || style="text-align: left;" | &nbsp;rotate left || a<<< || || || mem<<< || mem,x<<< || || || ||
 +
|-
 +
| ROR || style="text-align: left;" | &nbsp;rotate right || a>>> || || || mem>>> || mem,x>>> || || || ||
 +
|-
 +
| RRA || style="text-align: left;" | &nbsp; || || || ||  ||  ||  ||  ||  ||
 +
|-
 +
| RTI || style="text-align: left;" | &nbsp;return from interrupt || || ''TBD'' || || || || || || ||
 +
|-
 +
| RTS || style="text-align: left;" | &nbsp;return from subroutine || || return || || || || || || ||
 +
|-
 +
| SBC || style="text-align: left;" | &nbsp;subtract with carry || || || a-imm || a-mem || a-mem,x || a-mem,y || a-(mem,x) || a-(mem),y ||
 +
|-
 +
| SEC || style="text-align: left;" | &nbsp;set carry || || c+ || || || || || || ||
 +
|-
 +
| SED || style="text-align: left;" | &nbsp;set decimal || || d+ || || || || || || ||
 +
|-
 +
| SEI || style="text-align: left;" | &nbsp;set interrupt disable || || i- || || || || || || ||
 +
|-
 +
| STA || style="text-align: left;" | &nbsp;store accumulator || || || || mem=a || mem,x=a || mem,y=a || (mem,x)=a || (mem),y=a ||
 +
|-
 +
| STX || style="text-align: left;" | &nbsp;store X || || || || mem=x || || || || ||
 +
|-
 +
| STY || style="text-align: left;" | &nbsp;store Y || || || || mem=y || || || || ||
 +
|-
 +
| TAX || style="text-align: left;" | &nbsp;transfer accumulator to X || || x=a || || || || || || ||
 +
|-
 +
| TAY || style="text-align: left;" | &nbsp;transfer accumulator to Y || || y=a || || || || || || ||
 +
|-
 +
| TSX || style="text-align: left;" | &nbsp;transfer stack pointer to X || || x=s || || || || || || ||
 +
|-
 +
| TXA || style="text-align: left;" | &nbsp;transfer X to accumulator || || a=x || || || || || || ||
 +
|-
 +
| TXS || style="text-align: left;" | &nbsp;transfer X to stack pointer || || s=x || || || || || || ||
 +
|-
 +
| TYA || style="text-align: left;" | &nbsp;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;" | &nbsp;A <- A & imm, C <- bit 7 || || || a&.imm || || || || || ||
 +
|-
 +
| ARR || style="text-align: left;" | &nbsp;A <- (A & imm) ror>>> || || || ''TBD'' || || || || || ||
 +
|-
 +
| ASR || style="text-align: left;" | &nbsp;A <- (A & imm) >> 1 || || || ''TBD'' || || || || || ||
 +
|-
 +
| AXS || style="text-align: left;" | &nbsp;X <- (A & X) - imm &nbsp;&nbsp;(no borrow) || || || x&=a-imm || || || || || ||
 +
|-
 +
| DCP || style="text-align: left;" | &nbsp;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;" | &nbsp;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;" | &nbsp;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;" | &nbsp;mem <- mem <<<, A <- A & mem || || || || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' ||
 +
|-
 +
| SAX || style="text-align: left;" | &nbsp;mem = A & X || || || || mem=a&x || || || (mem,x)=a&x || ||
 +
|-
 +
| SLO || style="text-align: left;" | &nbsp;mem <- mem << 1, A <- A | mem || || || || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' ||
 +
|-
 +
| SRE || style="text-align: left;" | &nbsp;mem <- mem >> 1, A <- A ^ mem || || || || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' || ''TBD'' ||
 
|-
 
|-
|Total
 
|
 
|15.00
 
 
|}
 
|}

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