Permalink
Browse files

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.
  • Loading branch information...
H. Peter Anvin
H. Peter Anvin committed Sep 11, 2007
1 parent 2ba7ed7 commit b79f0d0cc336662d16a22e07ad429e8deb71c956
Showing with 11 additions and 9 deletions.
  1. +1 −1 insns.pl
  2. +8 −6 nasm.h
  3. +2 −2 regs.pl
View
@@ -186,7 +186,7 @@
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 );
View
14 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
};
View
@@ -99,7 +99,7 @@ ($)
} 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 @@ ($)
# 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++ ) {

0 comments on commit b79f0d0

Please sign in to comment.