Browse Source

* suffix parsing for at&t fixed for things like movsbl
* string constants are now handle correctly and also allowed in
constant expressions

peter 26 years ago
parent
commit
b84eb33013
2 changed files with 60 additions and 18 deletions
  1. 31 3
      compiler/ra386att.pas
  2. 29 15
      compiler/ra386int.pas

+ 31 - 3
compiler/ra386att.pas

@@ -121,11 +121,13 @@ end;
 
 
 function is_asmopcode(const s: string):boolean;
 function is_asmopcode(const s: string):boolean;
 const
 const
+  { We need first to check the long prefixes, else we get probs
+    with things like movsbl }
   att_sizesuffixstr : array[0..8] of string[2] = (
   att_sizesuffixstr : array[0..8] of string[2] = (
-    '','B','W','L','BW','BL','WL','Q','T'
+    '','BW','BL','WL','B','W','L','Q','T'
   );
   );
   att_sizesuffix : array[0..8] of topsize = (
   att_sizesuffix : array[0..8] of topsize = (
-    S_NO,S_B,S_W,S_L,S_BW,S_BL,S_WL,S_IQ,S_FX
+    S_NO,S_BW,S_BL,S_WL,S_B,S_W,S_L,S_IQ,S_FX
   );
   );
 var
 var
   i    : tasmop;
   i    : tasmop;
@@ -860,6 +862,27 @@ Begin
           if actasmtoken<>AS_ID then
           if actasmtoken<>AS_ID then
            Comment(V_Error,'assem_e_dollar_without_identifier');
            Comment(V_Error,'assem_e_dollar_without_identifier');
         end;
         end;
+      AS_STRING:
+        Begin
+          l:=0;
+          case Length(actasmpattern) of
+           1 :
+            l:=ord(actasmpattern[1]);
+           2 :
+            l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
+           3 :
+            l:=ord(actasmpattern[3]) +
+               Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
+           4 :
+            l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
+               Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
+          else
+            Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
+          end;
+          str(l, tempstr);
+          expr:=expr + tempstr;
+          Consume(AS_STRING);
+        end;
       AS_ID:
       AS_ID:
         Begin
         Begin
           tempstr:=actasmpattern;
           tempstr:=actasmpattern;
@@ -1932,7 +1955,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.53  1999-06-21 16:45:01  peter
+  Revision 1.54  1999-07-24 11:17:12  peter
+    * suffix parsing for at&t fixed for things like movsbl
+    * string constants are now handle correctly and also allowed in
+      constant expressions
+
+  Revision 1.53  1999/06/21 16:45:01  peter
     * merged
     * merged
 
 
   Revision 1.52  1999/06/14 17:48:03  peter
   Revision 1.52  1999/06/14 17:48:03  peter

+ 29 - 15
compiler/ra386int.pas

@@ -776,6 +776,27 @@ Begin
           if actasmtoken<>AS_ID then
           if actasmtoken<>AS_ID then
            Message(asmr_e_offset_without_identifier);
            Message(asmr_e_offset_without_identifier);
         end;
         end;
+      AS_STRING:
+        Begin
+          l:=0;
+          case Length(actasmpattern) of
+           1 :
+            l:=ord(actasmpattern[1]);
+           2 :
+            l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
+           3 :
+            l:=ord(actasmpattern[3]) +
+               Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
+           4 :
+            l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
+               Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
+          else
+            Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
+          end;
+          str(l, tempstr);
+          expr:=expr + tempstr;
+          Consume(AS_STRING);
+        end;
       AS_ID:
       AS_ID:
         Begin
         Begin
           tempstr:=actasmpattern;
           tempstr:=actasmpattern;
@@ -1151,26 +1172,14 @@ Begin
     AS_PLUS,
     AS_PLUS,
     AS_MINUS,
     AS_MINUS,
     AS_NOT,
     AS_NOT,
-    AS_LPAREN :
+    AS_LPAREN,
+    AS_STRING :
       Begin
       Begin
         if not (opr.typ in [OPR_NONE,OPR_CONSTANT]) then
         if not (opr.typ in [OPR_NONE,OPR_CONSTANT]) then
           Message(asmr_e_invalid_operand_type);
           Message(asmr_e_invalid_operand_type);
         BuildConstant;
         BuildConstant;
       end;
       end;
 
 
-    AS_STRING :
-      Begin
-        if not (opr.typ in [OPR_NONE]) then
-          Message(asmr_e_invalid_operand_type);
-        if not PadZero(actasmpattern,4) then
-          Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
-        opr.typ:=OPR_CONSTANT;
-        opr.val:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
-                 Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
-        Consume(AS_STRING);
-      end;
-
-
     AS_ID : { A constant expression, or a Variable ref. }
     AS_ID : { A constant expression, or a Variable ref. }
       Begin
       Begin
         { Label or Special symbol reference? }
         { Label or Special symbol reference? }
@@ -1661,7 +1670,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.40  1999-07-12 15:03:04  peter
+  Revision 1.41  1999-07-24 11:17:16  peter
+    * suffix parsing for at&t fixed for things like movsbl
+    * string constants are now handle correctly and also allowed in
+      constant expressions
+
+  Revision 1.40  1999/07/12 15:03:04  peter
     * merged
     * merged
 
 
   Revision 1.39  1999/06/28 16:02:32  peter
   Revision 1.39  1999/06/28 16:02:32  peter