SPC-700 instruction set: Difference between revisions
From SNESdev Wiki
Jump to navigationJump to search
Rainwarrior (talk | contribs) (registers and addressing modes summary) |
Rainwarrior (talk | contribs) (→Instructions: group 1 instructions) |
||
Line 41: | Line 41: | ||
Official instruction names and syntax for SPC-700 instruction were provided by Sony. However, because of its architectural similarity to 6502, some prefer to rename and remap them using a 6502 style syntax. Both are provided here. | Official instruction names and syntax for SPC-700 instruction were provided by Sony. However, because of its architectural similarity to 6502, some prefer to rename and remap them using a 6502 style syntax. Both are provided here. | ||
Cycles in this table are 1.024 MHz CPU cycles. Each one is equal to 2 clocks of the 2.048 Mhz S-SMP. | |||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
Line 53: | Line 55: | ||
! Notes | ! Notes | ||
|- | |- | ||
| colspan= | | colspan=7 | 8-bit move to register | ||
|- | |||
| <tt>MOV A, #imm</tt> | |||
| <tt>LDA #imm</tt> | |||
| <tt>E8</tt> | |||
| 2 | |||
| 2 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, (X)</tt> | |||
| <tt>?</tt> | |||
| <tt>E6</tt> | |||
| 1 | |||
| 3 | |||
| <tt>N......Z</tt> | |||
| Loads from (P * $100) + X | |||
|- | |||
| <tt>MOV A, (X)+</tt> | |||
| <tt>?</tt> | |||
| <tt>BF</tt> | |||
| 1 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| X is incremented after the read | |||
|- | |||
| <tt>MOV A, dp</tt> | |||
| <tt>LDA zp</tt> | |||
| <tt>E4</tt> | |||
| 2 | |||
| 3 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, dp+X</tt> | |||
| <tt>LDA zp, X</tt> | |||
| <tt>F4</tt> | |||
| 2 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, !abs</tt> | |||
| <tt>LDA abs</tt> | |||
| <tt>E5</tt> | |||
| 3 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, !abs+X</tt> | |||
| <tt>LDA abs, X</tt> | |||
| <tt>F5</tt> | |||
| 3 | |||
| 5 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, !abs+Y</tt> | |||
| <tt>LDA abs, Y</tt> | |||
| <tt>F6</tt> | |||
| 3 | |||
| 5 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, [dp+X]</tt> | |||
| <tt>LDA (zp, X)</tt> | |||
| <tt>E7</tt> | |||
| 2 | |||
| 6 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV A, [dp]+Y</tt> | |||
| <tt>LDA (dp), Y</tt> | |||
| <tt>F7</tt> | |||
| 2 | |||
| 6 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV X, #imm</tt> | |||
| <tt>LDX #imm</tt> | |||
| <tt>CD</tt> | |||
| 2 | |||
| 2 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV X, dp</tt> | |||
| <tt>LDX zp</tt> | |||
| <tt>F8</tt> | |||
| 2 | |||
| 3 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV X, dp+Y</tt> | |||
| <tt>LDX zp, Y</tt> | |||
| <tt>F9</tt> | |||
| 2 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV X, !abs</tt> | |||
| <tt>LDX abs</tt> | |||
| <tt>E9</tt> | |||
| 3 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV Y, #imm</tt> | |||
| <tt>LDY #imm</tt> | |||
| <tt>8D</tt> | |||
| 2 | |||
| 2 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV Y, dp</tt> | |||
| <tt>LDY zp</tt> | |||
| <tt>EB</tt> | |||
| 2 | |||
| 3 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV Y, dp+X</tt> | |||
| <tt>LDY zp, X</tt> | |||
| <tt>FB</tt> | |||
| 2 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| <tt>MOV Y, !abs</tt> | |||
| <tt>LDY abs</tt> | |||
| <tt>EC</tt> | |||
| 3 | |||
| 4 | |||
| <tt>N......Z</tt> | |||
| | |||
|- | |||
| colspan=7 | 8-bit move to memory | |||
|- | |||
| colspan=7 | TODO | |||
|} | |} | ||
Revision as of 04:21, 7 October 2022
The Sony SPC-700 CPU is part of the S-SMP sound processor of the SNES. It runs at 2.048 MHz, and behaves similarly to a 6502 at 1.024 MHz with some extensions.
Architecture
The SPC-700 has a 16-bit address space, and a similar set of registers to the 6502.
Registers
- A - 8-bit accumulator
- X - 8-bit index
- Y - 8-bit index
- YA - 16-bit pair of A (lsb) and Y (msb).
- PC - program counter
- SP - stack pointer
- PSW - program status word: NVPBHIZC
- N - negative flag (high bit of result was set)
- V - overflow flag (signed overflow indication)
- P - direct page flag (moves the direct page to $0100 if set)
- H - half carry flag (carry between low and high nibble)
- I - interrupt disable (unused: the S-SMP has no attached interrupts)
- Z - zero flag (set if last result was zero)
- C - carry flag
Differences from the 6502:
- A 16-bit combined YA register is available for some operations.
- The direct page can be moved to $0100. (Rarely used.)
- A half carry flag that is useful for nibble operations.
- No decimal mode.
Addressing Modes
- imm - 8-bit immediate value
- dp - 8-bit direct page offset ($0000+dp or $01000+dp)
- !abs - 16-bit absolute address
- rel - relative offset in two's complement
- (addr) - indirect
- (addr)+i - indirect indexed (add index after lookup)
- [addr+i] - indexed indirect (add index before lookup)
Instructions
Official instruction names and syntax for SPC-700 instruction were provided by Sony. However, because of its architectural similarity to 6502, some prefer to rename and remap them using a 6502 style syntax. Both are provided here.
Cycles in this table are 1.024 MHz CPU cycles. Each one is equal to 2 clocks of the 2.048 Mhz S-SMP.
Instruction | 6502-Style | Opcode | Bytes | Cycles | Flags | Notes |
---|---|---|---|---|---|---|
8-bit move to register | ||||||
MOV A, #imm | LDA #imm | E8 | 2 | 2 | N......Z | |
MOV A, (X) | ? | E6 | 1 | 3 | N......Z | Loads from (P * $100) + X |
MOV A, (X)+ | ? | BF | 1 | 4 | N......Z | X is incremented after the read |
MOV A, dp | LDA zp | E4 | 2 | 3 | N......Z | |
MOV A, dp+X | LDA zp, X | F4 | 2 | 4 | N......Z | |
MOV A, !abs | LDA abs | E5 | 3 | 4 | N......Z | |
MOV A, !abs+X | LDA abs, X | F5 | 3 | 5 | N......Z | |
MOV A, !abs+Y | LDA abs, Y | F6 | 3 | 5 | N......Z | |
MOV A, [dp+X] | LDA (zp, X) | E7 | 2 | 6 | N......Z | |
MOV A, [dp]+Y | LDA (dp), Y | F7 | 2 | 6 | N......Z | |
MOV X, #imm | LDX #imm | CD | 2 | 2 | N......Z | |
MOV X, dp | LDX zp | F8 | 2 | 3 | N......Z | |
MOV X, dp+Y | LDX zp, Y | F9 | 2 | 4 | N......Z | |
MOV X, !abs | LDX abs | E9 | 3 | 4 | N......Z | |
MOV Y, #imm | LDY #imm | 8D | 2 | 2 | N......Z | |
MOV Y, dp | LDY zp | EB | 2 | 3 | N......Z | |
MOV Y, dp+X | LDY zp, X | FB | 2 | 4 | N......Z | |
MOV Y, !abs | LDY abs | EC | 3 | 4 | N......Z | |
8-bit move to memory | ||||||
TODO |
Links
- SPC700 Reference - CPU Instruction Set at superfamicom.org wiki