]> granicus.if.org Git - yasm/commitdiff
Change groupdate into an array, and make everything 0-based in the output
authorPeter Johnson <peter@tortall.net>
Thu, 5 Jul 2001 07:21:35 +0000 (07:21 -0000)
committerPeter Johnson <peter@tortall.net>
Thu, 5 Jul 2001 07:21:35 +0000 (07:21 -0000)
code.  Bit of a kludge required in gen_instr.pl to slide the $0.\d down by
one (is there a better way to do it?).

svn path=/trunk/yasm/; revision=108

modules/parsers/nasm/bison.y.in
modules/parsers/nasm/gen_instr.pl
modules/parsers/nasm/nasm-bison.y
src/bison.y.in
src/gen_instr.pl
src/parsers/nasm/bison.y.in
src/parsers/nasm/gen_instr.pl
src/parsers/nasm/nasm-bison.y

index 5eff0429d1b81c09654ad0352add332240cda83d..72b0b96d41a7e49fa47170d9ca2bbf0bf809629c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.14 2001/07/05 05:04:37 peter Exp $
+/* $Id: bison.y.in,v 1.15 2001/07/05 07:21:35 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -44,11 +44,7 @@ extern void yyerror(char *);
        char *name;
        int line;
     } syminfo;
-    struct {
-       unsigned char d1;
-       unsigned char d2;
-       unsigned char d3;
-    } groupdata;
+    unsigned char groupdata[3];
     effaddr ea_val;
     immval im_val;
     bytecode bc;
index 63ecad3eae7852081e594cd08e346fd9009a8e42..f041d5402f28cf83c5f6c8163dadb4f8b3df37ac 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# $Id: gen_instr.pl,v 1.13 2001/07/05 07:00:01 peter Exp $
+# $Id: gen_instr.pl,v 1.14 2001/07/05 07:21:35 peter Exp $
 # Generates bison.y and token.l from instrs.dat for YASM
 #
 #    Copyright (C) 2001  Michael Urman
@@ -84,7 +84,7 @@ my $valid_regs = join '|', qw(
 );
 my $valid_opcodes = join '|', qw(
     [0-9A-F]{2}
-    \\$0\\.1 \\$0\\.2 \\$0\\.3
+    \\$0\\.0 \\$0\\.1 \\$0\\.2
 );
 my $valid_cpus = join '|', qw(
     8086 186 286 386 486 P4 P5 P6
@@ -154,6 +154,12 @@ sub read_instructions ($)
     {
        my ($inst, $args, $groups, $instrfile) = splice @_;
 
+       # yes, this is a kludge, to slide $0.\d down by one.
+       # is there a better way? (other than changing instrs.dat :)
+       $args =~ s/\$0\.1/\$0\.0/g;
+       $args =~ s/\$0\.2/\$0\.1/g;
+       $args =~ s/\$0\.3/\$0\.2/g;
+
        my ($op, $size, $opcode, $eff, $imm, $cpu) = split /\t+/, $args;
        eval {
            die "Invalid group name\n"
@@ -269,12 +275,10 @@ sub output_lex ($@)
                        if ($grp->[2])
                        {
                            @groupdata = split ",", $grp->[2];
-                           # choke.  gasp.  yes, the .d\d array starts
-                           # at 1 not 0.  *glares*
-                           for (my $i=1; $i <= @groupdata; ++$i)
+                           for (my $i=0; $i < @groupdata; ++$i)
                            {
-                               $groupdata[$i-1] =~ s/nil/0/;
-                               $groupdata[$i-1] = " yylval.groupdata.d$i = 0x$groupdata[$i-1];";
+                               $groupdata[$i] =~ s/nil/0/;
+                               $groupdata[$i] = " yylval.groupdata[$i] = 0x$groupdata[$i];";
                            }
                            $groupdata[-1] .= "\n\t     ";
                        }
@@ -476,7 +480,7 @@ sub output_yacc ($@)
                    $args[-1] =~ s[^([0-9A-Fa-f]+),]
                        [ConvertIntToImm((immval *)NULL, 0x$1),];
                    $args[-1] =~ s[^\$0.(\d+),]
-                       [ConvertIntToImm((immval *)NULL, \$1.d$1),];
+                       [ConvertIntToImm((immval *)NULL, \$1\[$1\]),];
 
                    # divide the second, and only the second, by 8 bits/byte
                    $args[-1] =~ s#(,\s*)(\d+)(s)?#$1 . ($2/8)#eg;
@@ -488,7 +492,7 @@ sub output_yacc ($@)
                    die $args[-1] if $args[-1] =~ m/\d+[ris]/;
 
                    # now that we've constructed the arglist, subst $0.\d
-                   s/\$0\.(\d+)/\$1.d$1/g foreach (@args);
+                   s/\$0\.(\d+)/\$1\[$1\]/g foreach (@args);
                    
                    # see if we match one of the cases to defer
                    if (($inst->[OPERANDS]||"") =~ m/,ONE/)
index 549ab5fa1cb1217d8da77c9387ea08c9c22eac61..7a32a80e0256b3c355ab7f876acde671437ffa4d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.14 2001/07/05 05:04:37 peter Exp $
+/* $Id: nasm-bison.y,v 1.15 2001/07/05 07:21:35 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -44,11 +44,7 @@ extern void yyerror(char *);
        char *name;
        int line;
     } syminfo;
-    struct {
-       unsigned char d1;
-       unsigned char d2;
-       unsigned char d3;
-    } groupdata;
+    unsigned char groupdata[3];
     effaddr ea_val;
     immval im_val;
     bytecode bc;
index 5eff0429d1b81c09654ad0352add332240cda83d..72b0b96d41a7e49fa47170d9ca2bbf0bf809629c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.14 2001/07/05 05:04:37 peter Exp $
+/* $Id: bison.y.in,v 1.15 2001/07/05 07:21:35 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -44,11 +44,7 @@ extern void yyerror(char *);
        char *name;
        int line;
     } syminfo;
-    struct {
-       unsigned char d1;
-       unsigned char d2;
-       unsigned char d3;
-    } groupdata;
+    unsigned char groupdata[3];
     effaddr ea_val;
     immval im_val;
     bytecode bc;
index 63ecad3eae7852081e594cd08e346fd9009a8e42..f041d5402f28cf83c5f6c8163dadb4f8b3df37ac 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# $Id: gen_instr.pl,v 1.13 2001/07/05 07:00:01 peter Exp $
+# $Id: gen_instr.pl,v 1.14 2001/07/05 07:21:35 peter Exp $
 # Generates bison.y and token.l from instrs.dat for YASM
 #
 #    Copyright (C) 2001  Michael Urman
@@ -84,7 +84,7 @@ my $valid_regs = join '|', qw(
 );
 my $valid_opcodes = join '|', qw(
     [0-9A-F]{2}
-    \\$0\\.1 \\$0\\.2 \\$0\\.3
+    \\$0\\.0 \\$0\\.1 \\$0\\.2
 );
 my $valid_cpus = join '|', qw(
     8086 186 286 386 486 P4 P5 P6
@@ -154,6 +154,12 @@ sub read_instructions ($)
     {
        my ($inst, $args, $groups, $instrfile) = splice @_;
 
+       # yes, this is a kludge, to slide $0.\d down by one.
+       # is there a better way? (other than changing instrs.dat :)
+       $args =~ s/\$0\.1/\$0\.0/g;
+       $args =~ s/\$0\.2/\$0\.1/g;
+       $args =~ s/\$0\.3/\$0\.2/g;
+
        my ($op, $size, $opcode, $eff, $imm, $cpu) = split /\t+/, $args;
        eval {
            die "Invalid group name\n"
@@ -269,12 +275,10 @@ sub output_lex ($@)
                        if ($grp->[2])
                        {
                            @groupdata = split ",", $grp->[2];
-                           # choke.  gasp.  yes, the .d\d array starts
-                           # at 1 not 0.  *glares*
-                           for (my $i=1; $i <= @groupdata; ++$i)
+                           for (my $i=0; $i < @groupdata; ++$i)
                            {
-                               $groupdata[$i-1] =~ s/nil/0/;
-                               $groupdata[$i-1] = " yylval.groupdata.d$i = 0x$groupdata[$i-1];";
+                               $groupdata[$i] =~ s/nil/0/;
+                               $groupdata[$i] = " yylval.groupdata[$i] = 0x$groupdata[$i];";
                            }
                            $groupdata[-1] .= "\n\t     ";
                        }
@@ -476,7 +480,7 @@ sub output_yacc ($@)
                    $args[-1] =~ s[^([0-9A-Fa-f]+),]
                        [ConvertIntToImm((immval *)NULL, 0x$1),];
                    $args[-1] =~ s[^\$0.(\d+),]
-                       [ConvertIntToImm((immval *)NULL, \$1.d$1),];
+                       [ConvertIntToImm((immval *)NULL, \$1\[$1\]),];
 
                    # divide the second, and only the second, by 8 bits/byte
                    $args[-1] =~ s#(,\s*)(\d+)(s)?#$1 . ($2/8)#eg;
@@ -488,7 +492,7 @@ sub output_yacc ($@)
                    die $args[-1] if $args[-1] =~ m/\d+[ris]/;
 
                    # now that we've constructed the arglist, subst $0.\d
-                   s/\$0\.(\d+)/\$1.d$1/g foreach (@args);
+                   s/\$0\.(\d+)/\$1\[$1\]/g foreach (@args);
                    
                    # see if we match one of the cases to defer
                    if (($inst->[OPERANDS]||"") =~ m/,ONE/)
index 5eff0429d1b81c09654ad0352add332240cda83d..72b0b96d41a7e49fa47170d9ca2bbf0bf809629c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: bison.y.in,v 1.14 2001/07/05 05:04:37 peter Exp $
+/* $Id: bison.y.in,v 1.15 2001/07/05 07:21:35 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -44,11 +44,7 @@ extern void yyerror(char *);
        char *name;
        int line;
     } syminfo;
-    struct {
-       unsigned char d1;
-       unsigned char d2;
-       unsigned char d3;
-    } groupdata;
+    unsigned char groupdata[3];
     effaddr ea_val;
     immval im_val;
     bytecode bc;
index 63ecad3eae7852081e594cd08e346fd9009a8e42..f041d5402f28cf83c5f6c8163dadb4f8b3df37ac 100755 (executable)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# $Id: gen_instr.pl,v 1.13 2001/07/05 07:00:01 peter Exp $
+# $Id: gen_instr.pl,v 1.14 2001/07/05 07:21:35 peter Exp $
 # Generates bison.y and token.l from instrs.dat for YASM
 #
 #    Copyright (C) 2001  Michael Urman
@@ -84,7 +84,7 @@ my $valid_regs = join '|', qw(
 );
 my $valid_opcodes = join '|', qw(
     [0-9A-F]{2}
-    \\$0\\.1 \\$0\\.2 \\$0\\.3
+    \\$0\\.0 \\$0\\.1 \\$0\\.2
 );
 my $valid_cpus = join '|', qw(
     8086 186 286 386 486 P4 P5 P6
@@ -154,6 +154,12 @@ sub read_instructions ($)
     {
        my ($inst, $args, $groups, $instrfile) = splice @_;
 
+       # yes, this is a kludge, to slide $0.\d down by one.
+       # is there a better way? (other than changing instrs.dat :)
+       $args =~ s/\$0\.1/\$0\.0/g;
+       $args =~ s/\$0\.2/\$0\.1/g;
+       $args =~ s/\$0\.3/\$0\.2/g;
+
        my ($op, $size, $opcode, $eff, $imm, $cpu) = split /\t+/, $args;
        eval {
            die "Invalid group name\n"
@@ -269,12 +275,10 @@ sub output_lex ($@)
                        if ($grp->[2])
                        {
                            @groupdata = split ",", $grp->[2];
-                           # choke.  gasp.  yes, the .d\d array starts
-                           # at 1 not 0.  *glares*
-                           for (my $i=1; $i <= @groupdata; ++$i)
+                           for (my $i=0; $i < @groupdata; ++$i)
                            {
-                               $groupdata[$i-1] =~ s/nil/0/;
-                               $groupdata[$i-1] = " yylval.groupdata.d$i = 0x$groupdata[$i-1];";
+                               $groupdata[$i] =~ s/nil/0/;
+                               $groupdata[$i] = " yylval.groupdata[$i] = 0x$groupdata[$i];";
                            }
                            $groupdata[-1] .= "\n\t     ";
                        }
@@ -476,7 +480,7 @@ sub output_yacc ($@)
                    $args[-1] =~ s[^([0-9A-Fa-f]+),]
                        [ConvertIntToImm((immval *)NULL, 0x$1),];
                    $args[-1] =~ s[^\$0.(\d+),]
-                       [ConvertIntToImm((immval *)NULL, \$1.d$1),];
+                       [ConvertIntToImm((immval *)NULL, \$1\[$1\]),];
 
                    # divide the second, and only the second, by 8 bits/byte
                    $args[-1] =~ s#(,\s*)(\d+)(s)?#$1 . ($2/8)#eg;
@@ -488,7 +492,7 @@ sub output_yacc ($@)
                    die $args[-1] if $args[-1] =~ m/\d+[ris]/;
 
                    # now that we've constructed the arglist, subst $0.\d
-                   s/\$0\.(\d+)/\$1.d$1/g foreach (@args);
+                   s/\$0\.(\d+)/\$1\[$1\]/g foreach (@args);
                    
                    # see if we match one of the cases to defer
                    if (($inst->[OPERANDS]||"") =~ m/,ONE/)
index 549ab5fa1cb1217d8da77c9387ea08c9c22eac61..7a32a80e0256b3c355ab7f876acde671437ffa4d 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: nasm-bison.y,v 1.14 2001/07/05 05:04:37 peter Exp $
+/* $Id: nasm-bison.y,v 1.15 2001/07/05 07:21:35 peter Exp $
  * Main bison parser
  *
  *  Copyright (C) 2001  Peter Johnson, Michael Urman
@@ -44,11 +44,7 @@ extern void yyerror(char *);
        char *name;
        int line;
     } syminfo;
-    struct {
-       unsigned char d1;
-       unsigned char d2;
-       unsigned char d3;
-    } groupdata;
+    unsigned char groupdata[3];
     effaddr ea_val;
     immval im_val;
     bytecode bc;