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.

92 lines
1.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
  1. #ifndef PSXC_INSN_H_
  2. #define PSXC_INSN_H_
  3. #include "cpu.h"
  4. #include <stdint.h>
  5. typedef enum {
  6. SPECIAL = 0x00,
  7. BCONDZ = 0x01,
  8. J = 0x02,
  9. JAL = 0x03,
  10. BEQ = 0x04,
  11. BNE = 0x05,
  12. BLEZ = 0x06,
  13. BGTZ = 0x07,
  14. ADDI = 0x08,
  15. ADDIU = 0x09,
  16. SLTI = 0x0a,
  17. SLTIU = 0x0b,
  18. ANDI = 0x0c,
  19. ORI = 0x0d,
  20. XORI = 0x0e,
  21. LUI = 0x0f,
  22. COP0 = 0x10,
  23. COP1 = 0x11,
  24. COP2 = 0x12,
  25. COP3 = 0x13,
  26. LB = 0x20,
  27. LH = 0x21,
  28. LWL = 0x22,
  29. LW = 0x23,
  30. LBU = 0x24,
  31. LHU = 0x25,
  32. LWR = 0x26,
  33. SB = 0x28,
  34. SH = 0x29,
  35. SWL = 0x2a,
  36. SW = 0x2b,
  37. SWR = 0x2e,
  38. LWC0 = 0x30,
  39. LWC1 = 0x31,
  40. LWC2 = 0x32,
  41. LWC3 = 0x33,
  42. SWC0 = 0x38,
  43. SWC1 = 0x39,
  44. SWC2 = 0x3a,
  45. SWC3 = 0x3b,
  46. } op_primary_t;
  47. static inline op_primary_t extract_primary_op(uint32_t insn) {
  48. return (insn >> 26) & 0x3f;
  49. }
  50. typedef enum {
  51. SLL = 0x00,
  52. SRL = 0x02,
  53. SRA = 0x03,
  54. SLLV = 0x04,
  55. SRLV = 0x06,
  56. SRAV = 0x07,
  57. JR = 0x08,
  58. JALR = 0x09,
  59. SYSCALL = 0x0c,
  60. BREAK = 0x0d,
  61. MFHI = 0x10,
  62. MTHI = 0x11,
  63. MFLO = 0x12,
  64. MTLO = 0x13,
  65. MULT = 0x18,
  66. MULTU = 0x19,
  67. DIV = 0x1a,
  68. DIVU = 0x1b,
  69. ADD = 0x20,
  70. ADDU = 0x21,
  71. SUB = 0x22,
  72. SUBU = 0x23,
  73. AND = 0x24,
  74. OR = 0x25,
  75. XOR = 0x26,
  76. NOR = 0x27,
  77. SLT = 0x2a,
  78. SLTU = 0x2b,
  79. } op_secondary_t;
  80. static inline op_secondary_t extract_secondary_op(uint32_t insn) {
  81. return (insn >> 0) & 0x3f;
  82. }
  83. void insn_execute(cpu_t *cpu, uint32_t insn);
  84. #endif