-/* $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
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;
#!/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
);
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
{
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"
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 ";
}
$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;
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/)
-/* $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
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;
-/* $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
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;
#!/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
);
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
{
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"
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 ";
}
$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;
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/)
-/* $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
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;
#!/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
);
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
{
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"
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 ";
}
$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;
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/)
-/* $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
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;