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

  1. #include "insn.h"
  2. #include "cpu.h"
  3. #include "util.h"
  4. #include <stddef.h>
  5. #define TABLE_SIZE 0x34
  6. static cpu_insn_handler primary_insn_handler[TABLE_SIZE] = {NULL};
  7. static cpu_insn_handler secondary_insn_handler[TABLE_SIZE] = {NULL};
  8. void insn_execute(cpu_t *cpu, uint32_t insn) {
  9. const op_primary_t op = extract_primary_op(insn);
  10. if (op == SPECIAL) {
  11. const op_secondary_t op2 = extract_secondary_op(insn);
  12. if (op2 > TABLE_SIZE || secondary_insn_handler[op2] == NULL) {
  13. fatal("unsupported instruction: insn=%08x, op=%02x, op2=%02x", insn, op,
  14. op2);
  15. }
  16. secondary_insn_handler[op2](cpu, insn);
  17. }
  18. if (op > TABLE_SIZE || primary_insn_handler[op] == NULL) {
  19. fatal("unsupported instruction: insn=%08x, op=%02x", insn, op);
  20. }
  21. primary_insn_handler[op](cpu, insn);
  22. }