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.
 
 

31 lines
815 B

#include "insn.h"
#include "cpu.h"
#include "util.h"
#include <stddef.h>
#define TABLE_SIZE 0x34
static cpu_insn_handler primary_insn_handler[TABLE_SIZE] = {NULL};
static cpu_insn_handler secondary_insn_handler[TABLE_SIZE] = {NULL};
void insn_execute(cpu_t *cpu, uint32_t insn) {
const op_primary_t op = extract_primary_op(insn);
if (op == SPECIAL) {
const op_secondary_t op2 = extract_secondary_op(insn);
if (op2 > TABLE_SIZE || secondary_insn_handler[op2] == NULL) {
fatal("unsupported instruction: insn=%08x, op=%02x, op2=%02x", insn, op,
op2);
}
secondary_insn_handler[op2](cpu, insn);
}
if (op > TABLE_SIZE || primary_insn_handler[op] == NULL) {
fatal("unsupported instruction: insn=%08x, op=%02x", insn, op);
}
primary_insn_handler[op](cpu, insn);
}