Advertisement
Guest User

Untitled

a guest
Oct 24th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. int GetType(unsigned int ins)
  2. {
  3. struct ins_format instruction;
  4. memset(&instruction, 0, 4);
  5. memcpy(&instruction, &ins, 4);
  6.  
  7. if(instruction.b26 == 0 && instruction.b27 == 0)
  8. {
  9. if(instruction.b25 == 1)
  10. {
  11. puts("Data processing, immediate value");
  12.  
  13. return INS_DATA_PROCESSING;
  14. }
  15. else if(instruction.b25 == 0)
  16. {
  17. if(instruction.b4 == 1 && instruction.b5 == 0 && instruction.b6 == 0 && instruction.b7 == 1)
  18. {
  19. if(instruction.b24 == 0)
  20. {
  21. // multiply
  22. if(instruction.b23 == 1)
  23. {
  24. puts("Long multiply");
  25.  
  26. return INS_MULTIPLY_LONG;
  27. }
  28. else
  29. {
  30. puts("Multiply");
  31.  
  32. return INS_MULTIPLY;
  33. }
  34. }
  35. else
  36. {
  37. puts("Swap");
  38.  
  39. return INS_SWAP;
  40. }
  41. }
  42. else
  43. {
  44. if(instruction.b22 == 0 && instruction.b7 == 1 && instruction.b4 == 1)
  45. {
  46. puts("Halfword Transfer Reg Off");
  47.  
  48. return INS_HALFWORD_XFER_REG;
  49. }
  50. else if(instruction.b22 == 1 && instruction.b7 == 1 && instruction.b4 == 1)
  51. {
  52. puts("Halfword Transfer Imm Off");
  53.  
  54. return INS_HALFWORD_XFER_IMM;
  55. }
  56. else
  57. {
  58. puts("Data processing, register");
  59.  
  60. return INS_DATA_PROCESSING;
  61. }
  62.  
  63. }
  64. }
  65.  
  66. if(instruction.b24 == 1)
  67. {
  68. if(instruction.b23 == 0 && instruction.b22 == 0 && instruction.b21 == 1 && instruction.b20 == 0)
  69. {
  70. puts("Branch exchange");
  71.  
  72. return INS_BRANCH_EXCHANGE;
  73. }
  74. }
  75.  
  76. return 0;
  77. }
  78. else if(instruction.b26 == 1 && instruction.b27 == 1)
  79. {
  80. if(instruction.b25 == 0)
  81. {
  82. puts("Coprocessor data transfer");
  83.  
  84. return INS_COPROCESSOR_DATA_XFER;
  85. }
  86. else
  87. {
  88. if(instruction.b4 == 0)
  89. {
  90. puts("Coprocessor data operation");
  91.  
  92. return INS_COPROCESSOR_DATA_OP;
  93. }
  94. else
  95. {
  96. puts("Coprocessor register transfer");
  97.  
  98. return INS_COPROCESSOR_REG_XFER;
  99. }
  100. }
  101.  
  102. if(instruction.b24 == 1 && instruction.b25 == 1)
  103. {
  104. puts("Software interrupt");
  105.  
  106. return INS_SOFTWARE_INTERRUPT;
  107. }
  108.  
  109. return 0;
  110.  
  111. }
  112. else if(instruction.b26 == 0 && instruction.b27 == 1)
  113. {
  114. if(instruction.b25 == 1)
  115. {
  116. puts("Branch");
  117.  
  118. return INS_BRANCH;
  119. }
  120. else
  121. {
  122. puts("Load/Store multiple");
  123.  
  124. return INS_STORELOAD_MULT;
  125. }
  126. }
  127. else if(instruction.b26 == 1 && instruction.b27 == 0)
  128. {
  129. if(instruction.b25 == 1)
  130. {
  131. puts("Load/Store immediate value");
  132.  
  133. return INS_STORELOAD_BYTEWORD;
  134. }
  135. else
  136. {
  137. puts("Load/Store register");
  138.  
  139. return INS_STORELOAD_BYTEWORD;
  140. }
  141. }
  142. else
  143. {
  144. puts("Unknown");
  145.  
  146. return INS_UNKNOWN;
  147. }
  148.  
  149. return INS_UNKNOWN;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement