summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-09-11 22:14:18 +0000
committerH. Peter Anvin <hpa@zytor.com>2007-09-11 22:14:18 +0000
commitb79f0d0cc336662d16a22e07ad429e8deb71c956 (patch)
treec3bd6f6f1808ca5d62a0554ac6f62c1acd405ca3
parent2ba7ed7122eea2e594f2f67ea9427b7e702692cc (diff)
downloadnasm-b79f0d0cc336662d16a22e07ad429e8deb71c956.tar.gz
Use enums to make debugging easier
When we're dealing with a field which is guaranteed to have an enum type, then declare it as such so it shows up in debuggers.
-rw-r--r--insns.pl2
-rw-r--r--nasm.h14
-rwxr-xr-xregs.pl4
3 files changed, 11 insertions, 9 deletions
diff --git a/insns.pl b/insns.pl
index 88e47634..f5d5bc1c 100644
--- a/insns.pl
+++ b/insns.pl
@@ -186,7 +186,7 @@ if ( !defined($output) || $output eq 'n' ) {
print N "\n};\n\n";
print N "/* and the corresponding opcodes */\n";
- print N "static const int ico[] = {";
+ print N "static const enum opcode ico[] = {";
$first = 1;
foreach $i (@opcodes_cc) {
print N "," if ( !$first );
diff --git a/nasm.h b/nasm.h
index 89e5273a..bbbb70b1 100644
--- a/nasm.h
+++ b/nasm.h
@@ -543,7 +543,7 @@ enum { /* condition code names */
* prefixes, we must ensure the enumerations for prefixes and
* register names do not overlap.
*/
-enum { /* instruction prefixes */
+enum prefixes { /* instruction prefixes */
PREFIX_ENUM_START = REG_ENUM_LIMIT,
P_A16 = PREFIX_ENUM_START, P_A32, P_LOCK, P_O16, P_O32,
P_REP, P_REPE, P_REPNE, P_REPNZ, P_REPZ, P_TIMES
@@ -562,7 +562,7 @@ enum { /* special EA flags */
EAF_FSGS = 32 /* fs/gs segment override present */
};
-enum { /* values for `hinttype' */
+enum eval_hint { /* values for `hinttype' */
EAH_NOHINT = 0, /* no hint at all - our discretion */
EAH_MAKEBASE = 1, /* try to make given reg the base */
EAH_NOTBASE = 2 /* try _not_ to make reg the base */
@@ -571,8 +571,10 @@ enum { /* values for `hinttype' */
typedef struct { /* operand to an instruction */
int32_t type; /* type of operand */
int addr_size; /* 0 means default; 16; 32; 64 */
- int basereg, indexreg, scale; /* registers and scale involved */
- int hintbase, hinttype; /* hint as to real base register */
+ enum reg_enum basereg, indexreg; /* address registers */
+ int scale; /* index scale */
+ int hintbase;
+ enum eval_hint hinttype; /* hint as to real base register */
int32_t segment; /* immediate segment, if needed */
int64_t offset; /* any immediate number */
int32_t wrt; /* segment base it's relative to */
@@ -597,7 +599,7 @@ typedef struct extop { /* extended operand */
typedef struct { /* an instruction itself */
char *label; /* the label defined, or NULL */
- int prefixes[MAXPREFIX]; /* instruction prefixes, if any */
+ enum prefixes prefixes[MAXPREFIX]; /* instruction prefixes, if any */
int nprefix; /* number of entries in above */
int opcode; /* the opcode - not just the string */
int condition; /* the condition code, if Jcc/SETcc */
@@ -931,7 +933,7 @@ struct dfmt {
* -----
*/
-enum {
+enum special_tokens {
S_ABS, S_BYTE, S_DWORD, S_FAR, S_LONG, S_NEAR, S_NOSPLIT, S_QWORD, S_REL,
S_SHORT, S_STRICT, S_TO, S_TWORD, S_WORD
};
diff --git a/regs.pl b/regs.pl
index cf27ce78..be37c7c6 100755
--- a/regs.pl
+++ b/regs.pl
@@ -99,7 +99,7 @@ if ( $fmt eq 'h' ) {
} elsif ( $fmt eq 'c' ) {
# Output regs.c
print "/* automatically generated from $file - do not edit */\n";
- print "static const char *reg_names[] = "; $ch = '{';
+ print "static const char * const reg_names[] = "; $ch = '{';
# This one has no dummy entry for 0
foreach $reg ( sort(keys(%regs)) ) {
print "$ch\n \"${reg}\"";
@@ -128,7 +128,7 @@ if ( $fmt eq 'h' ) {
# Output regdis.c
print "/* automatically generated from $file - do not edit */\n";
foreach $class ( sort(keys(%disclass)) ) {
- printf "static const int rd_%-8s[] = {", $class;
+ printf "static const enum reg_enum rd_%-8s[] = {", $class;
@foo = @{$disclass{$class}};
@bar = ();
for ( $i = 0 ; $i < scalar(@foo) ; $i++ ) {