opcode.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #include <stdint.h>
  2. #include "opcode.h"
  3. typedef struct
  4. {
  5. uint32_t andmask;
  6. uint32_t ormask;
  7. opcode_info info;
  8. } opcode;
  9. opcode rv32i[] =
  10. {
  11. { //lui
  12. 0x0000007f,0x00000037,
  13. },
  14. { //auipc
  15. 0x0000007f,0x00000017,
  16. },
  17. { //jal
  18. 0x0000007f,0x0000006f,
  19. },
  20. { //jalr
  21. 0x0000707f,0x00000067,
  22. },
  23. { //beq
  24. 0x0000707f,0x00000063,
  25. },
  26. { //bne
  27. 0x0000707f,0x00001063,
  28. },
  29. { //blt
  30. 0x0000707f,0x00004063,
  31. },
  32. { //bge
  33. 0x0000707f,0x00005063,
  34. },
  35. { //bltu
  36. 0x0000707f,0x00006063,
  37. },
  38. { //bgeu
  39. 0x0000707f,0x00007063,
  40. },
  41. { //lb
  42. 0x0000707f,0x00000003,
  43. },
  44. { //lh
  45. 0x0000707f,0x00001003,
  46. },
  47. { //lw
  48. 0x0000707f,0x00002003,
  49. },
  50. { //lbu
  51. 0x0000707f,0x00004003,
  52. },
  53. { //lhu
  54. 0x0000707f,0x00005003,
  55. },
  56. { //sb
  57. 0x0000707f,0x00000023,
  58. },
  59. { //sh
  60. 0x0000707f,0x00001023,
  61. },
  62. { //sw
  63. 0x0000707f,0x00002023,
  64. },
  65. { //addi
  66. 0x0000707f,0x00000013,
  67. },
  68. { //slti
  69. 0x0000707f,0x00002013,
  70. },
  71. { //sltiu
  72. 0x0000707f,0x00003013,
  73. },
  74. { //xori
  75. 0x0000707f,0x00004013,
  76. },
  77. { //ori
  78. 0x0000707f,0x00006013,
  79. },
  80. { //andi
  81. 0x0000707f,0x00007013,
  82. },
  83. { //slli
  84. 0xf800707f,0x00001013,
  85. },
  86. { //srli
  87. 0xf800707f,0x00005013,
  88. },
  89. { //srai
  90. 0xf800707f,0x40005013,
  91. },
  92. { //add
  93. 0xfe00707f,0x00000033,
  94. },
  95. { //sub
  96. 0xfe00707f,0x40000033,
  97. },
  98. { //sll
  99. 0xfe00707f,0x00001033,
  100. },
  101. { //slt
  102. 0xfe00707f,0x00002033,
  103. },
  104. { //sltu
  105. 0xfe00707f,0x00003033,
  106. },
  107. { //xor
  108. 0xfe00707f,0x00004033,
  109. },
  110. { //srl
  111. 0xfe00707f,0x00005033,
  112. },
  113. { //sra
  114. 0xfe00707f,0x40005033,
  115. },
  116. { //or
  117. 0xfe00707f,0x00006033,
  118. },
  119. { //and
  120. 0xfe00707f,0x00007033,
  121. },
  122. { //fence
  123. 0x0000707f,0x0000000F,
  124. },
  125. { //ecall
  126. 0xFFFFFFFF,0x00000073,
  127. },
  128. { //ebreak
  129. 0xFFFFFFFF,0x00100073,
  130. },
  131. };