| 768 | } |
| 769 | |
| 770 | virtual bool GetInstructionText(const uint8_t* data, uint64_t addr, size_t& len, vector<InstructionTextToken>& result) override |
| 771 | { |
| 772 | Instruction instr; |
| 773 | char operand[64]; |
| 774 | char padding[9]; |
| 775 | const char* reg = NULL; |
| 776 | if (!Disassemble(data, addr, len, instr)) |
| 777 | return false; |
| 778 | |
| 779 | len = instr.size; |
| 780 | memset(padding, 0x20, sizeof(padding)); |
| 781 | const char* operation = get_operation(instr.operation); |
| 782 | if (operation == NULL) |
| 783 | return false; |
| 784 | |
| 785 | size_t operationLen = strlen(operation); |
| 786 | if (operationLen < 8) |
| 787 | { |
| 788 | padding[8-operationLen] = '\0'; |
| 789 | } |
| 790 | else |
| 791 | padding[1] = '\0'; |
| 792 | |
| 793 | result.emplace_back(InstructionToken, operation); |
| 794 | result.emplace_back(TextToken, padding); |
| 795 | for (size_t i = 0; i < MAX_OPERANDS; i++) |
| 796 | { |
| 797 | if (instr.operands[i].operandClass == NONE) |
| 798 | return true; |
| 799 | |
| 800 | int32_t imm = instr.operands[i].immediate; |
| 801 | uint64_t label_imm = instr.operands[i].immediate; |
| 802 | |
| 803 | if (i != 0) |
| 804 | result.emplace_back(OperandSeparatorToken, ", "); |
| 805 | |
| 806 | switch (instr.operands[i].operandClass) |
| 807 | { |
| 808 | case IMM: |
| 809 | if (imm < -9) |
| 810 | snprintf(operand, sizeof(operand), "-%#x", -imm); |
| 811 | else if (imm < 0) |
| 812 | snprintf(operand, sizeof(operand), "-%d", -imm); |
| 813 | else if (imm < 10) |
| 814 | snprintf(operand, sizeof(operand), "%d", imm); |
| 815 | else |
| 816 | snprintf(operand, sizeof(operand), "%#x", imm); |
| 817 | |
| 818 | result.emplace_back(IntegerToken, operand, imm); |
| 819 | break; |
| 820 | case LABEL: |
| 821 | snprintf(operand, sizeof(operand), "%#" PRIx64, label_imm); |
| 822 | result.emplace_back(PossibleAddressToken, operand, imm); |
| 823 | break; |
| 824 | case REG: |
| 825 | reg = get_register((Reg)instr.operands[i].reg); |
| 826 | if (reg == NULL) |
| 827 | { |
nothing calls this directly
no test coverage detected