The heart of the PSX is a slightly modified R3000A CPU from MIPS and LSI. This is a 32-bit Reduced Instruction Set Controller (RISC) processor that clocks at 33.8688 MHz. It has an operating performance of 30 million instructions per second. In addition, it has an internal instruction cache of 4 KB, a data cache of 1 KB and has a bus transfer rate of 132 MB/sec. It has internally one Arithmetic/Logic unit (ALU), One shifter, and totally lacks an FPU or floating point unit. The R3000A is configured for litle-endian byte order and defines a word as 32 bits, a half-word as 16 bits, and a byte as 8 bits.
The PSX has two coprocessors, cop0
, the System Control coprocessor, and cop2
, the GPU or Graphics Processing Unit. These are covered later on in this document.
The PSX's R3000A contains 4 KB of instruction cache. The instruction cache is organized with a line size of 16 bytes. This should achieve hit rate of around 80%. The cache is implemented using physical address and tags, as opposed to virtual ones.
The PSX's R3000A incorporates an on-chip data cache of 1 KB, organized as a line size of 4 bytes (one word). This also should achieve hit rates of 80% in most applications. This also is a directly mapped physical address cache. The data cache is implemented as a write through cache, to maintain that the main memory is the same as the internal cache. In order to minimize processor stalls due to data write operations, the bus interface unit uses a 4-deep write buffer which captures address and data at the processor execution rate, allowing it to be retired to main memory at a much slower rate without impacting system performance.
The R3000A uses thirty-two 32-bit registers, a 32-bit program counter, and two 32-bit registers for multiply/divide functions. The following table lists the registers by register number, name, and usage.
Register number | Name | Usage |
---|---|---|
R0 |
ZR | Constant Zero |
R1 |
AT | Reserved for the assembler |
R2 -R3 |
V0-V1 | Values for results and expression evaluation |
R4 -R7 |
A0-A3 | Arguments |
R8 -
|
T0-T7 | Temporaries (not preserved across call) |
R16 -R23 |
S0-S7 | Saved (preserved across call) |
R24 -R25 |
T8-T9 | More temporaries (not preserved across call) |
R26 -R27 |
K0-K1 | Reserved for OS Kernel |
R28 |
GP | Global Pointer |
R29 |
SP | Stack Pointer |
R30 |
FP | Frame Pointer |
R31 |
RA | Return address (set by function call) |
Name | Description |
---|---|
HI |
Multiplication 64-bit high result or division remainder |
LO |
Multiplication 64-bit low result or division quotient |
PC |
Program Counter |
Even though all general purpose registers have different names, they are all treated the same except for two. The R0
(ZR) register is hardwired as zero. The Second exception is R31
(RA) which is used at a link register when link or jump routines are called. These instructions are used in subroutine calls, and the subroutine return address is placed in register R31
. This register can be written to or read as a normal register in other operations.
The instruction encoding is based on the MIPS architecture. This means that there are three types of instruction encoding.
op |
rs |
rt |
immediate |
op |
target |
op |
rs |
rt |
rd |
shamt |
funct |
Where:
op |
is a 6-bit operation code |
rs |
is a five bit source register specifier |
rt |
is a 5-bit target register or branch condition |
immediate |
is a 16-bit immediate, or branch or address displacement |
target |
is a 26-bit jump target address |
rd |
is a 5-bit destination register specifier |
shamt |
is a 5-bit shift amount |
funct |
is a 6-bit function field |
The R3000A instruction set can be divided into the following basic groups:
R31
. These are typically used as subroutine calls, where the subroutine return address is stored into R31
during the call operation.cop0
) contains registers which are used in memory management and exception handling.The following table describes The assembly instructions for the R3000A. Please refer to the next section for more detail about opcode encoding.
Instruction | Format and Description |
---|---|
Load Byte |
LB Sign-extend 16-bit offset and add to contents of register base to form address. Sign-extend contents of addressed byte and load into |
Load Byte Unsigned |
LBU Sign-extend 16-bit offset and add to contents of register base to form address. Zero-extend contents of addressed byte and load into |
Load Halfword |
LH Sign-extend 16-bit offset and add to contents of register base to form address. Sign-extend contents of addressed byte and load into |
Load Halfword Unsigned |
LHU Sign-extend 16-bit offset and add to contents of register base to form address. Zero-extend contents of addressed byte and load into |
Load Word |
LW Sign-extend 16-bit offset and add to contents of register base to form address. Load contents of addressed word into register |
Load Word Left |
LWL Sign-extend 16-bit offset and add to contents of register base to form address. Shift addressed word left so that addressed byte is leftmost byte of a word. Merge bytes from memory with contents of register |
Load Word Right |
LWR Sign-extend 16-bit offset and add to contents of register base to form address. Shift addressed word right so that addressed byte is rightmost byte of a word. Merge bytes from memory with contents of register |
Store Byte |
SB Sign-extend 16-bit offset and add to contents of register base to form address. Store least significant byte of register |
Store Halfword |
SH Sign-extend 16-bit offset and add to contents of register base to form address. Store least significant halfword of register |
Store Word |
SW Sign-extend 16-bit offset and add to contents of register base to form address. Store least significant word of register |
Store Word Left |
SWL Sign-extend 16-bit offset and add to contents of register base to form address. Shift contents of register |
Store Word Right |
SWR Sign-extend 16-bit offset and add to contents of register base to form address. Shift contents of register |
Instruction | Format and Description |
---|---|
ADD Immediate |
ADDI Add 16-bit sign-extended immediate to register |
ADD Immediate Unsigned |
ADDIU Add 16-bit sign-extended immediate to register |
Set on Less Than Immediate |
SLTI Compare 16-bit sign-extended immediate with register Place result in register |
Set on Less Than Unsigned Immediate |
SLTIU Compare 16-bit sign-extended immediate with register |
AND Immediate |
ANDI Zero-extend 16-bit immediate, AND with contents of register |
OR Immediate |
ORI Zero-extend 16-bit immediate, OR with contents of register |
Exclusive OR Immediate |
XORI Zero-extend 16-bit immediate, exclusive OR with contents of register |
Load Upper Immediate |
LUI Shift 16-bit immediate left 16-bits. Set least significant 16-bits of word to zeroes. Store result in register |
Instruction | Format and Description |
---|---|
Add |
ADD Add contents of registers |
ADD Unsigned |
ADDU Add contents of registers |
Subtract |
SUB Subtract contents of registers |
Subtract Unsigned |
SUBU Subtract contents of registers |
Set on Less Than |
SLT Compare contents of register If register |
Set on Less Than Unsigned |
SLTU Compare contents of register |
AND |
AND Bit-wise AND contents of registers |
OR |
OR Bit-wise OR contents of registers |
Exclusive OR |
XOR Bit-wise Exclusive OR contents of registers |
NOR |
NOR Bit-wise NOR contents of registers |
Instruction | Format and Description |
---|---|
Shift Left Logical |
SLL Shift contents of register |
Shift Right Logical |
SRL Shift contents of register |
Shift Right Arithmetic |
SRA Shift contents of register |
Shift Left Logical Variable |
SLLV Shift contents of register |
Shift Right Logical Variable |
SRLV Shift contents of register |
Shift Right Arithmetic Variable |
SRAV Shift contents of register |
Instruction | Format and Description |
---|---|
Multiply |
MULT Multiply contents of registers |
Multiply Unsigned |
MULTU Multiply contents of registers |
Divide |
DIV Divide contents of register |
Divide Unsigned |
DIVU Divide contents of register |
Move From HI |
MF Move contents of special register |
Move From LO |
MF Move contents of special register |
Move To HI |
MT Move contents of special register |
Move To LO |
MT Move contents of register |
Instruction | Format and Description |
---|---|
Jump |
J target Shift 26-bit target address left two bits, combine with high-order 4-bits of PC and jump to address with a one instruction delay. |
Jump and Link |
JAL target Shift 26-bit target address left two bits, combine with high-order 4-bits of PC and jump to address with a one instruction delay. Place address of instruction following delay slot in |
Jump Register |
JR Jump to address contained in register |
Jump and Link Register |
JALR Jump to address contained in register |
Instruction | Format and Description |
---|---|
Branch on Equal |
BEQ Branch to target address if register |
Branch on Not Equal |
BNE Branch to target address if register |
Branch on Less than or Equal Zero |
BLEZ Branch to target address if register |
Branch on Greater Than Zero |
BGTZ Branch to target address if register |
Branch on Less Than Zero |
BLTZ Branch to target address if register |
Branch on Greater than or Equal Zero |
BGEZ Branch to target address if register |
Branch on Less Than Zero And Link |
BLTZAL Place address of instruction following delay slot in register R31 (link register). Branch to target address if register |
Branch on greater than or Equal Zero And Link |
BGEZAL Place address of instruction following delay slot in register R31 (link register). Branch to target address if register |
Instruction | Format and Description |
---|---|
System Call |
SYSCALL Initiates system call trap, immediately transferring control to exception handler. More information on the PSX SYSCALL routines are covered later on. |
Breakpoint |
BREAK Initiates breakpoint trap, immediately transferring control to exception handler. |
More information on the PSX SYSCALL routines is covered later on.
Instruction | Format and Description |
---|---|
Load Word to Co-processor |
LWCz Sign-extend 16-bit offset and add to base to form address. Load contents of addressed word into co-processor register |
Store Word from Co-processor |
SWCz Sign-extend 16-bit offset and add to base to form address. Store contents of co-processor register |
Move To Co-processor |
MTCz Move contents of CPU register |
Move from Co-processor |
MFCz Move contents of co-processor register |
Move Control To Co-processor |
CTCz Move contents of CPU register |
Move Control From Co-processor |
CFCz Move contents of control register |
Move Control To Co-processor |
COPz cofun Co-processor |
Instruction | Format and Description |
---|---|
Move To CP0 |
MTC0 Store contents of CPU register |
Move From CP0 |
MFC0 Load CPU register |
Read Indexed TLB Entry |
TLBR Load |
Write Indexed TLB Entry |
TLBWI Load TLB entry pointed at by Index register with contents of |
Write Random TLB Entry |
TLBWR Load TLB entry pointed at by Random register with contents of |
Probe TLB for Matching Entry |
TLBP Entry Load Index register with address of TLB entry whose contents match |
Restore From Exception |
RFE Restore previous interrupt mask and mode bits of status register into current status bits. Restore old status bits into previous status bits. |
The following shows the opcode encoding for the MIPS architecture.
Bits | 28...26 | |||||||
38-29 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | SPECIAL | BCOND | J | JAL | BEQ | BNE | BLEZ | BGTZ |
1 | ADDI | ADDIU | SLTI | SLTIU | ANDI | ORI | XORI | LUI |
2 | COP0 | COP1 | COP2 | COP3 | - | - | - | - |
3 | - | - | - | - | - | - | - | - |
4 | LB | LH | LWL | LW | LBU | LHU | LWR | - |
5 | SB | SH | SWL | SW | - | - | SWR | - |
6 | LWC0 | LWC1 | LWC2 | LWC3 | - | - | - | - |
7 | SWC0 | SWC1 | SWC2 | SWC3 | - | - | - | - |
Bits | 2-0 | |||||||
5-3 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | SLL | - | SRL | SRA | SLLV | - | SRLV | SRAV |
1 | JR | JALR | - | - | SYSCALL | BREAK | - | - |
2 | MFHI | MTHI | MFLO | MTLO | - | - | - | - |
3 | MULT | MULTU | DIV | DIVU | - | - | - | - |
4 | ADD | ADDU | SUB | SUBU | AND | OR | XOR | NOR |
5 | - | - | SLT | SLTU | - | - | - | - |
6 | - | - | - | - | - | - | - | - |
7 | - | - | - | - | - | - | - | - |
Bits | 8-16 | |||||||
20-19 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | BLTZ | BGEZ | ||||||
1 | ||||||||
2 | BLTZAL | BGEZAL |
Bits | 23-21 | |||||||
25-24 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | MF | CF | MT | CT | ||||
1 | BC | - | - | - | - | - | - | - |
Bits | 2-0 | |||||||
4-3 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
0 | TLBR | TLBWI | TLBWR | |||||
1 | TLBP | |||||||
2 | RFE | |||||||
3 |