Browse Source

+ added extra boolean out parameter 'hasofs' to
tx86intreader.BuildConstSymbolExpression; it returns whether the 'OFFSET'
keyword has been used in the expression. This will be used for disambiguation
between 'dd xx' and 'dd offset xx', because they should produce different
results on i8086 (the first generates a far pointer, i.e. the same as
'dw xx, SEG xx', the second - a 32-bit offset)

git-svn-id: trunk@38147 -

nickysn 7 years ago
parent
commit
70038f1c0b
1 changed files with 13 additions and 16 deletions
  1. 13 16
      compiler/x86/rax86int.pas

+ 13 - 16
compiler/x86/rax86int.pas

@@ -64,7 +64,7 @@ Unit Rax86int;
          function consume(t : tasmtoken):boolean;
          function consume(t : tasmtoken):boolean;
          procedure RecoverConsume(allowcomma:boolean);
          procedure RecoverConsume(allowcomma:boolean);
          procedure BuildRecordOffsetSize(const expr: string;var offset:tcgint;var size:tcgint; var mangledname: string; needvmtofs: boolean; out hastypecast: boolean);
          procedure BuildRecordOffsetSize(const expr: string;var offset:tcgint;var size:tcgint; var mangledname: string; needvmtofs: boolean; out hastypecast: boolean);
-         procedure BuildConstSymbolExpression(needofs,isref,startingminus:boolean;var value:tcgint;var asmsym:string;var asmsymtyp:TAsmsymtype;out isseg,is_farproc_entry:boolean);
+         procedure BuildConstSymbolExpression(needofs,isref,startingminus:boolean;var value:tcgint;var asmsym:string;var asmsymtyp:TAsmsymtype;out isseg,is_farproc_entry,hasofs:boolean);
          function BuildConstExpression:aint;
          function BuildConstExpression:aint;
          function BuildRefConstExpression(startingminus:boolean=false):aint;
          function BuildRefConstExpression(startingminus:boolean=false):aint;
          procedure BuildReference(oper : tx86operand);
          procedure BuildReference(oper : tx86operand);
@@ -790,7 +790,7 @@ Unit Rax86int;
       end;
       end;
 
 
 
 
-    Procedure tx86intreader.BuildConstSymbolExpression(needofs,isref,startingminus:boolean;var value:tcgint;var asmsym:string;var asmsymtyp:TAsmsymtype;out isseg,is_farproc_entry:boolean);
+    Procedure tx86intreader.BuildConstSymbolExpression(needofs,isref,startingminus:boolean;var value:tcgint;var asmsym:string;var asmsymtyp:TAsmsymtype;out isseg,is_farproc_entry,hasofs:boolean);
       var
       var
         tempstr,expr,hs,mangledname : string;
         tempstr,expr,hs,mangledname : string;
         parenlevel : longint;
         parenlevel : longint;
@@ -812,6 +812,7 @@ Unit Rax86int;
         asmsymtyp:=AT_DATA;
         asmsymtyp:=AT_DATA;
         isseg:=false;
         isseg:=false;
         is_farproc_entry:=FALSE;
         is_farproc_entry:=FALSE;
+        hasofs:=FALSE;
         errorflag:=FALSE;
         errorflag:=FALSE;
         tempstr:='';
         tempstr:='';
         expr:='';
         expr:='';
@@ -1190,10 +1191,9 @@ Unit Rax86int;
         l : tcgint;
         l : tcgint;
         hs : string;
         hs : string;
         hssymtyp : TAsmsymtype;
         hssymtyp : TAsmsymtype;
-        isseg : boolean;
-        is_farproc_entry : boolean;
+        isseg,is_farproc_entry,hasofs : boolean;
       begin
       begin
-        BuildConstSymbolExpression(false,false,false,l,hs,hssymtyp,isseg,is_farproc_entry);
+        BuildConstSymbolExpression(false,false,false,l,hs,hssymtyp,isseg,is_farproc_entry,hasofs);
         if hs<>'' then
         if hs<>'' then
          Message(asmr_e_relocatable_symbol_not_allowed);
          Message(asmr_e_relocatable_symbol_not_allowed);
         BuildConstExpression:=l;
         BuildConstExpression:=l;
@@ -1205,10 +1205,9 @@ Unit Rax86int;
         l : tcgint;
         l : tcgint;
         hs : string;
         hs : string;
         hssymtyp : TAsmsymtype;
         hssymtyp : TAsmsymtype;
-        isseg : boolean;
-        is_farproc_entry : boolean;
+        isseg,is_farproc_entry,hasofs : boolean;
       begin
       begin
-        BuildConstSymbolExpression(false,true,startingminus,l,hs,hssymtyp,isseg,is_farproc_entry);
+        BuildConstSymbolExpression(false,true,startingminus,l,hs,hssymtyp,isseg,is_farproc_entry,hasofs);
         if hs<>'' then
         if hs<>'' then
          Message(asmr_e_relocatable_symbol_not_allowed);
          Message(asmr_e_relocatable_symbol_not_allowed);
         BuildRefConstExpression:=l;
         BuildRefConstExpression:=l;
@@ -1227,7 +1226,7 @@ Unit Rax86int;
         GotPlus,Negative : boolean;
         GotPlus,Negative : boolean;
         hl : tasmlabel;
         hl : tasmlabel;
         isseg: boolean;
         isseg: boolean;
-        is_farproc_entry,
+        is_farproc_entry,hasofs,
         hastypecast: boolean;
         hastypecast: boolean;
       Begin
       Begin
         Consume(AS_LBRACKET);
         Consume(AS_LBRACKET);
@@ -1550,7 +1549,7 @@ Unit Rax86int;
               begin
               begin
                 if not GotPlus and not GotStar then
                 if not GotPlus and not GotStar then
                   Message(asmr_e_invalid_reference_syntax);
                   Message(asmr_e_invalid_reference_syntax);
-                BuildConstSymbolExpression(true,true,GotPlus and negative,l,tempstr,tempsymtyp,isseg,is_farproc_entry);
+                BuildConstSymbolExpression(true,true,GotPlus and negative,l,tempstr,tempsymtyp,isseg,is_farproc_entry,hasofs);
                 { already handled by BuildConstSymbolExpression(); must be
                 { already handled by BuildConstSymbolExpression(); must be
                   handled there to avoid [reg-1+1] being interpreted as
                   handled there to avoid [reg-1+1] being interpreted as
                   [reg-(1+1)] }
                   [reg-(1+1)] }
@@ -1640,12 +1639,11 @@ Unit Rax86int;
         l : tcgint;
         l : tcgint;
         tempstr : string;
         tempstr : string;
         tempsymtyp : tasmsymtype;
         tempsymtyp : tasmsymtype;
-        isseg: boolean;
-        is_farproc_entry : boolean;
+        isseg,is_farproc_entry,hasofs : boolean;
       begin
       begin
         if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
         if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
           Message(asmr_e_invalid_operand_type);
           Message(asmr_e_invalid_operand_type);
-        BuildConstSymbolExpression(true,false,false,l,tempstr,tempsymtyp,isseg,is_farproc_entry);
+        BuildConstSymbolExpression(true,false,false,l,tempstr,tempsymtyp,isseg,is_farproc_entry,hasofs);
 {$ifdef i8086}
 {$ifdef i8086}
         if tempstr='@DATA' then
         if tempstr='@DATA' then
           begin
           begin
@@ -2412,8 +2410,7 @@ Unit Rax86int;
         asmsym,
         asmsym,
         expr: string;
         expr: string;
         value : tcgint;
         value : tcgint;
-        isseg: boolean;
-        is_farproc_entry : boolean;
+        isseg,is_farproc_entry,hasofs : boolean;
       Begin
       Begin
         Repeat
         Repeat
           Case actasmtoken of
           Case actasmtoken of
@@ -2447,7 +2444,7 @@ Unit Rax86int;
 {$endif i8086}
 {$endif i8086}
             AS_ID :
             AS_ID :
               Begin
               Begin
-                BuildConstSymbolExpression(false,false,false,value,asmsym,asmsymtyp,isseg,is_farproc_entry);
+                BuildConstSymbolExpression(false,false,false,value,asmsym,asmsymtyp,isseg,is_farproc_entry,hasofs);
                 if asmsym<>'' then
                 if asmsym<>'' then
                  begin
                  begin
                    if (not isseg) and (constsize<>sizeof(pint)) then
                    if (not isseg) and (constsize<>sizeof(pint)) then