K65 Instructions
From KK's Wiki
K65 compiler supports following 6502 instructions.
TBD value means that instruction support is planned, but currently not implemented.
Standard 6502 instructions
| Standard 6502 opcodes | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 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 instructions
| 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 | |||||
| NOP | NOP with #immediate lasting 3 cycles | *<number> (with even <number> generates one NOP #imm and regular NOPs) | ||||||||
| 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 | ||||