]> granicus.if.org Git - yasm/commitdiff
Make call instruction work correctly. The old code generated a legal short
authorPeter Johnson <peter@tortall.net>
Sun, 17 Mar 2002 20:18:24 +0000 (20:18 -0000)
committerPeter Johnson <peter@tortall.net>
Sun, 17 Mar 2002 20:18:24 +0000 (20:18 -0000)
form for it (opcode length 1, opcode 0, rather than opcode length 0).

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

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

index 50ee522563c5cd4c9d0afc957e8efa4550548cd4..b3f0533ac3b4d8ef1af2cb0895e8b341ff49d61a 100644 (file)
@@ -71,7 +71,7 @@ static bytecode *nasm_parser_temp_bc;
     intnum *intn;
     floatnum *flt;
     symrec *sym;
-    unsigned char groupdata[4];
+    unsigned char groupdata[5];
     effaddr *ea;
     expr *exp;
     immval *im_val;
index 57f0d7af41975dc8ae063de1b0c1c144f7224bd7..50184e04f4951a97c348e265e47afe750d04a3cd 100755 (executable)
@@ -180,7 +180,7 @@ sub read_instructions ($)
                die "Invalid Address Size\n"
                        if $size !~ m/^(nil|16|32|\$0\.\d)$/oi;
                die "Invalid Short Opcode\n"
-                       if $shortopcode !~ m/^(nil|(?:$valid_opcodes)(,(?:$valid_opcodes)){0,2}(\+(\$\d|\$0\.\d|\d))?)$/oi;
+                       if $shortopcode !~ m/^(\$0\.\d\?)?(nil|(?:$valid_opcodes)(,(?:$valid_opcodes)){0,2}(\+(\$\d|\$0\.\d|\d))?)$/oi;
                die "Invalid Near Opcode\n"
                        if $nearopcode !~ m/^(nil|(?:$valid_opcodes)(,(?:$valid_opcodes)){0,2}(\+(\$\d|\$0\.\d|\d))?)$/oi;
                die "Invalid Short CPU\n"
@@ -538,10 +538,23 @@ sub output_yacc ($@)
                        }
                        else
                        {
-                           # opcode piece 1 (and 2 and 3 if attached)
-                           my @opcodes = split ",", $inst->[SHORTOPCODE];
-                           # number of bytes of short opcode
-                           push @args, "short_op_len=".@opcodes.";";
+                           my @opcodes;
+                           print $inst->[SHORTOPCODE]."\n";
+                           # Check for possible length parameter
+                           if($inst->[SHORTOPCODE] =~ m/\?/)
+                           {
+                               my @pieces = split /\?/, $inst->[SHORTOPCODE];
+                               push @args, "short_op_len=".$pieces[0].";";
+                               # opcode piece 1 (and 2 and 3 if attached)
+                               @opcodes = split ",", $pieces[1];
+                           }
+                           else
+                           {
+                               # opcode piece 1 (and 2 and 3 if attached)
+                               @opcodes = split ",", $inst->[SHORTOPCODE];
+                               # number of bytes of short opcode
+                               push @args, "short_op_len=".@opcodes.";";
+                           }
                            for (my $i=0; $i < @opcodes; ++$i)
                            {
                                $opcodes[$i] =~ s/([0-9A-Fa-f]{2})/0x$1/g;
index 50ee522563c5cd4c9d0afc957e8efa4550548cd4..b3f0533ac3b4d8ef1af2cb0895e8b341ff49d61a 100644 (file)
@@ -71,7 +71,7 @@ static bytecode *nasm_parser_temp_bc;
     intnum *intn;
     floatnum *flt;
     symrec *sym;
-    unsigned char groupdata[4];
+    unsigned char groupdata[5];
     effaddr *ea;
     expr *exp;
     immval *im_val;
index 50ee522563c5cd4c9d0afc957e8efa4550548cd4..b3f0533ac3b4d8ef1af2cb0895e8b341ff49d61a 100644 (file)
@@ -71,7 +71,7 @@ static bytecode *nasm_parser_temp_bc;
     intnum *intn;
     floatnum *flt;
     symrec *sym;
-    unsigned char groupdata[4];
+    unsigned char groupdata[5];
     effaddr *ea;
     expr *exp;
     immval *im_val;
index 57f0d7af41975dc8ae063de1b0c1c144f7224bd7..50184e04f4951a97c348e265e47afe750d04a3cd 100755 (executable)
@@ -180,7 +180,7 @@ sub read_instructions ($)
                die "Invalid Address Size\n"
                        if $size !~ m/^(nil|16|32|\$0\.\d)$/oi;
                die "Invalid Short Opcode\n"
-                       if $shortopcode !~ m/^(nil|(?:$valid_opcodes)(,(?:$valid_opcodes)){0,2}(\+(\$\d|\$0\.\d|\d))?)$/oi;
+                       if $shortopcode !~ m/^(\$0\.\d\?)?(nil|(?:$valid_opcodes)(,(?:$valid_opcodes)){0,2}(\+(\$\d|\$0\.\d|\d))?)$/oi;
                die "Invalid Near Opcode\n"
                        if $nearopcode !~ m/^(nil|(?:$valid_opcodes)(,(?:$valid_opcodes)){0,2}(\+(\$\d|\$0\.\d|\d))?)$/oi;
                die "Invalid Short CPU\n"
@@ -538,10 +538,23 @@ sub output_yacc ($@)
                        }
                        else
                        {
-                           # opcode piece 1 (and 2 and 3 if attached)
-                           my @opcodes = split ",", $inst->[SHORTOPCODE];
-                           # number of bytes of short opcode
-                           push @args, "short_op_len=".@opcodes.";";
+                           my @opcodes;
+                           print $inst->[SHORTOPCODE]."\n";
+                           # Check for possible length parameter
+                           if($inst->[SHORTOPCODE] =~ m/\?/)
+                           {
+                               my @pieces = split /\?/, $inst->[SHORTOPCODE];
+                               push @args, "short_op_len=".$pieces[0].";";
+                               # opcode piece 1 (and 2 and 3 if attached)
+                               @opcodes = split ",", $pieces[1];
+                           }
+                           else
+                           {
+                               # opcode piece 1 (and 2 and 3 if attached)
+                               @opcodes = split ",", $inst->[SHORTOPCODE];
+                               # number of bytes of short opcode
+                               push @args, "short_op_len=".@opcodes.";";
+                           }
                            for (my $i=0; $i < @opcodes; ++$i)
                            {
                                $opcodes[$i] =~ s/([0-9A-Fa-f]{2})/0x$1/g;
index 50ee522563c5cd4c9d0afc957e8efa4550548cd4..b3f0533ac3b4d8ef1af2cb0895e8b341ff49d61a 100644 (file)
@@ -71,7 +71,7 @@ static bytecode *nasm_parser_temp_bc;
     intnum *intn;
     floatnum *flt;
     symrec *sym;
-    unsigned char groupdata[4];
+    unsigned char groupdata[5];
     effaddr *ea;
     expr *exp;
     immval *im_val;