SPC-700 instruction set: Difference between revisions

From SNESdev Wiki
Jump to navigationJump to search
m (→‎Instructions: fix N.....Z. column)
Line 65: Line 65:
| 2
| 2
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 73: Line 73:
| 1
| 1
| 3
| 3
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 81: Line 81:
| 1
| 1
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
| X++ after read
| X++ after read
|-
|-
Line 89: Line 89:
| 2
| 2
| 3
| 3
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 97: Line 97:
| 2
| 2
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 105: Line 105:
| 3
| 3
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 113: Line 113:
| 3
| 3
| 5
| 5
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 121: Line 121:
| 3
| 3
| 5
| 5
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 129: Line 129:
| 2
| 2
| 6
| 6
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 137: Line 137:
| 2
| 2
| 6
| 6
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 145: Line 145:
| 2
| 2
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 153: Line 153:
| 2
| 2
| 3
| 3
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 161: Line 161:
| 2
| 2
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 169: Line 169:
| 3
| 3
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|


Line 178: Line 178:
| 2
| 2
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 186: Line 186:
| 2
| 2
| 3
| 3
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 194: Line 194:
| 2
| 2
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 202: Line 202:
| 3
| 3
| 4
| 4
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 334: Line 334:
| 1
| 1
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 342: Line 342:
| 1
| 1
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 350: Line 350:
| 1
| 1
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 358: Line 358:
| 1
| 1
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-
Line 366: Line 366:
| 1
| 1
| 2
| 2
| <tt>N......Z</tt>
| <tt>N.....Z.</tt>
|
|
|-
|-

Revision as of 05:03, 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, can be cleared by CLRV.
  • 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
  • (i) - direct-page relative index (P * $100 + i)
  • (i)+ - direct-page relative index with post-increment (i is incremented after read)
  • [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.

Sony instruction convention puts the destination on the left, source on the right (Intel syntax).

Cycles in this table are 1.024 MHz CPU cycles. Each one is equal to 2 clocks of the 2.048 Mhz S-SMP.

SPC-700 Instruction Set
Instruction 6502-Style Opcode Bytes Cycles Flags Notes
. 8-bit move memory to register
MOV A, #imm LDA #imm E8 2 2 N.....Z.
MOV A, (X) ? E6 1 3 N.....Z.
MOV A, (X)+ ? BF 1 4 N.....Z. X++ after 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 register to memory
MOV (X), A ? C6 1 4 ........
MOV (X)+, A ? AF 1 4 ........ X++ after read
MOV dp, A STA zp C4 2 4 ........
MOV dp+X, A STA zp, X D4 2 5 ........
MOV !abs, A STA abs C5 3 5 ........
MOV !abs+X, A STA abs, X D5 3 6 ........
MOV !abs+Y, A STA abs, Y D6 3 6 ........
MOV [dp+X], A STA (zp, X) C7 2 7 ........
MOV [dp]+Y, A STA (zp), Y D7 2 7 ........
MOV dp, X STX zp D8 2 4 ........
MOV dp+Y, X STX zp, Y D9 2 5 ........
MOV !abs, X STX abs C9 3 5 ........
MOV dp, Y STY zp CB 2 4 ........
MOV dp+X, Y STY zp, X DB 2 5 ........
MOV !abs, Y STY abs CC 3 5 ........
. 8-bit move register to register / special direct page moves
MOV A, X TXA 7D 1 2 N.....Z.
MOV A, Y TYA DD 1 2 N.....Z.
MOV X, A TAX 5D 1 2 N.....Z.
MOV Y, A TAY FD 1 2 N.....Z.
MOV X, SP TSX 9D 1 2 N.....Z.
MOV SP, X TXS BD 1 2 ........
MOV dp, dp ? FA 3 5 ........
MOV dp, #imm ? 8F 3 5 ........
. 8-bit arithmetic
ADC A, #imm ADC #imm 88 2 2 NV..H.ZC
ADC A, (X) ? 86 1 3 NV..H.ZC
ADC A, dp ADC zp 84 2 3 NV..H.ZC
ADC A, dp+X ADC zp, X 94 2 4 NV..H.ZC
ADC A, !abs ADC abs 85 3 4 NV..H.ZC
ADC A, !abs+X ADC abs, X 95 3 5 NV..H.ZC
ADC A, !abs+Y ADC abs, Y 96 3 5 NV..H.ZC
ADC A, [dp+X] ADC (zp, X) 87 2 6 NV..H.ZC
ADC A, [dp]+Y ADC (dp), Y 97 2 6 NV..H.ZC
ADC (X), (Y) ? 99 1 5 NV..H.ZC
ADC dp, dp ? 89 3 6 NV..H.ZC
ADC dp, #imm ? 98 3 5 NV..H.ZC
TODO

Links