* readOpcode - Reads the opcode (excepting the ModR/M byte in the case of * extended or escape opcodes). * * @param insn - The instruction whose opcode is to be read. * @return - 0 if the opcode could be read successfully; nonzero otherwise. */
| 763 | * @return - 0 if the opcode could be read successfully; nonzero otherwise. |
| 764 | */ |
| 765 | static int readOpcode(struct InternalInstruction* insn) |
| 766 | { |
| 767 | uint8_t current; |
| 768 | |
| 769 | // dbgprintf(insn, "readOpcode()"); |
| 770 | |
| 771 | insn->opcodeType = ONEBYTE; |
| 772 | |
| 773 | if (insn->vectorExtensionType == TYPE_EVEX) { |
| 774 | switch (mmFromEVEX2of4(insn->vectorExtensionPrefix[1])) { |
| 775 | default: |
| 776 | // dbgprintf(insn, "Unhandled mm field for instruction (0x%hhx)", |
| 777 | // mmFromEVEX2of4(insn->vectorExtensionPrefix[1])); |
| 778 | return -1; |
| 779 | case VEX_LOB_0F: |
| 780 | insn->opcodeType = TWOBYTE; |
| 781 | return consumeByte(insn, &insn->opcode); |
| 782 | case VEX_LOB_0F38: |
| 783 | insn->opcodeType = THREEBYTE_38; |
| 784 | return consumeByte(insn, &insn->opcode); |
| 785 | case VEX_LOB_0F3A: |
| 786 | insn->opcodeType = THREEBYTE_3A; |
| 787 | return consumeByte(insn, &insn->opcode); |
| 788 | } |
| 789 | } else if (insn->vectorExtensionType == TYPE_VEX_3B) { |
| 790 | switch (mmmmmFromVEX2of3(insn->vectorExtensionPrefix[1])) { |
| 791 | default: |
| 792 | // dbgprintf(insn, "Unhandled m-mmmm field for instruction (0x%hhx)", |
| 793 | // mmmmmFromVEX2of3(insn->vectorExtensionPrefix[1])); |
| 794 | return -1; |
| 795 | case VEX_LOB_0F: |
| 796 | //insn->twoByteEscape = 0x0f; |
| 797 | insn->opcodeType = TWOBYTE; |
| 798 | return consumeByte(insn, &insn->opcode); |
| 799 | case VEX_LOB_0F38: |
| 800 | //insn->twoByteEscape = 0x0f; |
| 801 | insn->opcodeType = THREEBYTE_38; |
| 802 | return consumeByte(insn, &insn->opcode); |
| 803 | case VEX_LOB_0F3A: |
| 804 | //insn->twoByteEscape = 0x0f; |
| 805 | insn->opcodeType = THREEBYTE_3A; |
| 806 | return consumeByte(insn, &insn->opcode); |
| 807 | } |
| 808 | } else if (insn->vectorExtensionType == TYPE_VEX_2B) { |
| 809 | //insn->twoByteEscape = 0x0f; |
| 810 | insn->opcodeType = TWOBYTE; |
| 811 | return consumeByte(insn, &insn->opcode); |
| 812 | } else if (insn->vectorExtensionType == TYPE_XOP) { |
| 813 | switch (mmmmmFromXOP2of3(insn->vectorExtensionPrefix[1])) { |
| 814 | default: |
| 815 | // dbgprintf(insn, "Unhandled m-mmmm field for instruction (0x%hhx)", |
| 816 | // mmmmmFromVEX2of3(insn->vectorExtensionPrefix[1])); |
| 817 | return -1; |
| 818 | case XOP_MAP_SELECT_8: |
| 819 | insn->opcodeType = XOP8_MAP; |
| 820 | return consumeByte(insn, &insn->opcode); |
| 821 | case XOP_MAP_SELECT_9: |
| 822 | insn->opcodeType = XOP9_MAP; |
no test coverage detected
searching dependent graphs…