Browse Source

* never use the 66h prefix when pushing/popping segment registers on i8086, as the stack is aligned on 2 bytes there

git-svn-id: trunk@24729 -
nickysn 12 years ago
parent
commit
e243b6b869
3 changed files with 12 additions and 10 deletions
  1. 8 8
      compiler/i8086/cgcpu.pas
  2. 2 0
      compiler/x86/agx86nsm.pas
  3. 2 2
      compiler/x86/cgx86.pas

+ 8 - 8
compiler/i8086/cgcpu.pas

@@ -349,7 +349,7 @@ unit cgcpu;
         if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
           begin
             list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_L,NR_ES));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
             tmpref.segment:=NR_ES;
           end;
 
@@ -501,7 +501,7 @@ unit cgcpu;
         if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
           begin
             list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_L,NR_ES));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
             tmpref.segment:=NR_ES;
           end;
 
@@ -539,7 +539,7 @@ unit cgcpu;
         if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
           begin
             list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_L,NR_ES));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
             tmpref.segment:=NR_ES;
           end;
 
@@ -856,7 +856,7 @@ unit cgcpu;
         if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
           begin
             list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_L,NR_ES));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
             tmpref.segment:=NR_ES;
           end;
 
@@ -885,7 +885,7 @@ unit cgcpu;
         if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
           begin
             list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_L,NR_ES));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
             tmpref.segment:=NR_ES;
           end;
 
@@ -976,7 +976,7 @@ unit cgcpu;
         if (tmpref.segment<>NR_NO) and (not is_segment_reg(tmpref.segment)) then
           begin
             list.concat(taicpu.op_reg(A_PUSH,S_W,tmpref.segment));
-            list.concat(taicpu.op_reg(A_POP,S_L,NR_ES));
+            list.concat(taicpu.op_reg(A_POP,S_W,NR_ES));
             tmpref.segment:=NR_ES;
           end;
 
@@ -1247,8 +1247,8 @@ unit cgcpu;
         { return from interrupt }
         if po_interrupt in current_procinfo.procdef.procoptions then
           begin
-            list.concat(Taicpu.Op_reg(A_POP,S_L,NR_ES));
-            list.concat(Taicpu.Op_reg(A_POP,S_L,NR_DS));
+            list.concat(Taicpu.Op_reg(A_POP,S_W,NR_ES));
+            list.concat(Taicpu.Op_reg(A_POP,S_W,NR_DS));
             list.concat(Taicpu.Op_reg(A_POP,S_W,NR_DI));
             list.concat(Taicpu.Op_reg(A_POP,S_W,NR_SI));
             list.concat(Taicpu.Op_reg(A_POP,S_W,NR_DX));

+ 2 - 0
compiler/x86/agx86nsm.pas

@@ -914,6 +914,7 @@ interface
                 AsmWriteln(#9#9'DB'#9'09bh')
                else
                 begin
+{$ifndef i8086}
                   { We need to explicitely set
                     word prefix to get selectors
                     to be pushed in 2 bytes  PM }
@@ -923,6 +924,7 @@ interface
                       (taicpu(hp).oper[0]^.typ=top_reg) and
                       (is_segment_reg(taicpu(hp).oper[0]^.reg)) then
                     AsmWriteln(#9#9'DB'#9'066h');
+{$endif not i8086}
                   AsmWrite(#9#9+std_op2str[fixed_opcode]+cond2str[taicpu(hp).condition]);
                   if taicpu(hp).ops<>0 then
                    begin

+ 2 - 2
compiler/x86/cgx86.pas

@@ -2226,8 +2226,8 @@ unit cgx86;
             list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_DX));
             list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_SI));
             list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_DI));
-            list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_DS));
-            list.concat(Taicpu.Op_reg(A_PUSH,S_L,NR_ES));
+            list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_DS));
+            list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_ES));
             reference_reset(dgroup,0);
             dgroup.refaddr:=addr_dgroup;
             list.concat(Taicpu.Op_ref_reg(A_MOV,S_W,dgroup,NR_AX));