summaryrefslogtreecommitdiff
path: root/insns.pl
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-12 20:27:41 -0700
committerH. Peter Anvin <hpa@zytor.com>2007-09-12 20:27:41 -0700
commit16b0a33ceae7b57cf4ebc9ab62cd4e1dc00dbf8c (patch)
tree8402b87bfea53a1b9c57069653c3b8f42e0f8b6e /insns.pl
parent7978feebd2fb0be9f4a37980090dfebeeb29a36d (diff)
downloadnasm-16b0a33ceae7b57cf4ebc9ab62cd4e1dc00dbf8c.tar.gz
nasm-16b0a33ceae7b57cf4ebc9ab62cd4e1dc00dbf8c.tar.bz2
nasm-16b0a33ceae7b57cf4ebc9ab62cd4e1dc00dbf8c.zip
Use enumerations where practical to ease debugging
We have a lot of enumerations; by declaring fields as such, we make it easier when debugging, since the debugger can display the enumerations in cleartext. However, make sure exceptional values (like -1) are included in the enumeration, since the compiler otherwise may not include it in the valid range of the enumeration.
Diffstat (limited to 'insns.pl')
-rw-r--r--insns.pl15
1 files changed, 8 insertions, 7 deletions
diff --git a/insns.pl b/insns.pl
index f5d5bc1..280213c 100644
--- a/insns.pl
+++ b/insns.pl
@@ -135,20 +135,21 @@ if ( !defined($output) || $output eq 'i' ) {
" - don't edit it */\n\n";
print I "/* This file in included by nasm.h */\n\n";
- print I "/* Instruction names */\n";
- print I "enum opcode {";
- $first = 1;
+ print I "/* Instruction names */\n\n";
+ print I "#ifndef NASM_INSNSI_H\n";
+ print I "#define NASM_INSNSI_H 1\n\n";
+ print I "enum opcode {\n";
$maxlen = 0;
foreach $i (@opcodes, @opcodes_cc) {
- print I "," if ( !$first );
- $first = 0;
- print I "\n\tI_${i}";
+ print I "\tI_${i},\n";
$len = length($i);
$len++ if ( $i =~ /cc$/ ); # Condition codes can be 3 characters long
$maxlen = $len if ( $len > $maxlen );
}
+ print I "\tI_none = -1\n";
print I "\n};\n\n";
- print I "#define MAX_INSLEN ", $maxlen, "\n";
+ print I "#define MAX_INSLEN ", $maxlen, "\n\n";
+ print I "#endif /* NASM_INSNSI_H */\n";
close I;
}