Browse Source

* translate opr_symbol to reference for lea

peter 26 years ago
parent
commit
f9b4da4d85
1 changed files with 35 additions and 20 deletions
  1. 35 20
      compiler/ra386.pas

+ 35 - 20
compiler/ra386.pas

@@ -164,6 +164,8 @@ procedure AddReferenceSizes(var instr:TInstruction);
   operand is a register }
   operand is a register }
 var
 var
   operand2,i : longint;
   operand2,i : longint;
+  s : pasmsymbol;
+  so : longint;
 begin
 begin
   with instr do
   with instr do
    begin
    begin
@@ -171,25 +173,35 @@ begin
       if (operands[i].size=S_NO) then
       if (operands[i].size=S_NO) then
        begin
        begin
          case operands[i].operandtype of
          case operands[i].operandtype of
-          OPR_REFERENCE :
-            begin
-              if i=2 then
-               operand2:=1
-              else
-               operand2:=2;
-              { Only allow register as operand to take the size from }
-              if operands[operand2].operandtype=OPR_REGISTER then
-               operands[i].size:=operands[operand2].size
-              else
-               begin
-                 { if no register then take the opsize (which is available with ATT) }
-                 operands[i].size:=opsize;
-               end;
-            end;
-          OPR_SYMBOL :
-            begin
-              operands[i].size:=S_L;
-            end;
+           OPR_REFERENCE :
+             begin
+               if i=2 then
+                operand2:=1
+               else
+                operand2:=2;
+               { Only allow register as operand to take the size from }
+               if operands[operand2].operandtype=OPR_REGISTER then
+                operands[i].size:=operands[operand2].size
+               else
+                begin
+                  { if no register then take the opsize (which is available with ATT) }
+                  operands[i].size:=opsize;
+                end;
+             end;
+           OPR_SYMBOL :
+             begin
+               { Fix lea which need a reference }
+               if opcode=A_LEA then
+                begin
+                  s:=operands[i].symbol;
+                  so:=operands[i].symofs;
+                  operands[i].operandtype:=OPR_REFERENCE;
+                  reset_reference(operands[i].ref);
+                  operands[i].ref.symbol:=s;
+                  operands[i].ref.offset:=so;
+                end;
+               operands[i].size:=S_L;
+             end;
          end;
          end;
        end;
        end;
    end;
    end;
@@ -381,7 +393,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  1999-05-01 13:24:40  peter
+  Revision 1.2  1999-05-02 14:24:26  peter
+    * translate opr_symbol to reference for lea
+
+  Revision 1.1  1999/05/01 13:24:40  peter
     * merged nasm compiler
     * merged nasm compiler
     * old asm moved to oldasm/
     * old asm moved to oldasm/