Prevent disassembling over PC
This commit is contained in:
parent
650d9dfd05
commit
6cba6e5d4f
|
@ -489,8 +489,9 @@ static OpDef* dasmSETF(VBU_DasmConfig *config,
|
|||
}
|
||||
|
||||
/* Disassemble one instruction */
|
||||
static int dasmLine(VB *sim, uint32_t *address, VBU_DasmConfig *config,
|
||||
VBU_DasmLine **lines, size_t *size, size_t *offset, unsigned index) {
|
||||
static int dasmLine(VB *sim, uint32_t *address, uint32_t pc,
|
||||
VBU_DasmConfig *config, VBU_DasmLine **lines, size_t *size, size_t *offset,
|
||||
unsigned index) {
|
||||
char *dest; /* Text output pointer */
|
||||
char *format; /* Hexadecimal format string */
|
||||
VBU_DasmLine *line; /* Output line */
|
||||
|
@ -501,15 +502,17 @@ static int dasmLine(VB *sim, uint32_t *address, VBU_DasmConfig *config,
|
|||
char tCode[4][3]; /* Code display text */
|
||||
char tMnemonic[8]; /* Mnemonic display text */
|
||||
char tOperands[3][15]; /* Operands display text */
|
||||
unsigned x; /* Scratch and iterator */
|
||||
uint32_t x; /* Scratch and iterator */
|
||||
|
||||
/* Process non-text members */
|
||||
line = &(*lines)[index];
|
||||
line->address = *address;
|
||||
line->codeLength = dasmInstSize(sim, *address);
|
||||
line->isPC = vbGetProgramCounter(sim) - *address < line->codeLength;
|
||||
for (x = 0; x < line->codeLength; x++, (*address)++)
|
||||
line->code[x] = vbRead(sim, *address, VB_U8);
|
||||
line->isPC = *address == pc;
|
||||
for (x = 0; x < line->codeLength; x++)
|
||||
line->code[x] = vbRead(sim, *address + x, VB_U8);
|
||||
*address += pc - *address < line->codeLength ?
|
||||
pc - *address : line->codeLength;
|
||||
|
||||
/* Do not process text members */
|
||||
if (config == NULL) {
|
||||
|
@ -674,7 +677,7 @@ static VBU_DasmLine* dasmDisassemble(VB *sim, uint32_t address,
|
|||
|
||||
/* Process output lines */
|
||||
for (x = 0; x < length; x++) {
|
||||
if (dasmLine(sim, &addr, config, &lines, &size, &offset, x))
|
||||
if (dasmLine(sim, &addr, pc, config, &lines, &size, &offset, x))
|
||||
goto catch;
|
||||
}
|
||||
return lines;
|
||||
|
|
Loading…
Reference in New Issue