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:
H. Peter Anvin 2008-05-20 17:07:57 -07:00
parent f99359c03a
commit 0ab96a17d5
2 changed files with 11 additions and 14 deletions

View File

@ -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++) {

View File

@ -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;