Make MAX_OPERANDS a parameter in insns.pl as well
authorH. Peter Anvin <hpa@zytor.com>
Mon, 12 May 2008 18:36:24 +0000 (11:36 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 12 May 2008 18:36:24 +0000 (11:36 -0700)
MAX_OPERANDS is present in insns.pl as well (although proper C
compilers shouldn't need this kind of zero padding.)  Make sure it's
clear to everyone.

insns.pl
nasm.h

index ca27fc0..064a3f4 100644 (file)
--- a/insns.pl
+++ b/insns.pl
@@ -11,6 +11,9 @@
 # LONGER PREFIXES FIRST!
 @disasm_prefixes = qw(0F24 0F25 0F38 0F3A 0F7A 0FA6 0FA7 0F);
 
+# This should match MAX_OPERANDS from nasm.h
+$MAX_OPERANDS = 5;
+
 print STDERR "Reading insns.dat...\n";
 
 @args   = ();
@@ -299,7 +302,7 @@ sub format {
        @ops = split(/\,/, $operands);
     }
     $num = scalar(@ops);
-    while (scalar(@ops) < 4) {
+    while (scalar(@ops) < $MAX_OPERANDS) {
        push(@ops, '0');
     }
     $operands = join(',', @ops);
diff --git a/nasm.h b/nasm.h
index 052bbe7..18184d1 100644 (file)
--- a/nasm.h
+++ b/nasm.h
@@ -652,6 +652,7 @@ enum prefix_pos {
     MAXPREFIX                  /* Total number of prefix slots */
 };
 
+/* If you need to change this, also change it in insns.pl */
 #define MAX_OPERANDS 5
 
 typedef struct insn {          /* an instruction itself */