From 21b7287f5aa95e33919978835eda182e09c8f89a Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Mon, 12 Sep 2011 14:32:18 +0000 Subject: [PATCH] Fixes for disassembling correctly and genearl bug fixes --- .../Includes/instr_set/opcodes_A_M.c | 12 ++++++++++++ libIRDB/test/fill_in_cfg.cpp | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c index 2d0f884ee..4849762d7 100644 --- a/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c +++ b/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c @@ -1570,6 +1570,12 @@ void __bea_callspec__ cmp_eAX_Iv(PDISASM pMyDisasm) * ======================================= */ void __bea_callspec__ cmpsb_(PDISASM pMyDisasm) { + if ((*pMyDisasm).Prefix.RepnePrefix == SuperfluousPrefix) { + (*pMyDisasm).Prefix.RepnePrefix = InUsePrefix; + } + if ((*pMyDisasm).Prefix.RepPrefix == SuperfluousPrefix) { + (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; + } (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "cmpsb "); @@ -1590,6 +1596,12 @@ void __bea_callspec__ cmpsb_(PDISASM pMyDisasm) * ======================================= */ void __bea_callspec__ cmps_(PDISASM pMyDisasm) { + if ((*pMyDisasm).Prefix.RepnePrefix == SuperfluousPrefix) { + (*pMyDisasm).Prefix.RepnePrefix = InUsePrefix; + } + if ((*pMyDisasm).Prefix.RepPrefix == SuperfluousPrefix) { + (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; + } (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION; (*pMyDisasm).Argument1.ArgType = MEMORY_TYPE; (*pMyDisasm).Argument1.Memory.BaseRegister = REG7; diff --git a/libIRDB/test/fill_in_cfg.cpp b/libIRDB/test/fill_in_cfg.cpp index af3d576d2..a1e83ccf9 100644 --- a/libIRDB/test/fill_in_cfg.cpp +++ b/libIRDB/test/fill_in_cfg.cpp @@ -257,8 +257,6 @@ void add_new_instructions(VariantIR_t *virp) /* is the missed instruction in this section */ if(first<=missed_address && missed_address<=second) { - /* found */ - found=true; char* data=(char*)malloc(sechdrs[secndx].sh_size+16); /* +16 to account for a bogus-y instruction that wraps past the end of the section */ memset(data,0, sechdrs[secndx].sh_size+16); /* bogus bits are always 0 */ @@ -279,6 +277,21 @@ void add_new_instructions(VariantIR_t *virp) int instr_len = Disasm(&disasm); +/* bea docs say OUT_OF_RANGE and UNKNOWN_OPCODE are defined, but they aren't */ +#define OUT_OF_RANGE (0) +#define UNKNOWN_OPCODE (1) + + /* if we found the instruction, but can't disassemble it, then we skip out for now */ + if(instr_len==OUT_OF_RANGE || instr_len==UNKNOWN_OPCODE) + break; + + /* intel instructions have a max size of 16 */ + assert(1<=instr_len && instr_len<=16); + + + /* here we are certain we found the instruction */ + found=true; + /* get the new bits for an instruction */ string newinsnbits; newinsnbits.resize(instr_len); -- GitLab