diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c index 2d0f884eef3be671500867f747c0eef09f718b6b..4849762d70c0827858c4476010fd22b3f084ed72 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 af3d576d2190d4640b64a1178112bcc25770bc67..a1e83ccf95cb718c8694c99098e3dd8a8d8fe547 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);