mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-03-01 17:35:38 +08:00
ndisasm: simple compare for conditional opcodes, no loop
We had a completely unnecessary loop to test for conditional opcodes. Since we always put the conditional opcodes at the end, we might as well just remember where that list starts and compare against it.
This commit is contained in:
parent
f99359c03a
commit
0ab96a17d5
21
disasm.c
21
disasm.c
@ -1208,18 +1208,15 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < NCOND_OPCODES; i++)
|
||||
if ((*p)->opcode == nasm_cond_insn_opcodes[i]) {
|
||||
slen +=
|
||||
snprintf(output + slen, outbufsize - slen, "%s%s",
|
||||
nasm_cond_insn_names[i],
|
||||
condition_name[ins.condition]);
|
||||
break;
|
||||
}
|
||||
if (i >= NCOND_OPCODES)
|
||||
slen +=
|
||||
snprintf(output + slen, outbufsize - slen, "%s",
|
||||
nasm_insn_names[(*p)->opcode]);
|
||||
i = (*p)->opcode;
|
||||
if (i >= FIRST_COND_OPCODE) {
|
||||
slen += snprintf(output + slen, outbufsize - slen, "%s%s",
|
||||
nasm_cond_insn_names[i-FIRST_COND_OPCODE],
|
||||
condition_name[ins.condition]);
|
||||
} else {
|
||||
slen += snprintf(output + slen, outbufsize - slen, "%s",
|
||||
nasm_insn_names[i]);
|
||||
}
|
||||
colon = false;
|
||||
length += data - origdata; /* fix up for prefixes */
|
||||
for (i = 0; i < (*p)->operands; i++) {
|
||||
|
4
insns.pl
4
insns.pl
@ -230,8 +230,8 @@ if ( !defined($output) || $output eq 'i' ) {
|
||||
}
|
||||
print I "\tI_none = -1\n";
|
||||
print I "\n};\n\n";
|
||||
print I "#define MAX_INSLEN ", $maxlen, "\n\n";
|
||||
print I "#define NCOND_OPCODES ", scalar @opcodes_cc, "\n\n";
|
||||
print I "#define MAX_INSLEN ", $maxlen, "\n";
|
||||
print I "#define FIRST_COND_OPCODE I_", $opcodes_cc[0], "\n\n";
|
||||
print I "#endif /* NASM_INSNSI_H */\n";
|
||||
|
||||
close I;
|
||||
|
Loading…
Reference in New Issue
Block a user