psx emulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

116 lines
1.7 KiB

#ifndef PSXC_INSN_H_
#define PSXC_INSN_H_
#include "cpu.h"
#include <stdint.h>
typedef enum
{
SPECIAL = 0x00,
BCONDZ = 0x01,
J = 0x02,
JAL = 0x03,
BEQ = 0x04,
BNE = 0x05,
BLEZ = 0x06,
BGTZ = 0x07,
ADDI = 0x08,
ADDIU = 0x09,
SLTI = 0x0a,
SLTIU = 0x0b,
ANDI = 0x0c,
ORI = 0x0d,
XORI = 0x0e,
LUI = 0x0f,
COP0 = 0x10,
COP1 = 0x11,
COP2 = 0x12,
COP3 = 0x13,
LB = 0x20,
LH = 0x21,
LWL = 0x22,
LW = 0x23,
LBU = 0x24,
LHU = 0x25,
LWR = 0x26,
SB = 0x28,
SH = 0x29,
SWL = 0x2a,
SW = 0x2b,
SWR = 0x2e,
LWC0 = 0x30,
LWC1 = 0x31,
LWC2 = 0x32,
LWC3 = 0x33,
SWC0 = 0x38,
SWC1 = 0x39,
SWC2 = 0x3a,
SWC3 = 0x3b,
} op_primary_t;
typedef enum
{
SLL = 0x00,
SRL = 0x02,
SRA = 0x03,
SLLV = 0x04,
SRLV = 0x06,
SRAV = 0x07,
JR = 0x08,
JALR = 0x09,
SYSCALL = 0x0c,
BREAK = 0x0d,
MFHI = 0x10,
MTHI = 0x11,
MFLO = 0x12,
MTLO = 0x13,
MULT = 0x18,
MULTU = 0x19,
DIV = 0x1a,
DIVU = 0x1b,
ADD = 0x20,
ADDU = 0x21,
SUB = 0x22,
SUBU = 0x23,
AND = 0x24,
OR = 0x25,
XOR = 0x26,
NOR = 0x27,
SLT = 0x2a,
SLTU = 0x2b,
} op_secondary_t;
typedef union
{
struct __attribute__((packed))
{
uint8_t op : 6;
uint16_t rs : 5;
uint8_t rt : 5;
uint8_t rd : 5;
uint16_t imm5 : 5;
uint8_t tail : 6;
} insn_reg;
struct __attribute__((packed))
{
uint8_t op : 6;
uint32_t comment : 20;
uint8_t tail : 6;
} insn_call;
struct __attribute__((packed))
{
uint8_t op : 6;
uint16_t rs : 5;
uint8_t rt : 5;
uint16_t imm : 16;
} insn_imm;
} insn_t;
typedef void (*cpu_insn_handler)(cpu_t *, insn_t);
void insn_execute(cpu_t *cpu, uint32_t insn);
#endif