Browse Source

* smartlinking doesn't crash anymore

peter 27 years ago
parent
commit
7c90404c78
3 changed files with 76 additions and 7 deletions
  1. 37 1
      compiler/ag386int.pas
  2. 31 1
      compiler/ag386nsm.pas
  3. 8 5
      compiler/i386.pas

+ 37 - 1
compiler/ag386int.pas

@@ -544,6 +544,39 @@ ait_labeled_instruction : AsmWriteLn(#9#9+int_op2str[pai_labeled(hp)^._operator]
         ait_force_line,
 ait_stab_function_name : ;
 {$endif GDB}
+           ait_cut : begin
+                     { only reset buffer if nothing has changed }
+                       if AsmSize=AsmStartSize then
+                        AsmClear
+                       else
+                        begin
+                          if LastSec<>sec_none then
+                           AsmWriteLn('_'+ait_section2masmstr[LastSec]+#9#9'ENDS');
+                          AsmLn;
+                          AsmWriteLn(#9'END');
+                          AsmClose;
+                          DoAssemble;
+                          if pai_cut(hp)^.EndName then
+                           IsEndFile:=true;
+                          AsmCreate;
+                        end;
+                     { avoid empty files }
+                       while assigned(hp^.next) and (pai(hp^.next)^.typ in [ait_cut,ait_section,ait_comment]) do
+                        begin
+                          if pai(hp^.next)^.typ=ait_section then
+                           begin
+                             lastsec:=pai_section(hp^.next)^.sec;
+                           end;
+                          hp:=pai(hp^.next);
+                        end;
+                       AsmWriteLn(#9'.386p');
+                       AsmWriteLn(#9'LOCALS '+target_asm.labelprefix);
+                       if lastsec<>sec_none then
+                          AsmWriteLn('_'+ait_section2masmstr[lastsec]+#9#9+
+                                     'SEGMENT'#9'PARA PUBLIC USE32 '''+
+                                     ait_section2masmstr[lastsec]+'''');
+                       AsmStartSize:=AsmSize;
+                     end;
              ait_marker: ;
          else
           internalerror(10000);
@@ -591,7 +624,10 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.23  1998-12-16 00:27:17  peter
+  Revision 1.24  1998-12-20 16:21:22  peter
+    * smartlinking doesn't crash anymore
+
+  Revision 1.23  1998/12/16 00:27:17  peter
     * removed some obsolete version checks
 
   Revision 1.22  1998/12/01 11:19:38  peter

+ 31 - 1
compiler/ag386nsm.pas

@@ -239,6 +239,7 @@ unit ag386nsm;
 
     var
       LastSec : tsection;
+      lastsecidx : longint;
 
     const
       ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
@@ -539,6 +540,32 @@ ait_labeled_instruction :
         ait_force_line,
 ait_stab_function_name : ;
 {$endif GDB}
+           ait_cut : begin
+                     { only reset buffer if nothing has changed }
+                       if AsmSize=AsmStartSize then
+                        AsmClear
+                       else
+                        begin
+                          AsmClose;
+                          DoAssemble;
+                          if pai_cut(hp)^.EndName then
+                           IsEndFile:=true;
+                          AsmCreate;
+                        end;
+                     { avoid empty files }
+                       while assigned(hp^.next) and (pai(hp^.next)^.typ in [ait_cut,ait_section,ait_comment]) do
+                        begin
+                          if pai(hp^.next)^.typ=ait_section then
+                           begin
+                             lastsec:=pai_section(hp^.next)^.sec;
+                             lastsecidx:=pai_section(hp^.next)^.idataidx;
+                           end;
+                          hp:=pai(hp^.next);
+                        end;
+                       if lastsec<>sec_none then
+                         AsmWriteLn('SECTION '+ait_section2nasmstr[lastsec]);
+                       AsmStartSize:=AsmSize;
+                     end;
         ait_marker : ;
          else
           internalerror(10000);
@@ -580,7 +607,10 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.16  1998-12-16 00:27:18  peter
+  Revision 1.17  1998-12-20 16:21:23  peter
+    * smartlinking doesn't crash anymore
+
+  Revision 1.16  1998/12/16 00:27:18  peter
     * removed some obsolete version checks
 
   Revision 1.15  1998/12/01 11:19:39  peter

+ 8 - 5
compiler/i386.pas

@@ -26,9 +26,9 @@ unit i386;
 
   { We Don't need the intel style opcodes if we don't have a intel
     reader or generator (PFV) }
-  {$ifndef NORA386INT}
-    {$ifndef NOAG386NSM}
-      {$ifndef NOAG386INT}
+  {$ifdef NORA386INT}
+    {$ifdef NOAG386NSM}
+      {$ifdef NOAG386INT}
         {$define NOINTOP}
       {$endif}
     {$endif}
@@ -1010,7 +1010,7 @@ unit i386;
         '%mm0','%mm1','%mm2','%mm3',
         '%mm4','%mm5','%mm6','%mm7');
 
-{$ifdef NOINTOP}
+{$ifndef NOINTOP}
       int_op2str : array[firstop..lastop] of string[9] =
        ('mov','movzx','movsx','','add',
         'call','idiv','imul','jmp','lea','mul','neg','not',
@@ -1769,7 +1769,10 @@ unit i386;
 end.
 {
   $Log$
-  Revision 1.23  1998-12-19 00:23:49  florian
+  Revision 1.24  1998-12-20 16:21:24  peter
+    * smartlinking doesn't crash anymore
+
+  Revision 1.23  1998/12/19 00:23:49  florian
     * ansistring memory leaks fixed
 
   Revision 1.22  1998/12/18 17:24:51  peter