From: Peter Johnson Date: Thu, 5 Jul 2001 07:21:35 +0000 (-0000) Subject: Change groupdate into an array, and make everything 0-based in the output X-Git-Tag: v0.1.0~403 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=273a7b3c838d353c626b93a9413f6fc33e8781c2;p=yasm Change groupdate into an array, and make everything 0-based in the output 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 --- diff --git a/modules/parsers/nasm/bison.y.in b/modules/parsers/nasm/bison.y.in index 5eff0429..72b0b96d 100644 --- a/modules/parsers/nasm/bison.y.in +++ b/modules/parsers/nasm/bison.y.in @@ -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; diff --git a/modules/parsers/nasm/gen_instr.pl b/modules/parsers/nasm/gen_instr.pl index 63ecad3e..f041d540 100755 --- a/modules/parsers/nasm/gen_instr.pl +++ b/modules/parsers/nasm/gen_instr.pl @@ -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/) diff --git a/modules/parsers/nasm/nasm-bison.y b/modules/parsers/nasm/nasm-bison.y index 549ab5fa..7a32a80e 100644 --- a/modules/parsers/nasm/nasm-bison.y +++ b/modules/parsers/nasm/nasm-bison.y @@ -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; diff --git a/src/bison.y.in b/src/bison.y.in index 5eff0429..72b0b96d 100644 --- a/src/bison.y.in +++ b/src/bison.y.in @@ -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; diff --git a/src/gen_instr.pl b/src/gen_instr.pl index 63ecad3e..f041d540 100755 --- a/src/gen_instr.pl +++ b/src/gen_instr.pl @@ -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/) diff --git a/src/parsers/nasm/bison.y.in b/src/parsers/nasm/bison.y.in index 5eff0429..72b0b96d 100644 --- a/src/parsers/nasm/bison.y.in +++ b/src/parsers/nasm/bison.y.in @@ -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; diff --git a/src/parsers/nasm/gen_instr.pl b/src/parsers/nasm/gen_instr.pl index 63ecad3e..f041d540 100755 --- a/src/parsers/nasm/gen_instr.pl +++ b/src/parsers/nasm/gen_instr.pl @@ -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/) diff --git a/src/parsers/nasm/nasm-bison.y b/src/parsers/nasm/nasm-bison.y index 549ab5fa..7a32a80e 100644 --- a/src/parsers/nasm/nasm-bison.y +++ b/src/parsers/nasm/nasm-bison.y @@ -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;