insnsn.c: cleaner to *not* separate out conditional instructions
The disassembler code gets cleaner if we do *not* separate out the conditional instructions; instead, rely on the fact that the conditionals are always at the end and use FIRST_COND_OPCODE as a barrier.
This commit is contained in:
parent
895f56b611
commit
a69ce1d19d
3 changed files with 6 additions and 31 deletions
9
disasm.c
9
disasm.c
|
@ -1245,14 +1245,13 @@ int32_t disasm(uint8_t *data, char *output, int outbufsize, int segsize,
|
|||
}
|
||||
|
||||
i = (*p)->opcode;
|
||||
if (i >= FIRST_COND_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 {
|
||||
nasm_insn_names[i], 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++) {
|
||||
|
|
26
insns.pl
26
insns.pl
|
@ -284,36 +284,14 @@ if ( !defined($output) || $output eq 'n' ) {
|
|||
|
||||
print N "const char * const nasm_insn_names[] = {";
|
||||
$first = 1;
|
||||
foreach $i (@opcodes) {
|
||||
foreach $i (@opcodes, @opcodes_cc) {
|
||||
print N "," if ( !$first );
|
||||
$first = 0;
|
||||
$ilower = $i;
|
||||
$ilower =~ s/cc$//; # Remove conditional cc suffix
|
||||
$ilower =~ tr/A-Z/a-z/; # Change to lower case (Perl 4 compatible)
|
||||
print N "\n\t\"${ilower}\"";
|
||||
}
|
||||
print N "\n};\n\n";
|
||||
print N "/* Conditional instructions */\n";
|
||||
print N "const char * const nasm_cond_insn_names[] = {";
|
||||
$first = 1;
|
||||
foreach $i (@opcodes_cc) {
|
||||
print N "," if ( !$first );
|
||||
$first = 0;
|
||||
$ilower = $i;
|
||||
$ilower =~ s/cc$//; # Skip cc suffix
|
||||
$ilower =~ tr/A-Z/a-z/; # Change to lower case (Perl 4 compatible)
|
||||
print N "\n\t\"${ilower}\"";
|
||||
}
|
||||
|
||||
print N "\n};\n\n";
|
||||
print N "/* and the corresponding opcodes */\n";
|
||||
print N "const enum opcode nasm_cond_insn_opcodes[] = {";
|
||||
$first = 1;
|
||||
foreach $i (@opcodes_cc) {
|
||||
print N "," if ( !$first );
|
||||
$first = 0;
|
||||
print N "\n\tI_$i";
|
||||
}
|
||||
|
||||
print N "\n};\n";
|
||||
close N;
|
||||
}
|
||||
|
|
2
tables.h
2
tables.h
|
@ -21,8 +21,6 @@ extern const char * const * nasm_stdmac_after_tasm;
|
|||
|
||||
/* insnsn.c */
|
||||
extern const char * const nasm_insn_names[];
|
||||
extern const char * const nasm_cond_insn_names[];
|
||||
extern const enum opcode nasm_cond_insn_opcodes[];
|
||||
|
||||
/* --- From regs.dat via regs.pl: --- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue