Browse Source

* following Peters remark, removed all ifdef in
the systems unit enums
* last bugs of cg68k removed for sysamiga
(sysamiga assembles with as68k !!)

pierre 27 years ago
parent
commit
e619803966
4 changed files with 129 additions and 124 deletions
  1. 10 3
      compiler/cg68kinl.pas
  2. 9 2
      compiler/cg68kld.pas
  3. 97 94
      compiler/cg68kmem.pas
  4. 13 25
      compiler/systems.pas

+ 10 - 3
compiler/cg68kinl.pas

@@ -76,7 +76,8 @@ implementation
          { tfloattype = (f32bit,s32real,s64real,s80real,s64bit); }
          { tfloattype = (f32bit,s32real,s64real,s80real,s64bit); }
          float_name: array[tfloattype] of string[8]=
          float_name: array[tfloattype] of string[8]=
            ('FIXED','SINGLE','REAL','EXTENDED','COMP','FIXED16');
            ('FIXED','SINGLE','REAL','EXTENDED','COMP','FIXED16');
-         addsubop:array[in_inc_x..in_dec_x] of tasmop=(A_ADDQ,A_SUBQ);
+         addconstsubop:array[in_inc_x..in_dec_x] of tasmop=(A_ADDQ,A_SUBQ);
+         addsubop:array[in_inc_x..in_dec_x] of tasmop=(A_ADD,A_SUB);
        var
        var
          aktfile : treference;
          aktfile : treference;
          ft : tfiletype;
          ft : tfiletype;
@@ -758,7 +759,7 @@ implementation
               { write the add instruction }
               { write the add instruction }
                 if addconstant then
                 if addconstant then
                  begin
                  begin
-                    exprasmlist^.concat(new(pai68k,op_const_ref(addsubop[p^.inlinenumber],opsize,
+                    exprasmlist^.concat(new(pai68k,op_const_ref(addconstsubop[p^.inlinenumber],opsize,
                       addvalue,newreference(p^.left^.left^.location.reference))));
                       addvalue,newreference(p^.left^.left^.location.reference))));
                  end
                  end
                 else
                 else
@@ -889,7 +890,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.7  1998-10-13 16:50:08  pierre
+  Revision 1.8  1998-10-14 08:08:52  pierre
+    * following Peters remark, removed all ifdef in
+      the systems unit enums
+    * last bugs of cg68k removed for sysamiga
+      (sysamiga assembles with as68k !!)
+
+  Revision 1.7  1998/10/13 16:50:08  pierre
     * undid some changes of Peter that made the compiler wrong
     * undid some changes of Peter that made the compiler wrong
       for m68k (I had to reinsert some ifdefs)
       for m68k (I had to reinsert some ifdefs)
     * removed several memory leaks under m68k
     * removed several memory leaks under m68k

+ 9 - 2
compiler/cg68kld.pas

@@ -472,7 +472,8 @@ implementation
          if ret_in_param(p^.retdef) then
          if ret_in_param(p^.retdef) then
            begin
            begin
               if not hr_valid then
               if not hr_valid then
-                hr:=getregister32;
+                { this was wrong !! PM }
+                hr:=getaddressreg;
               exprasmlist^.concat(new(pai68k,op_ref_reg(A_MOVE,S_L,newreference(p^.location.reference),hr)));
               exprasmlist^.concat(new(pai68k,op_ref_reg(A_MOVE,S_L,newreference(p^.location.reference),hr)));
               p^.location.reference.base:=hr;
               p^.location.reference.base:=hr;
               p^.location.reference.offset:=0;
               p^.location.reference.offset:=0;
@@ -509,7 +510,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.4  1998-10-13 08:19:28  pierre
+  Revision 1.5  1998-10-14 08:08:53  pierre
+    * following Peters remark, removed all ifdef in
+      the systems unit enums
+    * last bugs of cg68k removed for sysamiga
+      (sysamiga assembles with as68k !!)
+
+  Revision 1.4  1998/10/13 08:19:28  pierre
     + source_os is now set correctly for cross-processor compilers
     + source_os is now set correctly for cross-processor compilers
       (tos contains all target_infos and
       (tos contains all target_infos and
        we use CPU86 and CPU68 conditionnals to
        we use CPU86 and CPU68 conditionnals to

+ 97 - 94
compiler/cg68kmem.pas

@@ -422,23 +422,23 @@ implementation
            begin
            begin
               { offset can only differ from 0 if arraydef }
               { offset can only differ from 0 if arraydef }
               if (p^.left^.resulttype^.deftype=arraydef) then
               if (p^.left^.resulttype^.deftype=arraydef) then
-              begin
+                begin
                    if not(is_open_array(p^.left^.resulttype)) then
                    if not(is_open_array(p^.left^.resulttype)) then
-                       begin
-                     if (p^.right^.value>parraydef(p^.left^.resulttype)^.highrange) or
-                        (p^.right^.value<parraydef(p^.left^.resulttype)^.lowrange) then
-                        CGMessage(parser_e_range_check_error);
-
-                     dec(p^.left^.location.reference.offset,
-                        p^.resulttype^.size*parraydef(p^.left^.resulttype)^.lowrange);
-                    end
+                     begin
+                        if (p^.right^.value>parraydef(p^.left^.resulttype)^.highrange) or
+                           (p^.right^.value<parraydef(p^.left^.resulttype)^.lowrange) then
+                          CGMessage(parser_e_range_check_error);
+
+                        dec(p^.left^.location.reference.offset,
+                          p^.resulttype^.size*parraydef(p^.left^.resulttype)^.lowrange);
+                     end
                    else
                    else
                      begin
                      begin
                         { range checking for open arrays }
                         { range checking for open arrays }
                      end;
                      end;
-                  end;
+                end;
               inc(p^.left^.location.reference.offset,
               inc(p^.left^.location.reference.offset,
-                 p^.right^.value*p^.resulttype^.size);
+                p^.right^.value*p^.resulttype^.size);
               p^.left^.resulttype:=p^.resulttype;
               p^.left^.resulttype:=p^.resulttype;
               disposetree(p^.right);
               disposetree(p^.right);
               _p:=p^.left;
               _p:=p^.left;
@@ -473,7 +473,7 @@ implementation
                      end
                      end
                    else if (p^.right^.treetype=subn) then
                    else if (p^.right^.treetype=subn) then
                      begin
                      begin
-                              if p^.right^.right^.treetype=ordconstn then
+                        if p^.right^.right^.treetype=ordconstn then
                           begin
                           begin
                              extraoffset:=p^.right^.right^.value;
                              extraoffset:=p^.right^.right^.value;
                              t:=p^.right^.left;
                              t:=p^.right^.left;
@@ -513,14 +513,14 @@ implementation
                                end;
                                end;
 
 
                 LOC_CREGISTER : begin
                 LOC_CREGISTER : begin
-                                       ind:=getregister32;
+                                   ind:=getregister32;
                                    emit_reg_reg(A_MOVE,S_L,p^.right^.location.register,ind);
                                    emit_reg_reg(A_MOVE,S_L,p^.right^.location.register,ind);
                                    case p^.right^.resulttype^.size of
                                    case p^.right^.resulttype^.size of
                                    1: exprasmlist^.concat(new(pai68k,op_const_reg(A_AND,S_L,
                                    1: exprasmlist^.concat(new(pai68k,op_const_reg(A_AND,S_L,
                                       $ff,ind)));
                                       $ff,ind)));
                                    2: exprasmlist^.concat(new(pai68k,op_const_reg(A_AND,S_L,
                                    2: exprasmlist^.concat(new(pai68k,op_const_reg(A_AND,S_L,
                                       $ffff,ind)));
                                       $ffff,ind)));
-                                end;
+                                   end;
                                 end;
                                 end;
                    LOC_FLAGS:
                    LOC_FLAGS:
                      begin
                      begin
@@ -544,99 +544,96 @@ implementation
                         2: exprasmlist^.concat(new(pai68k,op_const_reg(A_AND,S_L,
                         2: exprasmlist^.concat(new(pai68k,op_const_reg(A_AND,S_L,
                           $ffff,ind)));
                           $ffff,ind)));
                       end; { end case }
                       end; { end case }
-                      end; { end else begin }
-              end;
+                end; { end else begin }
+           end;
 
 
-              { produce possible range check code: }
-              if cs_check_range in aktlocalswitches  then
+         { produce possible range check code: }
+         if cs_check_range in aktlocalswitches  then
+           begin
+              if p^.left^.resulttype^.deftype=arraydef then
                 begin
                 begin
-                   if p^.left^.resulttype^.deftype=arraydef then
-                     begin
-                        new(hp);
-                        reset_reference(hp^);
-                        parraydef(p^.left^.resulttype)^.genrangecheck;
-                        hp^.symbol:=stringdup(parraydef(p^.left^.resulttype)^.getrangecheckstring);
-                        emit_bounds_check(hp^,ind);
-                     end;
+                   new(hp);
+                   reset_reference(hp^);
+                   parraydef(p^.left^.resulttype)^.genrangecheck;
+                   hp^.symbol:=stringdup(parraydef(p^.left^.resulttype)^.getrangecheckstring);
+                   emit_bounds_check(hp^,ind);
                 end;
                 end;
-
-           { ------------------------ HANDLE INDEXING ----------------------- }
-           { In Motorola 680x0 mode, displacement can only be of 64K max.     }
-           { Therefore instead of doing a direct displacement, we must first  }
-           { load the new address into an address register. Therefore the     }
-           { symbol is not used.                                              }
-           if assigned(p^.location.reference.symbol) then
+           end;
+ 
+         { ------------------------ HANDLE INDEXING ----------------------- }
+         { In Motorola 680x0 mode, displacement can only be of 64K max.     }
+         { Therefore instead of doing a direct displacement, we must first  }
+         { load the new address into an address register. Therefore the     }
+         { symbol is not used.                                              }
+         if assigned(p^.location.reference.symbol) then
            begin
            begin
               if p^.location.reference.base <> R_NO then
               if p^.location.reference.base <> R_NO then
-               CGMessage(cg_f_secondvecn_base_defined_twice);
+                CGMessage(cg_f_secondvecn_base_defined_twice);
               p^.location.reference.base:=getaddressreg;
               p^.location.reference.base:=getaddressreg;
               exprasmlist^.concat(new(pai68k,op_csymbol_reg(A_LEA,S_L,newcsymbol(p^.location.reference.symbol^,0),
               exprasmlist^.concat(new(pai68k,op_csymbol_reg(A_LEA,S_L,newcsymbol(p^.location.reference.symbol^,0),
                 p^.location.reference.base)));
                 p^.location.reference.base)));
               stringdispose(p^.location.reference.symbol);
               stringdispose(p^.location.reference.symbol);
            end;
            end;
 
 
-              if (p^.location.reference.index=R_NO) then
+         if (p^.location.reference.index=R_NO) then
+           begin
+              p^.location.reference.index:=ind;
+              calc_emit_mul;
+              { here we must check for the offset      }
+              { and if out of bounds for the motorola  }
+              { eg: out of signed d8 then reload index }
+              { with correct value.                    }
+              if p^.location.reference.offset > 127 then
                 begin
                 begin
-                   p^.location.reference.index:=ind;
-                   calc_emit_mul;
-               { here we must check for the offset      }
-               { and if out of bounds for the motorola  }
-               { eg: out of signed d8 then reload index }
-               { with correct value.                    }
-               if p^.location.reference.offset > 127 then
-               begin
-                  exprasmlist^.concat(new(pai68k,op_const_reg(A_ADD,S_L,p^.location.reference.offset,ind)));
-                  p^.location.reference.offset := 0;
-               end
-               else
-               if p^.location.reference.offset < -128 then
-               begin
-                  exprasmlist^.concat(new(pai68k,op_const_reg(A_SUB,S_L,-p^.location.reference.offset,ind)));
-                  p^.location.reference.offset := 0;
-               end;
+                   exprasmlist^.concat(new(pai68k,op_const_reg(A_ADD,S_L,p^.location.reference.offset,ind)));
+                   p^.location.reference.offset := 0;
                 end
                 end
-              else
+              else if p^.location.reference.offset < -128 then
                 begin
                 begin
-                   if p^.location.reference.base=R_NO then
-                      begin
-                          case p^.location.reference.scalefactor of
-                       2 : exprasmlist^.concat(new(pai68k,op_const_reg(A_LSL,S_L,1,p^.location.reference.index)));
-                       4 : exprasmlist^.concat(new(pai68k,op_const_reg(A_LSL,S_L,2,p^.location.reference.index)));
-                       8 : exprasmlist^.concat(new(pai68k,op_const_reg(A_LSL,S_L,3,p^.location.reference.index)));
-                       end;
-                          calc_emit_mul;
-
-                    { we must use address register to put index in base }
-                    { compare with cgi386.pas                           }
-
-                    reg := getaddressreg;
-                    p^.location.reference.base := reg;
-
-                    emit_reg_reg(A_MOVE,S_L,p^.location.reference.index,reg);
-                    ungetregister(p^.location.reference.index);
-
-                    p^.location.reference.index:=ind;
-                 end
-               else
-                 begin
-                    reg := getaddressreg;
-                    exprasmlist^.concat(new(pai68k,op_ref_reg(
-                      A_LEA,S_L,newreference(p^.location.reference),
-                      reg)));
-
-                    ungetregister(p^.location.reference.base);
-                    { the symbol offset is loaded,               }
-                    { so release the symbol name and set symbol  }
-                    { to nil                                     }
-                    stringdispose(p^.location.reference.symbol);
-                    p^.location.reference.offset:=0;
-                    calc_emit_mul;
-                    p^.location.reference.base:=reg;
-                    ungetregister32(p^.location.reference.index);
-                    p^.location.reference.index:=ind;
-                 end;
-               end;
-           end;
+                   exprasmlist^.concat(new(pai68k,op_const_reg(A_SUB,S_L,-p^.location.reference.offset,ind)));
+                   p^.location.reference.offset := 0;
+                end;
+           end
+         { if no index then allways get an address register !! PM }
+         else if p^.location.reference.base=R_NO then
+           begin
+              case p^.location.reference.scalefactor of
+                  2 : exprasmlist^.concat(new(pai68k,op_const_reg(A_LSL,S_L,1,p^.location.reference.index)));
+                  4 : exprasmlist^.concat(new(pai68k,op_const_reg(A_LSL,S_L,2,p^.location.reference.index)));
+                  8 : exprasmlist^.concat(new(pai68k,op_const_reg(A_LSL,S_L,3,p^.location.reference.index)));
+                end;
+              calc_emit_mul;
+
+              { we must use address register to put index in base }
+              { compare with cgi386.pas                           }
+
+              reg := getaddressreg;
+              p^.location.reference.base := reg;
+
+              emit_reg_reg(A_MOVE,S_L,p^.location.reference.index,reg);
+              ungetregister(p^.location.reference.index);
+
+              p^.location.reference.index:=ind;
+           end
+         else
+           begin
+              reg := getaddressreg;
+              exprasmlist^.concat(new(pai68k,op_ref_reg(
+                A_LEA,S_L,newreference(p^.location.reference),
+                reg)));
+
+              ungetregister(p^.location.reference.base);
+              { the symbol offset is loaded,               }
+              { so release the symbol name and set symbol  }
+              { to nil                                     }
+              stringdispose(p^.location.reference.symbol);
+              p^.location.reference.offset:=0;
+              calc_emit_mul;
+              p^.location.reference.base:=reg;
+              ungetregister32(p^.location.reference.index);
+              p^.location.reference.index:=ind;
+         end;
+         end;
       end;
       end;
 
 
 
 
@@ -691,7 +688,13 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.6  1998-10-06 20:49:00  peter
+  Revision 1.7  1998-10-14 08:08:54  pierre
+    * following Peters remark, removed all ifdef in
+      the systems unit enums
+    * last bugs of cg68k removed for sysamiga
+      (sysamiga assembles with as68k !!)
+
+  Revision 1.6  1998/10/06 20:49:00  peter
     * m68k compiler compiles again
     * m68k compiler compiles again
 
 
   Revision 1.5  1998/09/17 09:42:28  peter
   Revision 1.5  1998/09/17 09:42:28  peter

+ 13 - 25
compiler/systems.pas

@@ -40,12 +40,8 @@ unit systems;
 
 
      type
      type
        tasmmode= (asmmode_none
        tasmmode= (asmmode_none
-{$ifdef i386}
             ,asmmode_i386_direct,asmmode_i386_att,asmmode_i386_intel
             ,asmmode_i386_direct,asmmode_i386_att,asmmode_i386_intel
-{$endif i386}
-{$ifdef m68k}
             ,asmmode_m68k_mot
             ,asmmode_m68k_mot
-{$endif m68k}
        );
        );
      const
      const
        {$ifdef i386} i386asmmodecnt=3; {$else} i386asmmodecnt=0; {$endif}
        {$ifdef i386} i386asmmodecnt=3; {$else} i386asmmodecnt=0; {$endif}
@@ -54,16 +50,10 @@ unit systems;
 
 
      type
      type
        ttarget = (target_none
        ttarget = (target_none
-{$ifdef i386}
             ,target_i386_GO32V1,target_i386_GO32V2,target_i386_linux,
             ,target_i386_GO32V1,target_i386_GO32V2,target_i386_linux,
             target_i386_OS2,target_i386_Win32
             target_i386_OS2,target_i386_Win32
-{$endif i386}
             ,target_m68k_Amiga,target_m68k_Atari,target_m68k_Mac,
             ,target_m68k_Amiga,target_m68k_Atari,target_m68k_Mac,
             target_m68k_linux,target_m68k_PalmOS
             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
      const
        {$ifdef i386} i386targetcnt=5; {$else} i386targetcnt=0; {$endif}
        {$ifdef i386} i386targetcnt=5; {$else} i386targetcnt=0; {$endif}
@@ -72,14 +62,10 @@ unit systems;
 
 
      type
      type
        tasm = (as_none
        tasm = (as_none
-{$ifdef i386}
             ,as_i386_o,as_i386_o_aout,as_i386_asw,
             ,as_i386_o,as_i386_o_aout,as_i386_asw,
             as_i386_nasmcoff,as_i386_nasmelf,as_i386_nasmobj,
             as_i386_nasmcoff,as_i386_nasmelf,as_i386_nasmobj,
             as_i386_tasm,as_i386_masm
             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
             ,as_m68k_o,as_m68k_gas,as_m68k_mit,as_m68k_mot,as_m68k_mpw
-{$endif m68k}
        );
        );
      const
      const
        {$ifdef i386} i386asmcnt=8; {$else} i386asmcnt=0; {$endif}
        {$ifdef i386} i386asmcnt=8; {$else} i386asmcnt=0; {$endif}
@@ -88,14 +74,10 @@ unit systems;
 
 
      type
      type
        tlink = (link_none
        tlink = (link_none
-{$ifdef i386}
             ,link_i386_ld,link_i386_ldgo32v1,
             ,link_i386_ld,link_i386_ldgo32v1,
             link_i386_ldgo32v2,link_i386_ldw,
             link_i386_ldgo32v2,link_i386_ldw,
             link_i386_ldos2
             link_i386_ldos2
-{$endif i386}
-{$ifdef m68k}
             ,link_m68k_ld
             ,link_m68k_ld
-{$endif m68k}
        );
        );
      const
      const
        {$ifdef i386} i386linkcnt=5; {$else} i386linkcnt=0; {$endif}
        {$ifdef i386} i386linkcnt=5; {$else} i386linkcnt=0; {$endif}
@@ -104,12 +86,8 @@ unit systems;
 
 
      type
      type
        tar = (ar_none
        tar = (ar_none
-{$ifdef i386}
             ,ar_i386_ar,ar_i386_arw
             ,ar_i386_ar,ar_i386_arw
-{$endif i386}
-{$ifdef m68k}
             ,ar_m68k_ar
             ,ar_m68k_ar
-{$endif m68k}
        );
        );
      const
      const
        {$ifdef i386} i386arcnt=2; {$else} i386arcnt=0; {$endif}
        {$ifdef i386} i386arcnt=2; {$else} i386arcnt=0; {$endif}
@@ -117,7 +95,7 @@ unit systems;
        arcnt=i386arcnt+m68karcnt+1;
        arcnt=i386arcnt+m68karcnt+1;
 
 
      type
      type
-       tos = (
+       tos = ( os_none,
             os_i386_GO32V1,os_i386_GO32V2,os_i386_Linux,os_i386_OS2,
             os_i386_GO32V1,os_i386_GO32V2,os_i386_Linux,os_i386_OS2,
             os_i386_Win32,
             os_i386_Win32,
             os_m68k_Amiga,os_m68k_Atari,os_m68k_Mac,os_m68k_Linux,
             os_m68k_Amiga,os_m68k_Atari,os_m68k_Mac,os_m68k_Linux,
@@ -126,7 +104,7 @@ unit systems;
      const
      const
        i386oscnt=5;
        i386oscnt=5;
        m68koscnt=5;
        m68koscnt=5;
-       oscnt=i386oscnt+m68koscnt;
+       oscnt=i386oscnt+m68koscnt+1;
 
 
    type
    type
        tosinfo = packed record
        tosinfo = packed record
@@ -228,6 +206,10 @@ implementation
                                  OS Info
                                  OS Info
 ****************************************************************************}
 ****************************************************************************}
        os_infos : array[1..oscnt] of tosinfo = (
        os_infos : array[1..oscnt] of tosinfo = (
+          (
+            id           : os_none;
+            name         : 'No operating system';
+          ),
           (
           (
             id           : os_i386_go32v1;
             id           : os_i386_go32v1;
             name         : 'GO32 V1 DOS extender';
             name         : 'GO32 V1 DOS extender';
@@ -1148,7 +1130,13 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.42  1998-10-13 16:50:23  pierre
+  Revision 1.43  1998-10-14 08:08:56  pierre
+    * following Peters remark, removed all ifdef in
+      the systems unit enums
+    * last bugs of cg68k removed for sysamiga
+      (sysamiga assembles with as68k !!)
+
+  Revision 1.42  1998/10/13 16:50:23  pierre
     * undid some changes of Peter that made the compiler wrong
     * undid some changes of Peter that made the compiler wrong
       for m68k (I had to reinsert some ifdefs)
       for m68k (I had to reinsert some ifdefs)
     * removed several memory leaks under m68k
     * removed several memory leaks under m68k