Browse Source

+ support far calls and jumps in the internal asm writer

git-svn-id: trunk@30601 -
nickysn 10 years ago
parent
commit
955c29618a
1 changed files with 31 additions and 2 deletions
  1. 31 2
      compiler/x86/aasmcpu.pas

+ 31 - 2
compiler/x86/aasmcpu.pas

@@ -1242,7 +1242,10 @@ implementation
                         end
                         end
                       else
                       else
 {$ifdef i8086}
 {$ifdef i8086}
-                        ot:=OT_IMM16 or OT_NEAR;
+                        if opsize=S_FAR then
+                          ot:=OT_IMM16 or OT_FAR
+                        else
+                          ot:=OT_IMM16 or OT_NEAR;
 {$else i8086}
 {$else i8086}
                         ot:=OT_IMM32 or OT_NEAR;
                         ot:=OT_IMM32 or OT_NEAR;
 {$endif i8086}
 {$endif i8086}
@@ -1359,6 +1362,9 @@ implementation
            if ((insot and OT_SIZE_MASK)<>0) and
            if ((insot and OT_SIZE_MASK)<>0) and
               ((insot and currot and OT_SIZE_MASK)<>(currot and OT_SIZE_MASK)) then
               ((insot and currot and OT_SIZE_MASK)<>(currot and OT_SIZE_MASK)) then
              exit;
              exit;
+           { "far" matches only with "far" }
+           if (insot and OT_FAR)<>(currot and OT_FAR) then
+             exit;
          end;
          end;
 
 
         { Check operand sizes }
         { Check operand sizes }
@@ -1417,6 +1423,8 @@ implementation
                    ((currot and OT_IMMEDIATE)=0) and
                    ((currot and OT_IMMEDIATE)=0) and
                     (((insot and OT_SIZE_MASK) or siz[i])<(currot and OT_SIZE_MASK)) then
                     (((insot and OT_SIZE_MASK) or siz[i])<(currot and OT_SIZE_MASK)) then
                   exit;
                   exit;
+                if (insot and OT_FAR)<>(currot and OT_FAR) then
+                  exit;
               end;
               end;
           end;
           end;
 
 
@@ -2249,10 +2257,14 @@ implementation
               inc(len,2);
               inc(len,2);
             &34,&35,&36:
             &34,&35,&36:
               begin
               begin
+{$ifdef i8086}
+                inc(len,2);
+{$else i8086}
                 if opsize=S_Q then
                 if opsize=S_Q then
                   inc(len,8)
                   inc(len,8)
                 else
                 else
                   inc(len,4);
                   inc(len,4);
+{$endif i8086}
               end;
               end;
             &44,&45,&46:
             &44,&45,&46:
               inc(len,sizeof(pint));
               inc(len,sizeof(pint));
@@ -2881,6 +2893,12 @@ implementation
                     on address size, *not* operand size. Works by coincidence only. }
                     on address size, *not* operand size. Works by coincidence only. }
               begin
               begin
                 getvalsym(c-&34);
                 getvalsym(c-&34);
+{$ifdef i8086}
+                if assigned(currsym) then
+                  objdata_writereloc(currval,2,currsym,currabsreloc)
+                else
+                  objdata.writebytes(currval,2);
+{$else i8086}
                 if opsize=S_Q then
                 if opsize=S_Q then
                   begin
                   begin
                     if assigned(currsym) then
                     if assigned(currsym) then
@@ -2895,6 +2913,7 @@ implementation
                     else
                     else
                       objdata.writebytes(currval,4);
                       objdata.writebytes(currval,4);
                   end
                   end
+{$endif i8086}
               end;
               end;
             &40,&41,&42 :    // 040..042
             &40,&41,&42 :    // 040..042
               begin
               begin
@@ -3122,7 +3141,17 @@ implementation
                    else Internalerror(2014032008);
                    else Internalerror(2014032008);
                  end;
                  end;
             &370..&372: ; // VEX flags =>> nothing todo
             &370..&372: ; // VEX flags =>> nothing todo
-            &37,
+            &37:
+              begin
+{$ifdef i8086}
+                if assigned(currsym) then
+                  objdata_writereloc(0,2,currsym,RELOC_SEG)
+                else
+                  InternalError(2015041503);
+{$else i8086}
+                InternalError(777006);
+{$endif i8086}
+              end;
             &60,&61,&62 :
             &60,&61,&62 :
               begin
               begin
                 InternalError(777006);
                 InternalError(777006);