Bläddra i källkod

* undid some changes of Peter that made the compiler wrong
for m68k (I had to reinsert some ifdefs)
* removed several memory leaks under m68k
* removed the meory leaks for assembler readers
* cross compiling shoud work again better
( crosscompiling sysamiga works
but as68k still complain about some code !)

pierre 27 år sedan
förälder
incheckning
c3b3abdb65

+ 26 - 1
compiler/asmutils.pas

@@ -155,6 +155,7 @@ Type
       { the size of the instruction.                                    }
       stropsize: topsize;
       procedure init;
+      procedure done;
       { sets up the prefix field with the instruction pointed to in s }
       procedure addprefix(tok: tasmop);
       { sets up the instruction with the instruction pointed to in s }
@@ -798,6 +799,21 @@ end;
    getprefix := prefix;
  end;
 
+ Procedure TInstruction.done;
+ var
+  k: integer;
+ Begin
+  for k:=1 to numops do
+    begin
+       if (operands[k].operandtype=OPR_REFERENCE) and
+          assigned(operands[k].ref.symbol) then
+            stringdispose(operands[k].ref.symbol);
+       if (operands[k].operandtype=OPR_SYMBOL) and
+          assigned(operands[k].symbol) then
+            stringdispose(operands[k].symbol);
+    end;
+ end;
+ 
 {*************************************************************************}
 {                          Local label utilities                          }
 {*************************************************************************}
@@ -1869,7 +1885,16 @@ end;
 end.
 {
   $Log$
-  Revision 1.10  1998-10-13 13:10:10  peter
+  Revision 1.11  1998-10-13 16:49:59  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.10  1998/10/13 13:10:10  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.9  1998/09/24 17:54:15  carl

+ 16 - 2
compiler/assemble.pas

@@ -119,7 +119,12 @@ Function DoPipe:boolean;
 begin
   DoPipe:=(cs_asm_pipe in aktglobalswitches) and
           not(cs_asm_leave in aktglobalswitches)
-          and (aktoutputformat in [as_i386_o,as_m68k_o]);
+{$ifdef i386}
+          and (aktoutputformat=as_i386_o)
+{$endif i386}
+{$ifdef m68k}
+          and (aktoutputformat=as_m68k_o);
+{$endif m68k}
 end;
 
 
@@ -471,7 +476,16 @@ end;
 end.
 {
   $Log$
-  Revision 1.26  1998-10-13 13:10:11  peter
+  Revision 1.27  1998-10-13 16:50:01  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.26  1998/10/13 13:10:11  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.25  1998/10/13 08:19:24  pierre

+ 12 - 1
compiler/cg386inl.pas

@@ -552,6 +552,8 @@ implementation
                       emitcall('FPC_ASSERT',true);
                       emitl(A_LABEL,truelabel);
                    end;
+                 freelabel(truelabel);
+                 freelabel(falselabel);
                  truelabel:=otlabel;
                  falselabel:=oflabel;
               end;
@@ -939,7 +941,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.12  1998-10-08 17:17:12  pierre
+  Revision 1.13  1998-10-13 16:50:02  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.12  1998/10/08 17:17:12  pierre
     * current_module old scanner tagged as invalid if unit is recompiled
     + added ppheap for better info on tracegetmem of heaptrc
       (adds line column and file index)

+ 12 - 1
compiler/cg68kadd.pas

@@ -1242,12 +1242,14 @@ implementation
                                      gtn : flags := F_G;
                                      gten: flags := F_GE;
                                  end;
+                             clear_location(p^.location);
                              p^.location.loc := LOC_FLAGS;
                              p^.location.resflags := flags;
                              cmpop := false;
                           end
                          else
                          begin
+                             clear_location(p^.location);
                              p^.location.loc := LOC_FPU;
                              if p^.left^.location.loc = LOC_FPU then
                              { copy fpu register result . }
@@ -1270,7 +1272,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.9  1998-10-13 08:19:25  pierre
+  Revision 1.10  1998-10-13 16:50:03  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.9  1998/10/13 08:19:25  pierre
     + source_os is now set correctly for cross-processor compilers
       (tos contains all target_infos and
        we use CPU86 and CPU68 conditionnals to

+ 12 - 3
compiler/cg68kcal.pas

@@ -884,7 +884,7 @@ implementation
                          new(ref);
                          reset_reference(ref^);
                          ref^.base := R_A1;
-                         exprasmlist^.concat(new(pai68k,op_ref(A_JSR,S_NO,newreference(ref^))));
+                         exprasmlist^.concat(new(pai68k,op_ref(A_JSR,S_NO,ref)));
                        end
                        else
                        begin
@@ -893,7 +893,7 @@ implementation
                          new(ref);
                          reset_reference(ref^);
                          ref^.base := R_A1;
-                         exprasmlist^.concat(new(pai68k,op_ref(A_JSR,S_NO,newreference(ref^))));
+                         exprasmlist^.concat(new(pai68k,op_ref(A_JSR,S_NO,ref)));
                        end;
                        del_reference(p^.right^.location.reference);
                     end;
@@ -1047,7 +1047,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.7  1998-10-13 08:19:27  pierre
+  Revision 1.8  1998-10-13 16:50:04  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.7  1998/10/13 08:19:27  pierre
     + source_os is now set correctly for cross-processor compilers
       (tos contains all target_infos and
        we use CPU86 and CPU68 conditionnals to

+ 31 - 2
compiler/cg68kcnv.pas

@@ -255,7 +255,8 @@ implementation
 
               emit_bounds_check(hpp^, hregister);
               end;
-               p^.location.loc:=LOC_REGISTER;
+              clear_location(p^.location);
+              p^.location.loc:=LOC_REGISTER;
               p^.location.register:=hregister;
               exit;
            end
@@ -275,6 +276,7 @@ implementation
                      hregister:=getregister32;
                      exprasmlist^.concat(new(pai68k,op_ref_reg(A_MOVE,S_L,newreference(hp^.location.reference),hregister)));
                  end;
+              clear_location(p^.location);
               p^.location.loc:=LOC_REGISTER;
               p^.location.register:=hregister;
               exit;
@@ -435,6 +437,7 @@ implementation
               end;
          end; { end elseif }
 
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          p^.location.register:=hregister;
          maybe_rangechecking(p,p^.left^.resulttype,p^.resulttype);
@@ -598,6 +601,7 @@ implementation
     procedure second_cstring_charpointer(p,hp : ptree;convtyp : tconverttype);
 
       begin
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          p^.location.register:=getregister32;
          inc(p^.left^.location.reference.offset);
@@ -616,6 +620,7 @@ implementation
 
       begin
          del_reference(p^.left^.location.reference);
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          p^.location.register:=getregister32;
          exprasmlist^.concat(new(pai68k,op_ref_reg(A_LEA,S_L,newreference(p^.left^.location.reference),
@@ -627,6 +632,7 @@ implementation
       var
        reg: tregister;
       begin
+         clear_location(p^.location);
          p^.location.loc:=LOC_REFERENCE;
          clear_reference(p^.location.reference);
          { here, after doing some arithmetic on the pointer }
@@ -669,6 +675,7 @@ implementation
       begin
          { this is a type conversion which copies the data, so we can't }
          { return a reference                                             }
+         clear_location(p^.location);
          p^.location.loc:=LOC_MEM;
 
          { first get the memory for the string }
@@ -707,6 +714,9 @@ implementation
          p^.left:=p;
          loadstring(p);
          p^.left:=nil; { reset left tree, which is empty }
+         { p^.right is not disposed for typeconv !! PM }
+         disposetree(p^.right);
+         p^.right:=nil;
       end;
 
     procedure second_int_real(p,hp : ptree;convtyp : tconverttype);
@@ -790,6 +800,7 @@ implementation
              exprasmlist^.concat(new(pai68k,op_reg_reg(A_FMOVE,S_L,p^.left^.location.fpureg,rreg)));
            end;
          end;
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          p^.location.register:=rreg;
       end;
@@ -933,6 +944,7 @@ implementation
 
          if (cs_fp_emulation in aktmoduleswitches) then
          begin
+           clear_location(p^.location);
            p^.location.loc:=LOC_FPU;
            p^.location.fpureg := getregister32;
            exprasmlist^.concat(new(pai68k,op_ref_reg(A_MOVE,S_L,newreference(r),
@@ -940,6 +952,7 @@ implementation
          end
          else
          begin
+           clear_location(p^.location);
            p^.location.loc:=LOC_FPU;
            p^.location.fpureg := getfloatreg;
            exprasmlist^.concat(new(pai68k,op_ref_reg(A_FMOVE,S_L,newreference(r),
@@ -1002,6 +1015,7 @@ implementation
          exprasmlist^.concat(new(pai68k,op_const_reg(A_MOVEQ,S_L,16,R_D1)));
          exprasmlist^.concat(new(pai68k,op_reg_reg(A_LSL,S_L,R_D1,hregister)));
 
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          p^.location.register:=hregister;
       end;
@@ -1011,6 +1025,7 @@ implementation
 
      begin
         secondpass(hp);
+        clear_location(p^.location);
         p^.location.loc:=LOC_REGISTER;
         del_reference(hp^.location.reference);
         p^.location.register:=getregister32;
@@ -1034,6 +1049,7 @@ implementation
          getlabel(truelabel);
          getlabel(falselabel);
          secondpass(hp);
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          del_reference(hp^.location.reference);
          hregister:=getregister32;
@@ -1133,6 +1149,7 @@ implementation
      var
         hregister : tregister;
      begin
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          del_reference(hp^.location.reference);
          case hp^.location.loc of
@@ -1182,6 +1199,7 @@ implementation
         emitcall('FPC_SET_LOAD_SMALL',true);
         maybe_loada5;
         popusedregisters(pushedregs);
+        clear_location(p^.location);
         p^.location.loc:=LOC_MEM;
         stringdispose(p^.location.reference.symbol);
         p^.location.reference:=href;
@@ -1197,6 +1215,7 @@ implementation
         InternalError(342132);
 {!!!!!!!!!!!
 
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          getlabel(l1);
          getlabel(l2);
@@ -1305,6 +1324,7 @@ implementation
          { save all used registers }
          pushusedregisters(pushed,$ffff);
          secondpass(p^.left);
+         clear_location(p^.location);
          p^.location.loc:=LOC_FLAGS;
          p^.location.resflags:=F_NE;
 
@@ -1374,7 +1394,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.6  1998-10-06 20:48:56  peter
+  Revision 1.7  1998-10-13 16:50:06  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.6  1998/10/06 20:48:56  peter
     * m68k compiler compiles again
 
   Revision 1.5  1998/09/17 09:42:23  peter

+ 19 - 1
compiler/cg68kflw.pas

@@ -112,6 +112,8 @@ implementation
               truelabel:=otlabel;
               falselabel:=oflabel;
            end;
+         freelabel(l1);
+         freelabel(l2);
          aktcontinuelabel:=oldclabel;
          aktbreaklabel:=oldblabel;
       end;
@@ -157,6 +159,8 @@ implementation
            emitl(A_LABEL,falselabel);
          if not(assigned(p^.right)) then
            emitl(A_LABEL,truelabel);
+         freelabel(truelabel);
+         freelabel(falselabel);
          truelabel:=otlabel;
          falselabel:=oflabel;
       end;
@@ -357,6 +361,9 @@ implementation
          if temptovalue then
            ungetiftemp(temp1);
 
+         freelabel(aktcontinuelabel);
+         freelabel(aktbreaklabel);
+         freelabel(l3);
          aktcontinuelabel:=oldclabel;
          aktbreaklabel:=oldblabel;
       end;
@@ -479,6 +486,8 @@ implementation
                         end;
               end;
 do_jmp:
+              freelabel(truelabel);
+              freelabel(falselabel);
               truelabel:=otlabel;
               falselabel:=oflabel;
               emitl(A_JMP,aktexit2label);
@@ -769,7 +778,16 @@ do_jmp:
 end.
 {
   $Log$
-  Revision 1.5  1998-09-17 09:42:24  peter
+  Revision 1.6  1998-10-13 16:50:07  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.5  1998/09/17 09:42:24  peter
     + pass_2 for cg386
     * Message() -> CGMessage() for pass_1/pass_2
 

+ 17 - 1
compiler/cg68kinl.pas

@@ -444,6 +444,9 @@ implementation
              exit;
 
            dummycoll.paratyp:=vs_const;
+           disposetree(hp);
+           p^.left:=nil;
+           
            { second arg }
            hp:=node;
            node:=node^.right;
@@ -456,6 +459,7 @@ implementation
                 secondcallparan(hp,@dummycoll,false);
                 if codegenerror then
                   exit;
+                disposetree(hp);
                 hp:=node;
                 node:=node^.right;
                 hp^.right:=nil;
@@ -472,6 +476,7 @@ implementation
                 secondcallparan(hp,@dummycoll,false);
                 if codegenerror then
                   exit;
+                disposetree(hp);
                 hp:=node;
                 node:=node^.right;
                 hp^.right:=nil;
@@ -487,6 +492,8 @@ implementation
            if codegenerror then
              exit;
 
+           disposetree(hp);
+
            if is_real then
              emitcall('FPC_STR_'+float_name[pfloatdef(hp^.resulttype)^.typ],true)
            else if porddef(hp^.resulttype)^.typ=u32bit then
@@ -882,7 +889,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.6  1998-10-06 20:48:58  peter
+  Revision 1.7  1998-10-13 16:50:08  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.6  1998/10/06 20:48:58  peter
     * m68k compiler compiles again
 
   Revision 1.5  1998/09/20 12:26:39  peter

+ 12 - 1
compiler/cg68kmat.pas

@@ -76,6 +76,7 @@ implementation
                   exprasmlist^.concat(new(pai68k,op_ref_reg(A_MOVE,S_L,newreference(p^.left^.location.reference),
                     hreg1)));
                 end;
+              clear_location(p^.left^.location);
               p^.left^.location.loc:=LOC_REGISTER;
               p^.left^.location.register:=hreg1;
            end
@@ -183,6 +184,7 @@ implementation
          { this registers are always used when div/mod are present }
          usedinproc:=usedinproc or ($800 shr word(R_D1));
          usedinproc:=usedinproc or ($800 shr word(R_D0));
+         clear_location(p^.location);
          p^.location.loc:=LOC_REGISTER;
          p^.location.register:=hreg1;
       end;
@@ -446,7 +448,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.2  1998-09-14 10:44:01  peter
+  Revision 1.3  1998-10-13 16:50:10  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.2  1998/09/14 10:44:01  peter
     * all internal RTL functions start with FPC_
 
   Revision 1.1  1998/09/01 09:07:09  peter

+ 17 - 8
compiler/cg68kset.pas

@@ -86,7 +86,7 @@ implementation
          hr : tregister;
          setparts:array[1..8] of Tsetpart;
          i,numparts:byte;
-         href,href2:Treference;
+         {href,href2:Treference;}
          l,l2 : plabel;
          hl,hl1 : plabel;
          hl2, hl3: plabel;
@@ -320,19 +320,19 @@ implementation
                         p^.location.resflags:=F_C
                       else
                         p^.location.resflags:=F_E;
-                      href.symbol := nil;
-                      clear_reference(href);
+                      {href.symbol := nil;
+                      clear_reference(href);}
                       getlabel(l);
-                      href.symbol:=stringdup(lab2str(l));
+                      {href.symbol:=stringdup(lab2str(l));}
                       for i:=1 to numparts do
                           if setparts[i].range then
                              begin
                                   {Check if left is in a range.}
                                   {Get a label to jump over the check.}
-                                  href2.symbol := nil;
-                                  clear_reference(href2);
+                                  {href2.symbol := nil;
+                                  clear_reference(href2);}
                                   getlabel(l2);
-                                  href.symbol:=stringdup(lab2str(l2));
+                                  {href.symbol:=stringdup(lab2str(l2));}
                                   if setparts[i].start=setparts[i].stop-1 then
                                   begin
                                     case p^.left^.location.loc of
@@ -812,7 +812,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.5  1998-09-17 09:42:29  peter
+  Revision 1.6  1998-10-13 16:50:11  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.5  1998/09/17 09:42:29  peter
     + pass_2 for cg386
     * Message() -> CGMessage() for pass_1/pass_2
 

+ 20 - 12
compiler/cga68k.pas

@@ -528,7 +528,6 @@ var hs:string;
     hp:Pused_unit;
     unitinits:taasmoutput;
 {$ifdef GDB}
-    oldaktprocname : string;
     stab_function_name:Pai_stab_function_name;
 {$endif GDB}
 begin
@@ -680,7 +679,6 @@ begin
 {$IfDef GDB}
     if (cs_debuginfo in aktmoduleswitches) and target_os.use_function_relative_addresses then
         stab_function_name := new(pai_stab_function_name,init(strpnew(hs)));
-      oldaktprocname:=aktprocsym^.name;
 {$EndIf GDB}
 
 
@@ -691,19 +689,20 @@ begin
               else
                 procinfo.aktentrycode^.insert(new(pai_symbol,init(hs)));
 {$ifdef GDB}
-            if (cs_debuginfo in aktmoduleswitches) and
-               target_os.use_function_relative_addresses then
-            begin
-            procinfo.aktentrycode^.insert(new(pai_stab_function_name,init(strpnew(hs))));
-              { This is not a nice solution to save the name, change it and restore when done }
-                 aktprocsym^.setname(hs);
-                 procinfo.aktentrycode^.insert(new(pai_stabs,init(aktprocsym^.stabstring)));
-        end;
+            if (cs_debuginfo in aktmoduleswitches) then
+             begin
+               if target_os.use_function_relative_addresses then
+                list^.insert(new(pai_stab_function_name,init(strpnew(hs))));
+
+            { This is not a nice solution to save the name, change it and restore when done }
+            { not only not nice but also completely wrong !!! (PM) }
+            {   aktprocsym^.setname(hs);
+               list^.insert(new(pai_stabs,init(aktprocsym^.stabstring))); }
+             end;
 {$endif GDB}
               hs:=proc_names.get;
         end;
 {$ifdef GDB}
-      aktprocsym^.setname(oldaktprocname);
 
     if (cs_debuginfo in aktmoduleswitches) then
         begin
@@ -1345,7 +1344,16 @@ end;
 end.
 {
   $Log$
-  Revision 1.21  1998-10-13 13:10:12  peter
+  Revision 1.22  1998-10-13 16:50:12  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.21  1998/10/13 13:10:12  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.20  1998/10/13 08:19:29  pierre

+ 30 - 1
compiler/m68k.pas

@@ -357,6 +357,8 @@ type
     { use this only for already used references       }
     procedure clear_reference(var ref : treference);
 
+    procedure disposereference(var r : preference);
+
     function newreference(const r : treference) : preference;
 
     function reg2str(r : tregister) : string;
@@ -876,6 +878,15 @@ type
      reg2str:=a[r];
       end;
 
+    procedure disposereference(var r : preference);
+
+      begin
+         if assigned(r^.symbol) then
+           stringdispose(r^.symbol);
+         dispose(r);
+         r:=nil;
+      end;
+      
     function newreference(const r : treference) : preference;
 
       var
@@ -999,6 +1010,7 @@ type
        begin
           op1t:=top_const;
           op1:=pointer(_op1^.offset);
+          disposereference(_op1);
        end
      else
        begin
@@ -1071,6 +1083,7 @@ type
        begin
           op2t:=top_const;
           op2:=pointer(_op2^.offset);
+          disposereference(_op2);
        end
      else
        begin
@@ -1234,6 +1247,7 @@ type
        begin
           op2t:=top_const;
           op2:=pointer(_op2^.offset);
+          disposereference(_op2);
        end
      else
        begin
@@ -1290,6 +1304,7 @@ type
        begin
           op1t:=top_const;
           op1:=pointer(_op1^.offset);
+          disposereference(_op1);
        end
      else
        begin
@@ -1313,6 +1328,7 @@ type
        begin
           op1t:=top_const;
           op1:=pointer(_op1^.offset);
+          disposereference(_op1);
        end
      else
        begin
@@ -1324,6 +1340,7 @@ type
        begin
           op2t:=top_const;
           op2:=pointer(_op2^.offset);
+          disposereference(_op2);
        end
      else
        begin
@@ -1384,6 +1401,7 @@ type
        begin
           op2t:=top_const;
           op2:=pointer(_op2^.offset);
+          disposereference(_op2);
        end
      else
        begin
@@ -1467,6 +1485,7 @@ type
         begin
            op1t:=top_const;
            op1:=pointer(_op1^.offset);
+           disposereference(_op1);
         end
       else
         begin
@@ -1494,6 +1513,7 @@ type
         begin
            op2t:=top_const;
            op2:=pointer(_op2^.offset);
+           disposereference(_op2);
         end
       else
         begin
@@ -1573,7 +1593,16 @@ type
 end.
 {
   $Log$
-  Revision 1.7  1998-08-31 12:26:27  peter
+  Revision 1.8  1998-10-13 16:50:15  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.7  1998/08/31 12:26:27  peter
     * m68k and palmos updates from surebugfixes
 
   Revision 1.6  1998/08/21 14:08:44  pierre

+ 11 - 1
compiler/ra386att.pas

@@ -3781,6 +3781,7 @@ const
                      ConcatLabeledInstr(instr)
                    else
                      ConcatOpCode(instr);
+                   instr.done;
                   end;
         AS_SEPARATOR:Begin
                      Consume(AS_SEPARATOR);
@@ -3843,7 +3844,16 @@ end.
 
 {
   $Log$
-  Revision 1.14  1998-10-07 04:28:52  carl
+  Revision 1.15  1998-10-13 16:50:16  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.14  1998/10/07 04:28:52  carl
     * bugfix of in/out with gas (ins/outs still left though)
     * bugfix of wrong error output with concatlabel
     * gettoken always returns something valid now

+ 11 - 1
compiler/ra386int.pas

@@ -3338,6 +3338,7 @@ var
                      ConcatLabeledInstr(instr)
                    else
                      ConcatOpCode(instr);
+                   instr.done;
                   end;
         AS_SEPARATOR:Begin
                      Consume(AS_SEPARATOR);
@@ -3394,7 +3395,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.8  1998-10-07 04:29:44  carl
+  Revision 1.9  1998-10-13 16:50:17  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.8  1998/10/07 04:29:44  carl
     * Concatlabel now gives output on error
     * in/out bugfix (still ins/outs left to fix)
 

+ 11 - 1
compiler/ra68kmot.pas

@@ -2128,6 +2128,7 @@ var
                      ConcatLabeledInstr(instr)
                    else
                      ConcatOpCode(instr);
+                   instr.done;
                   end;
         AS_SEPARATOR:Begin
                      Consume(AS_SEPARATOR);
@@ -2177,7 +2178,16 @@ Begin
 end.
 {
   $Log$
-  Revision 1.5  1998-08-10 14:50:23  peter
+  Revision 1.6  1998-10-13 16:50:19  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.5  1998/08/10 14:50:23  peter
     + localswitches, moduleswitches, globalswitches splitting
 
   Revision 1.4  1998/07/14 14:47:02  peter

+ 12 - 1
compiler/scandir.inc

@@ -723,11 +723,13 @@ const
 
     procedure dir_oldasmmode(t:tdirectivetoken);
       begin
+{$ifdef i386}
         case t of
          _DIR_I386_ATT    : aktasmmode:=asmmode_i386_att;
          _DIR_I386_DIRECT : aktasmmode:=asmmode_i386_direct;
          _DIR_I386_INTEL  : aktasmmode:=asmmode_i386_intel;
         end;
+{$endif i386}
       end;
 
 
@@ -942,7 +944,16 @@ const
 
 {
   $Log$
-  Revision 1.38  1998-10-13 13:10:28  peter
+  Revision 1.39  1998-10-13 16:50:21  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.38  1998/10/13 13:10:28  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.37  1998/10/08 23:29:04  peter

+ 22 - 4
compiler/switches.pas

@@ -92,9 +92,18 @@ begin
                    else
                     aktlocalswitches:=aktlocalswitches-[tlocalswitch(setsw)];
                  { Message for linux which has global checking only }
-                   if (switch='S') and
-                      (target_info.target in [target_i386_linux,target_m68k_linux]) then
-                     Message(scan_n_stack_check_global_under_linux);
+                   if (switch='S') and (
+{$ifdef i386}
+                      (target_info.target = target_i386_linux)
+{$ifdef m68k}
+                        or
+{$endif m68k}
+{$endif i386}
+{$ifdef m68k}
+                      (target_info.target = target_m68k_linux)
+{$endif m68k}
+                       ) then
+                       Message(scan_n_stack_check_global_under_linux);
                  end;
       modulesw : begin
                    if current_module^.in_global then
@@ -155,7 +164,16 @@ end;
 end.
 {
   $Log$
-  Revision 1.15  1998-10-13 13:10:29  peter
+  Revision 1.16  1998-10-13 16:50:22  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.15  1998/10/13 13:10:29  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.14  1998/10/13 08:19:41  pierre

+ 106 - 75
compiler/systems.pas

@@ -39,58 +39,82 @@ unit systems;
 
 
      type
-       tasmmode= (
-            asmmode_i386_direct,asmmode_i386_att,asmmode_i386_intel,
-            asmmode_m68k_mot
+       tasmmode= (asmmode_none
+{$ifdef i386}
+            ,asmmode_i386_direct,asmmode_i386_att,asmmode_i386_intel
+{$endif i386}
+{$ifdef m68k}
+            ,asmmode_m68k_mot
+{$endif m68k}
        );
      const
        {$ifdef i386} i386asmmodecnt=3; {$else} i386asmmodecnt=0; {$endif}
        {$ifdef m68k} m68kasmmodecnt=1; {$else} m68kasmmodecnt=0; {$endif}
-
+       asmmodecnt=i386asmmodecnt+m68kasmmodecnt+1;
 
      type
-       ttarget = (
-            target_i386_GO32V1,target_i386_GO32V2,target_i386_linux,
-            target_i386_OS2,target_i386_Win32,
-            target_m68k_Amiga,target_m68k_Atari,target_m68k_Mac,
+       ttarget = (target_none
+{$ifdef i386}
+            ,target_i386_GO32V1,target_i386_GO32V2,target_i386_linux,
+            target_i386_OS2,target_i386_Win32
+{$endif i386}
+            ,target_m68k_Amiga,target_m68k_Atari,target_m68k_Mac,
             target_m68k_linux,target_m68k_PalmOS
+{$ifndef i386}
+            ,target_i386_GO32V1,target_i386_GO32V2,target_i386_linux,
+            target_i386_OS2,target_i386_Win32
+{$endif i386}
        );
      const
        {$ifdef i386} i386targetcnt=5; {$else} i386targetcnt=0; {$endif}
        {$ifdef m68k} m68ktargetcnt=5; {$else} m68ktargetcnt=0; {$endif}
-
+       targetcnt=i386targetcnt+m68ktargetcnt+1;
 
      type
-       tasm = (
-            as_i386_o,as_i386_o_aout,as_i386_asw,as_i386_nasmcoff,as_i386_nasmelf,as_i386_nasmobj,
-            as_i386_tasm,as_i386_masm,
-            as_m68k_o,as_m68k_gas,as_m68k_mit,as_m68k_mot,as_m68k_mpw
+       tasm = (as_none
+{$ifdef i386}
+            ,as_i386_o,as_i386_o_aout,as_i386_asw,
+            as_i386_nasmcoff,as_i386_nasmelf,as_i386_nasmobj,
+            as_i386_tasm,as_i386_masm
+{$endif i386}
+{$ifdef m68k}
+            ,as_m68k_o,as_m68k_gas,as_m68k_mit,as_m68k_mot,as_m68k_mpw
+{$endif m68k}
        );
      const
        {$ifdef i386} i386asmcnt=8; {$else} i386asmcnt=0; {$endif}
        {$ifdef m68k} m68kasmcnt=5; {$else} m68kasmcnt=0; {$endif}
-
+       asmcnt=i386asmcnt+m68kasmcnt+1;
 
      type
-       tlink = (
-            link_i386_ld,link_i386_ldgo32v1,link_i386_ldgo32v2,link_i386_ldw,
-            link_i386_ldos2,
-            link_m68k_ld
+       tlink = (link_none
+{$ifdef i386}
+            ,link_i386_ld,link_i386_ldgo32v1,
+            link_i386_ldgo32v2,link_i386_ldw,
+            link_i386_ldos2
+{$endif i386}
+{$ifdef m68k}
+            ,link_m68k_ld
+{$endif m68k}
        );
      const
        {$ifdef i386} i386linkcnt=5; {$else} i386linkcnt=0; {$endif}
        {$ifdef m68k} m68klinkcnt=1; {$else} m68klinkcnt=0; {$endif}
-
+       linkcnt=i386linkcnt+m68klinkcnt+1;
 
      type
-       tar = (
-            ar_i386_ar,ar_i386_arw,
-            ar_m68k_ar
+       tar = (ar_none
+{$ifdef i386}
+            ,ar_i386_ar,ar_i386_arw
+{$endif i386}
+{$ifdef m68k}
+            ,ar_m68k_ar
+{$endif m68k}
        );
      const
        {$ifdef i386} i386arcnt=2; {$else} i386arcnt=0; {$endif}
        {$ifdef m68k} m68karcnt=1; {$else} m68karcnt=0; {$endif}
-
+       arcnt=i386arcnt+m68karcnt+1;
 
      type
        tos = (
@@ -100,9 +124,9 @@ unit systems;
             os_m68k_PalmOS
        );
      const
-       {$ifdef i386} i386oscnt=5; {$else} i386oscnt=0; {$endif}
-       {$ifdef m68k} m68koscnt=5; {$else} m68koscnt=0; {$endif}
-
+       i386oscnt=5;
+       m68koscnt=5;
+       oscnt=i386oscnt+m68koscnt;
 
    type
        tosinfo = packed record
@@ -203,8 +227,7 @@ implementation
 {****************************************************************************
                                  OS Info
 ****************************************************************************}
-       os_infos : array[1..i386oscnt+m68koscnt] of tosinfo = (
-{$ifdef i386}
+       os_infos : array[1..oscnt] of tosinfo = (
           (
             id           : os_i386_go32v1;
             name         : 'GO32 V1 DOS extender';
@@ -279,12 +302,7 @@ implementation
             newline      : #13#10;
             endian       : endian_little;
             use_function_relative_addresses : true
-          )
-      {$ifdef m68k}
-          ,
-      {$endif m68k}
-{$endif i386}
-{$ifdef m68k}
+          ),
           (
             id           : os_m68k_amiga;
             name         : 'Commodore Amiga';
@@ -360,7 +378,6 @@ implementation
             endian       : endian_big;
             use_function_relative_addresses : false
           )
-{$endif m68k}
           );
 
 
@@ -368,9 +385,13 @@ implementation
                              Assembler Info
 ****************************************************************************}
 
-       as_infos : array[1..i386asmcnt+m68kasmcnt] of tasminfo = (
-{$ifdef i386}
+       as_infos : array[1..asmcnt] of tasminfo = (
           (
+            id     : as_none;
+            idtxt  : 'no'
+          )
+{$ifdef i386}
+          ,(
             id     : as_i386_o;
             idtxt  : 'O';
             asmbin : 'as';
@@ -442,12 +463,9 @@ implementation
             labelprefix : '.L';
             comment : '; '
           )
-      {$ifdef m68k}
-          ,
-      {$endif m68k}
 {$endif i386}
 {$ifdef m68k}
-          (
+          ,(
             id     : as_m68k_o;
             idtxt  : 'O';
             asmbin : 'as';
@@ -498,9 +516,12 @@ implementation
 {****************************************************************************
                             Linker Info
 ****************************************************************************}
-       link_infos : array[1..i386linkcnt+m68klinkcnt] of tlinkinfo = (
-{$ifdef i386}
+       link_infos : array[1..linkcnt] of tlinkinfo = (
           (
+            id      : link_none;
+          )
+{$ifdef i386}
+          ,(
             id      : link_i386_ld;
             linkbin : 'ld';
             linkcmd : '$OPT -o $EXE $RES';
@@ -575,12 +596,9 @@ implementation
             inputend   : '';
             libprefix  : '-l'
           )
-      {$ifdef m68k}
-          ,
-      {$endif m68k}
 {$endif i386}
 {$ifdef m68k}
-          (
+          ,(
             id      : link_m68k_ld;
             linkbin : 'ld';
             linkcmd : '$OPT -o $EXE $RES';
@@ -601,9 +619,12 @@ implementation
 {****************************************************************************
                                  Ar Info
 ****************************************************************************}
-           ar_infos : array[1..i386arcnt+m68karcnt] of tarinfo = (
-{$ifdef i386}
+           ar_infos : array[1..arcnt] of tarinfo = (
           (
+            id    : ar_none;
+          )
+{$ifdef i386}
+          ,(
             id    : ar_i386_ar;
             arbin : 'ar';
             arcmd : 'rs $LIB $FILES'
@@ -613,12 +634,9 @@ implementation
             arbin : 'arw';
             arcmd : 'rs $LIB $FILES'
           )
-      {$ifdef m68k}
-          ,
-      {$endif m68k}
 {$endif i386}
 {$ifdef m68k}
-          (
+          ,(
             id    : ar_m68k_ar;
             arbin : 'ar';
             arcmd : 'rs $LIB $FILES'
@@ -629,9 +647,14 @@ implementation
 {****************************************************************************
                             Targets Info
 ****************************************************************************}
-       target_infos : array[1..i386targetcnt+m68ktargetcnt] of ttargetinfo = (
-{$ifdef i386}
+       target_infos : array[1..targetcnt] of ttargetinfo = (
           (
+            target      : target_none;
+            cpu         : no_cpu;
+            short_name  : 'notarget'
+          )
+{$ifdef i386}
+          ,(
             target      : target_i386_GO32V1;
             cpu         : i386;
             short_name  : 'GO32V1';
@@ -731,12 +754,9 @@ implementation
             maxheapsize : 32768*1024;
             stacksize   : 32768
           )
-      {$ifdef m68k}
-          ,
-      {$endif m68k}
 {$endif i386}
 {$ifdef m68k}
-          (
+          ,(
             target      : target_m68k_Amiga;
             cpu         : m68k;
             short_name  : 'AMIGA';
@@ -842,9 +862,13 @@ implementation
 {****************************************************************************
                              AsmModeInfo
 ****************************************************************************}
-       asmmodeinfos : array[1..i386asmmodecnt+m68kasmmodecnt] of tasmmodeinfo = (
-{$ifdef i386}
+       asmmodeinfos : array[1..asmmodecnt] of tasmmodeinfo = (
           (
+            id    : asmmode_none;
+            idtxt : 'none'
+          )
+{$ifdef i386}
+          ,(
             id    : asmmode_i386_direct;
             idtxt : 'DIRECT'
           ),
@@ -856,12 +880,9 @@ implementation
             id    : asmmode_i386_intel;
             idtxt : 'INTEL'
           )
-      {$ifdef m68k}
-          ,
-      {$endif m68k}
 {$endif i386}
 {$ifdef m68k}
-          (
+          ,(
             id    : asmmode_m68k_mot;
             idtxt : 'MOT'
           )
@@ -877,7 +898,8 @@ var
   i : longint;
 begin
   set_target_os:=false;
-  for i:=1 to (sizeof(os_infos) div sizeof(tosinfo)) do
+  { target 1 is none }
+  for i:=2 to oscnt do
    if os_infos[i].id=t then
     begin
       target_os:=os_infos[i];
@@ -892,7 +914,7 @@ var
   i : longint;
 begin
   set_target_asm:=false;
-  for i:=1 to (sizeof(as_infos) div sizeof(tasminfo)) do
+  for i:=1 to asmcnt do
    if as_infos[i].id=t then
     begin
       target_asm:=as_infos[i];
@@ -907,7 +929,7 @@ var
   i : longint;
 begin
   set_target_link:=false;
-  for i:=1 to (sizeof(link_infos) div sizeof(tlinkinfo)) do
+  for i:=1 to linkcnt do
    if link_infos[i].id=t then
     begin
       target_link:=link_infos[i];
@@ -922,7 +944,7 @@ var
   i : longint;
 begin
   set_target_ar:=false;
-  for i:=1 to (sizeof(ar_infos) div sizeof(tarinfo)) do
+  for i:=1 to arcnt do
    if ar_infos[i].id=t then
     begin
       target_ar:=ar_infos[i];
@@ -937,7 +959,7 @@ var
   i : longint;
 begin
   set_target_info:=false;
-  for i:=1 to (sizeof(target_infos) div sizeof(ttargetinfo)) do
+  for i:=1 to targetcnt do
    if target_infos[i].target=t then
     begin
       target_info:=target_infos[i];
@@ -963,7 +985,7 @@ begin
   set_string_target:=false;
   { this should be case insensitive !! PM }
   s:=upper(s);
-  for i:=1 to (sizeof(target_infos) div sizeof(ttargetinfo)) do
+  for i:=1 to targetcnt do
    if target_infos[i].short_name=s then
     begin
       target_info:=target_infos[i];
@@ -985,7 +1007,7 @@ begin
   set_string_asm:=false;
   { this should be case insensitive !! PM }
   s:=upper(s);
-  for i:=1 to (sizeof(as_infos) div sizeof(tasminfo)) do
+  for i:=1 to asmcnt do
    if as_infos[i].idtxt=s then
     begin
       target_asm:=as_infos[i];
@@ -1001,7 +1023,7 @@ begin
   set_string_asmmode:=false;
   { this should be case insensitive !! PM }
   s:=upper(s);
-  for i:=1 to (sizeof(asmmodeinfos) div sizeof(tasmmodeinfo)) do
+  for i:=1 to asmmodecnt do
    if asmmodeinfos[i].idtxt=s then
     begin
       t:=asmmodeinfos[i].id;
@@ -1028,7 +1050,7 @@ var
 begin
   if source_os.name<>'' then
     Message(exec_w_source_os_redefined);
-  for i:=1 to (sizeof(os_infos) div sizeof(tosinfo)) do
+  for i:=1 to oscnt do
    if os_infos[i].id=t then
     begin
       source_os:=os_infos[i];
@@ -1126,7 +1148,16 @@ begin
 end.
 {
   $Log$
-  Revision 1.41  1998-10-13 13:10:31  peter
+  Revision 1.42  1998-10-13 16:50:23  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.41  1998/10/13 13:10:31  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.40  1998/10/13 09:13:09  pierre

+ 15 - 3
compiler/tcmat.pas

@@ -171,8 +171,11 @@ implementation
               exit;
            end;
            { nasm can not cope with negativ reals !! }
-         if is_constrealnode(p^.left) and
-            not(aktoutputformat in [as_i386_nasmcoff,as_i386_nasmelf,as_i386_nasmobj]) then
+         if is_constrealnode(p^.left)
+{$ifdef i386}
+           and not(aktoutputformat in [as_i386_nasmcoff,as_i386_nasmelf,as_i386_nasmobj])
+{$endif i386}
+             then
            begin
               t:=genrealconstnode(-p^.left^.value_real);
               disposetree(p);
@@ -319,7 +322,16 @@ implementation
 end.
 {
   $Log$
-  Revision 1.3  1998-10-13 13:10:33  peter
+  Revision 1.4  1998-10-13 16:50:25  pierre
+    * undid some changes of Peter that made the compiler wrong
+      for m68k (I had to reinsert some ifdefs)
+    * removed several memory leaks under m68k
+    * removed the meory leaks for assembler readers
+    * cross compiling shoud work again better
+      ( crosscompiling sysamiga works
+       but as68k still complain about some code !)
+
+  Revision 1.3  1998/10/13 13:10:33  peter
     * new style for m68k/i386 infos and enums
 
   Revision 1.2  1998/10/11 14:31:20  peter