Browse Source

* moved section names to systems
* fixed nasm,intel writer

peter 26 years ago
parent
commit
adda83dac6
9 changed files with 277 additions and 181 deletions
  1. 7 10
      compiler/aasm.pas
  2. 13 35
      compiler/ag386int.pas
  3. 9 12
      compiler/ag386nsm.pas
  4. 9 5
      compiler/assemble.pas
  5. 15 1
      compiler/i386asm.pas
  6. 7 3
      compiler/og386.pas
  7. 6 2
      compiler/og386dbg.pas
  8. 103 95
      compiler/rautils.pas
  9. 108 18
      compiler/systems.pas

+ 7 - 10
compiler/aasm.pas

@@ -25,7 +25,7 @@ unit aasm;
   interface
 
     uses
-       cobjects,files,globals;
+       systems,cobjects,files,globals;
 
     type
 {$ifdef i386}
@@ -70,13 +70,6 @@ unit aasm;
           { never used, makes insertation of new ait_ easier to type }
           ait_dummy);
 
-       tsection=(sec_none,
-         sec_code,sec_data,sec_bss,
-         sec_stab,sec_stabstr,
-         sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_edata,
-         sec_fake
-       );
-
 
   { asm symbol functions }
     type
@@ -350,7 +343,7 @@ type
 implementation
 
 uses
-  strings,verbose,systems,globtype;
+  strings,verbose,globtype;
 
 {****************************************************************************
                              TAI
@@ -1013,7 +1006,11 @@ uses
 end.
 {
   $Log$
-  Revision 1.40  1999-04-21 09:43:28  peter
+  Revision 1.41  1999-05-02 22:41:46  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.40  1999/04/21 09:43:28  peter
     * storenumber works
     * fixed some typos in double_checksum
     + incompatible types type1 and type2 message (with storenumber)

+ 13 - 35
compiler/ag386int.pas

@@ -338,9 +338,6 @@ unit ag386int;
       ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
         (#9'DD'#9,#9'DW'#9,#9'DB'#9);
 
-      ait_section2masmstr : array[tsection] of string[6]=
-       ('','CODE','DATA','BSS','','','','','','','','','');
-
     Function PadTabs(const p:string;addch:char):string;
     var
       s : string;
@@ -395,13 +392,13 @@ unit ag386int;
        ait_tempalloc : ;
        ait_section : begin
                        if LastSec<>sec_none then
-                        AsmWriteLn('_'+ait_section2masmstr[LastSec]+#9#9'ENDS');
+                        AsmWriteLn('_'+target_asm.secnames[LastSec]+#9#9'ENDS');
                        if pai_section(hp)^.sec<>sec_none then
                         begin
                           AsmLn;
-                          AsmWriteLn('_'+ait_section2masmstr[pai_section(hp)^.sec]+#9#9+
+                          AsmWriteLn('_'+target_asm.secnames[pai_section(hp)^.sec]+#9#9+
                                      'SEGMENT'#9'PARA PUBLIC USE32 '''+
-                                     ait_section2masmstr[pai_section(hp)^.sec]+'''');
+                                     target_asm.secnames[pai_section(hp)^.sec]+'''');
                         end;
                        LastSec:=pai_section(hp)^.sec;
                      end;
@@ -554,6 +551,7 @@ ait_labeled_instruction : AsmWriteLn(#9#9+int_op2str[pai386_labeled(hp)^.opcode]
    ait_instruction : begin
                        suffix:='';
                        prefix:= '';
+                       s:='';
 {$ifndef OLDASM}
                      { added prefix instructions, must be on same line as opcode }
                        if (pai386(hp)^.ops = 0) and
@@ -582,7 +580,7 @@ ait_labeled_instruction : AsmWriteLn(#9#9+int_op2str[pai386_labeled(hp)^.opcode]
                        if pai386(hp)^.ops<>0 then
                         begin
                           if pai386(hp)^.opcode=A_CALL then
-                           s:='dword ptr '+getopstr_jmp(pai386(hp)^.oper[0])
+                           s:=#9+getopstr_jmp(pai386(hp)^.oper[0])
                           else
                            begin
                              for i:=0to pai386(hp)^.ops-1 do
@@ -594,30 +592,6 @@ ait_labeled_instruction : AsmWriteLn(#9#9+int_op2str[pai386_labeled(hp)^.opcode]
                                 s:=s+sep+getopstr(pai386(hp)^.oper[i],pai386(hp)^.opsize,pai386(hp)^.opcode,(i=1));
                               end;
                            end;
-                        end
-                       else
-                        begin
-                          { check if string instruction }
-                          { long form, otherwise may give range check errors }
-                          { in turbo pascal...                               }
-{                          if ((pai386(hp)^.opcode = A_CMPS) or
-                             (pai386(hp)^.opcode = A_INS) or
-                             (pai386(hp)^.opcode = A_OUTS) or
-                             (pai386(hp)^.opcode = A_SCAS) or
-                             (pai386(hp)^.opcode = A_STOS) or
-                             (pai386(hp)^.opcode = A_MOVS) or
-                             (pai386(hp)^.opcode = A_LODS) or
-                             (pai386(hp)^.opcode = A_XLAT)) then
-                           Begin
-                             case pai386(hp)^.opsize of
-                              S_B: suffix:='b';
-                              S_W: suffix:='w';
-                              S_L: suffix:='d';
-                             else
-                              Message(assem_f_invalid_suffix_intel);
-                             end;
-                           end; }
-                          s:='';
                         end;
                        AsmWriteLn(#9#9+prefix+int_op2str[pai386(hp)^.opcode]+cond2str[pai386_labeled(hp)^.condition]+suffix+s);
 {$else}
@@ -722,7 +696,7 @@ ait_stab_function_name : ;
                        else
                         begin
                           if LastSec<>sec_none then
-                           AsmWriteLn('_'+ait_section2masmstr[LastSec]+#9#9'ENDS');
+                           AsmWriteLn('_'+target_asm.secnames[LastSec]+#9#9'ENDS');
                           AsmLn;
                           AsmWriteLn(#9'END');
                           AsmClose;
@@ -743,9 +717,9 @@ ait_stab_function_name : ;
                        AsmWriteLn(#9'.386p');
                        AsmWriteLn(#9'LOCALS '+target_asm.labelprefix);
                        if lastsec<>sec_none then
-                          AsmWriteLn('_'+ait_section2masmstr[lastsec]+#9#9+
+                          AsmWriteLn('_'+target_asm.secnames[lastsec]+#9#9+
                                      'SEGMENT'#9'PARA PUBLIC USE32 '''+
-                                     ait_section2masmstr[lastsec]+'''');
+                                     target_asm.secnames[lastsec]+'''');
                        AsmStartSize:=AsmSize;
                      end;
              ait_marker: ;
@@ -795,7 +769,11 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.34  1999-05-01 13:23:58  peter
+  Revision 1.35  1999-05-02 22:41:49  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.34  1999/05/01 13:23:58  peter
     * merged nasm compiler
     * old asm moved to oldasm/
 

+ 9 - 12
compiler/ag386nsm.pas

@@ -344,12 +344,6 @@ unit ag386nsm;
       ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
         (#9'DD'#9,#9'DW'#9,#9'DB'#9);
 
-      ait_section2nasmstr : array[tsection] of string[8]=
-       ('','.text','.data','.bss',
-        '.stab','.stabstr',
-        '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
-        '');
-
     Function PadTabs(const p:string;addch:char):string;
     var
       s : string;
@@ -408,7 +402,7 @@ unit ag386nsm;
                        if pai_section(hp)^.sec<>sec_none then
                         begin
                           AsmLn;
-                          AsmWriteLn('SECTION '+ait_section2nasmstr[pai_section(hp)^.sec]);
+                          AsmWriteLn('SECTION '+target_asm.secnames[pai_section(hp)^.sec]);
                         end;
                        LastSec:=pai_section(hp)^.sec;
                      end;
@@ -557,6 +551,7 @@ ait_labeled_instruction :
    ait_instruction : begin
                        suffix:='';
                        prefix:='';
+                       s:='';
 {$ifndef OLDASM}
                        if pai386(hp)^.ops<>0 then
                         begin
@@ -573,9 +568,7 @@ ait_labeled_instruction :
                                 s:=s+sep+getopstr(pai386(hp)^.oper[i],pai386(hp)^.opsize,pai386(hp)^.opcode,(i=1));
                               end;
                            end;
-                        end
-                       else
-                        s:='';
+                        end;
                        if pai386(hp)^.opcode=A_FWAIT then
                         AsmWriteln(#9#9'DB'#9'09bh')
                        else
@@ -696,7 +689,7 @@ ait_stab_function_name : ;
                           hp:=pai(hp^.next);
                         end;
                        if lastsec<>sec_none then
-                         AsmWriteLn('SECTION '+ait_section2nasmstr[lastsec]);
+                         AsmWriteLn('SECTION '+target_asm.secnames[lastsec]);
                        AsmStartSize:=AsmSize;
                      end;
         ait_marker : ;
@@ -740,7 +733,11 @@ ait_stab_function_name : ;
 end.
 {
   $Log$
-  Revision 1.29  1999-05-01 13:23:59  peter
+  Revision 1.30  1999-05-02 22:41:50  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.29  1999/05/01 13:23:59  peter
     * merged nasm compiler
     * old asm moved to oldasm/
 

+ 9 - 5
compiler/assemble.pas

@@ -85,7 +85,7 @@ uses
 {$endif}
   ,strings
 {$ifdef i386}
-  {$ifndef OLDASM}
+  {$ifndef NoAg386Bin}
     ,ag386bin
   {$endif}
   {$ifndef NoAg386Att}
@@ -446,14 +446,14 @@ Procedure GenerateAsm;
 var
   a : PAsmList;
 {$ifdef i386}
-  {$ifndef OLDASM}
+  {$ifndef NoAg386Bin}
     b : Pi386binasmlist;
   {$endif}
 {$endif}
 begin
   case aktoutputformat of
 {$ifdef i386}
-  {$ifndef OLDASM}
+  {$ifndef NoAg386Bin}
      as_i386_dbg,
      as_i386_coff,
      as_i386_pecoff :
@@ -479,7 +479,7 @@ begin
            SynchronizeFileTime(current_module^.ppufilename^,current_module^.objfilename^);
          exit;
        end;
-  {$endif Ag386Bin}
+  {$endif NoAg386Bin}
   {$ifndef NoAg386Att}
      as_i386_as,
      as_i386_as_aout,
@@ -541,7 +541,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.42  1999-05-01 13:24:00  peter
+  Revision 1.43  1999-05-02 22:41:51  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.42  1999/05/01 13:24:00  peter
     * merged nasm compiler
     * old asm moved to oldasm/
 

+ 15 - 1
compiler/i386asm.pas

@@ -209,6 +209,8 @@ uses
 
     procedure tai386.loadconst(opidx:longint;l:longint);
       begin
+        if opidx>=ops then
+         ops:=opidx+1;
         with oper[opidx] do
          begin
            if typ=top_ref then
@@ -220,6 +222,8 @@ uses
 
     procedure tai386.loadsymbol(opidx:longint;s:pasmsymbol;sofs:longint);
       begin
+        if opidx>=ops then
+         ops:=opidx+1;
         with oper[opidx] do
          begin
            if typ=top_ref then
@@ -232,6 +236,8 @@ uses
 
     procedure tai386.loadref(opidx:longint;p:preference);
       begin
+        if opidx>=ops then
+         ops:=opidx+1;
         with oper[opidx] do
          begin
            if typ=top_ref then
@@ -257,6 +263,8 @@ uses
 
     procedure tai386.loadreg(opidx:longint;r:tregister);
       begin
+        if opidx>=ops then
+         ops:=opidx+1;
         with oper[opidx] do
          begin
            if typ=top_ref then
@@ -268,6 +276,8 @@ uses
 
     procedure tai386.loadoper(opidx:longint;o:toper);
       begin
+        if opidx>=ops then
+         ops:=opidx+1;
         if oper[opidx].typ=top_ref then
           disposereference(oper[opidx].ref);
         oper[opidx]:=o;
@@ -1569,7 +1579,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.2  1999-05-02 21:33:52  florian
+  Revision 1.3  1999-05-02 22:41:53  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.2  1999/05/02 21:33:52  florian
     * several bugs regarding -Or fixed
 
   Revision 1.1  1999/05/01 13:24:23  peter

+ 7 - 3
compiler/og386.pas

@@ -30,7 +30,7 @@ unit og386;
     uses
        dos,
        owbase,owar,
-       i386base,aasm;
+       systems,i386base,aasm;
 
     type
        tsecsize = array[tsection] of longint;
@@ -77,7 +77,7 @@ unit og386;
   implementation
 
     uses
-      systems,globtype,globals,verbose,files,
+      globtype,globals,verbose,files,
       assemble;
 
 
@@ -236,7 +236,11 @@ unit og386;
 end.
 {
   $Log$
-  Revision 1.1  1999-05-01 13:24:23  peter
+  Revision 1.2  1999-05-02 22:41:54  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.1  1999/05/01 13:24:23  peter
     * merged nasm compiler
     * old asm moved to oldasm/
 

+ 6 - 2
compiler/og386dbg.pas

@@ -28,7 +28,7 @@ unit og386dbg;
 
   interface
     uses
-       i386base,
+       systems,i386base,
        aasm,
        og386;
 
@@ -189,7 +189,11 @@ unit og386dbg;
 end.
 {
   $Log$
-  Revision 1.1  1999-05-01 13:24:24  peter
+  Revision 1.2  1999-05-02 22:41:55  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.1  1999/05/01 13:24:24  peter
     * merged nasm compiler
     * old asm moved to oldasm/
 

+ 103 - 95
compiler/rautils.pas

@@ -287,7 +287,7 @@ begin
   if RPNTop < RPNMax then
   begin
     Inc(RPNTop);
-    RPNStack[RPNTop] := Num;
+    RPNStack[RPNTop]:=Num;
   end
   else
     Error(stack_overflow); { Put some error handler here }
@@ -300,7 +300,7 @@ Function TExprParse.RPNPop : longint;       { Get the operand at the top of the
 begin
   if RPNTop > 0 then
   begin
-    RPNPop := RPNStack[RPNTop];
+    RPNPop:=RPNStack[RPNTop];
     Dec(RPNTop);
   end
   else  { Put some error handler here }
@@ -334,7 +334,7 @@ begin
     '<' : RPNPush(RPNPop SHL RPNPop);
     '>' : RPNPush(RPNPop SHR RPNPop);
     '%' : begin
-      Temp := RPNPop;
+      Temp:=RPNPop;
       if Temp <> 0 then
        RPNPush(RPNPop mod Temp)
       else Error(zero_divide); { Handle divide by zero error }
@@ -342,7 +342,7 @@ begin
     '^' : RPNPush(RPNPop XOR RPNPop);
     '/' :
     begin
-      Temp := RPNPop;
+      Temp:=RPNPop;
       if Temp <> 0 then
    RPNPush(RPNPop div Temp)
       else  Error(zero_divide);{ Handle divide by 0 error }
@@ -368,8 +368,8 @@ begin
   if OpTop < OpMax then
   begin
     Inc(OpTop);
-    OpStack[OpTop].ch := _Operator;
-    OpStack[OpTop].is_prefix := prefix;
+    OpStack[OpTop].ch:=_Operator;
+    OpStack[OpTop].is_prefix:=prefix;
   end
   else Error(stack_overflow); { Put some error handler here }
 end;
@@ -378,7 +378,7 @@ Procedure TExprParse.OpPop(var _Operator:TExprOperator);               { Get ope
 begin
   if OpTop > 0 then
   begin
-    _Operator := OpStack[OpTop];
+    _Operator:=OpStack[OpTop];
     Dec(OpTop);
   end
   else Error(stack_underflow); { Put some error handler here }
@@ -388,10 +388,10 @@ Function TExprParse.Priority(_Operator : Char) : Integer; { Return priority of o
 { The greater the priority, the higher the precedence }
 begin
   Case _Operator OF
-    '('      : Priority := 0;
-    '+', '-' : Priority := 1;
-    '*', '/','%','<','>' : Priority := 2;
-    '|','&','^','~': Priority := 0;
+    '('      : Priority:=0;
+    '+', '-' : Priority:=1;
+    '*', '/','%','<','>' : Priority:=2;
+    '|','&','^','~': Priority:=0;
     else  Error(invalid_op);{ More error handling }
   end;
 end;
@@ -403,15 +403,19 @@ Var
   Token : String15;
   opr: TExprOperator;
 begin
-  OpTop  := 0;                                              { Reset stacks }
-  RPNTop := 0;
-  Token  := '';
-
-  For I := 1 to Length(Expr) DO
+  Evaluate:=0;
+  { Reset stacks }
+  OpTop :=0;
+  RPNTop:=0;
+  Token :='';
+  { nothing to do ? }
+  if Expr='' then
+   exit;
+  For I:=1 to Length(Expr) DO
    begin
      if Expr[I] in ['0'..'9'] then
       begin       { Build multi-digit numbers }
-        Token := Token + Expr[I];
+        Token:=Token + Expr[I];
         if I = Length(Expr) then          { Send last one to calculator }
          RPNCalc(Token,false);
       end
@@ -421,7 +425,7 @@ begin
          if Token <> '' then
           begin        { Send last built number to calc. }
             RPNCalc(Token,false);
-            Token := '';
+            Token:='';
           end;
 
          Case Expr[I] OF
@@ -480,7 +484,7 @@ begin
    end;
 
 { The result is stored on the top of the stack }
-  Evaluate := RPNPop;
+  Evaluate:=RPNPop;
 end;
 
 
@@ -494,7 +498,7 @@ var
   expr: TExprParse;
 Begin
   expr.Init;
-  CalculateExpression := expr.Evaluate(expression);
+  CalculateExpression:=expr.Evaluate(expression);
   expr.Done;
 end;
 
@@ -573,7 +577,7 @@ Function ValDecimal(const S:String):longint;
 var
   vs,c : longint;
 Begin
-  vs := 0;
+  vs:=0;
   for c:=1 to length(s) do
    begin
      vs:=vs*10;
@@ -595,7 +599,7 @@ Function ValOctal(const S:String):longint;
 var
   vs,c : longint;
 Begin
-  vs := 0;
+  vs:=0;
   for c:=1 to length(s) do
    begin
      vs:=vs shl 3;
@@ -617,7 +621,7 @@ Function ValBinary(const S:String):longint;
 var
   vs,c : longint;
 Begin
-  vs := 0;
+  vs:=0;
   for c:=1 to length(s) do
    begin
      vs:=vs shl 1;
@@ -639,7 +643,7 @@ Function ValHexadecimal(const S:String):longint;
 var
   vs,c : longint;
 Begin
-  vs := 0;
+  vs:=0;
   for c:=1 to length(s) do
    begin
      vs:=vs shl 4;
@@ -664,22 +668,22 @@ end;
 
 Function PadZero(Var s: String; n: byte): Boolean;
 Begin
-  PadZero := TRUE;
+  PadZero:=TRUE;
   { Do some error checking first }
   if Length(s) = n then
     exit
   else
   if Length(s) > n then
   Begin
-    PadZero := FALSE;
+    PadZero:=FALSE;
     delete(s,n+1,length(s));
     exit;
   end
   else
-    PadZero := TRUE;
+    PadZero:=TRUE;
   { Fill it up with the specified character }
   fillchar(s[length(s)+1],n-1,#0);
-  s[0] := chr(n);
+  s[0]:=chr(n);
 end;
 
 
@@ -692,7 +696,7 @@ Begin
   Opcode:=A_NONE;
   Opsize:=S_NO;
   Condition:=C_NONE;
-  labeled := FALSE;
+  labeled:=FALSE;
   Ops:=0;
   FillChar(Operands,sizeof(Operands),0);
 end;
@@ -709,8 +713,8 @@ end;
 
   Constructor TAsmLabelList.Init;
   Begin
-    First := nil;
-    Last := nil;
+    First:=nil;
+    Last:=nil;
   end;
 
 
@@ -728,17 +732,17 @@ end;
       if First = nil then
        Begin
           New(First);
-          Last := First;
+          Last:=First;
        end
       else
        Begin
           New(Last^.Next);
-          Last := Last^.Next;
+          Last:=Last^.Next;
        end;
-      Last^.name := stringdup(s);
-      Last^.Lab := lab;
-      Last^.Next := nil;
-      Last^.emitted := emitted;
+      Last^.name:=stringdup(s);
+      Last^.Lab:=lab;
+      Last^.Next:=nil;
+      Last^.emitted:=emitted;
     end;
   end;
 
@@ -753,18 +757,18 @@ end;
   Var
     asmlab: PAsmLabel;
   Begin
-    asmlab := First;
+    asmlab:=First;
     if First = nil then
     Begin
-      Search := nil;
+      Search:=nil;
       exit;
     end;
     While (asmlab^.name^ <> s) and (asmlab^.Next <> nil) do
-       asmlab := asmlab^.Next;
+       asmlab:=asmlab^.Next;
     if asmlab^.name^ = s then
-       search := asmlab
+       search:=asmlab
     else
-       search := nil;
+       search:=nil;
   end;
 
 
@@ -781,13 +785,13 @@ end;
     temp: PAsmLabel;
     temp1: PAsmLabel;
   Begin
-    temp := First;
+    temp:=First;
     while temp <> nil do
     Begin
       Freemem(Temp^.name, length(Temp^.name^)+1);
-      Temp1 := Temp^.Next;
+      Temp1:=Temp^.Next;
       Dispose(Temp);
-      Temp := Temp1;
+      Temp:=Temp1;
       { The plabel could be deleted here, but let us not do }
       { it, FPC will do it instead.                         }
     end;
@@ -804,16 +808,16 @@ end;
   Begin
     if instr.Ops = 2 then
     Begin
-      tempopr := instr.operands[1];
-      instr.operands[1] := instr.operands[2];
-      instr.operands[2] := tempopr;
+      tempopr:=instr.operands[1];
+      instr.operands[1]:=instr.operands[2];
+      instr.operands[2]:=tempopr;
     end
     else
     if instr.Ops = 3 then
     Begin
-      tempopr := instr.operands[1];
-      instr.operands[1] := instr.operands[3];
-      instr.operands[3] := tempopr;
+      tempopr:=instr.operands[1];
+      instr.operands[1]:=instr.operands[3];
+      instr.operands[3]:=tempopr;
     end;
   end;
 
@@ -830,18 +834,18 @@ end;
   var
     sym: psym;
   Begin
-    SearchIConstant := FALSE;
+    SearchIConstant:=FALSE;
     { check for TRUE or FALSE reserved words first }
     if s = 'TRUE' then
      Begin
-       SearchIConstant := TRUE;
-       l := 1;
+       SearchIConstant:=TRUE;
+       l:=1;
      end
     else
      if s = 'FALSE' then
       Begin
-        SearchIConstant := TRUE;
-        l := 0;
+        SearchIConstant:=TRUE;
+        l:=0;
       end
     else
      if assigned(aktprocsym) then
@@ -851,16 +855,16 @@ end;
          { Check the local constants }
            if assigned(aktprocsym^.definition^.localst) and
               (lexlevel >= normal_function_level) then
-            sym := aktprocsym^.definition^.localst^.search(s)
+            sym:=aktprocsym^.definition^.localst^.search(s)
            else
-            sym := nil;
+            sym:=nil;
            if assigned(sym) then
             Begin
               if (sym^.typ = constsym) and
                  (pconstsym(sym)^.consttype in [constord,constint,constchar,constbool]) then
                Begin
                  l:=pconstsym(sym)^.value;
-                 SearchIConstant := TRUE;
+                 SearchIConstant:=TRUE;
                  exit;
                end;
             end;
@@ -876,7 +880,7 @@ end;
              if (pconstsym(srsym)^.consttype in [constord,constint,constchar,constbool]) then
               Begin
                 l:=pconstsym(srsym)^.value;
-                SearchIConstant := TRUE;
+                SearchIConstant:=TRUE;
                 exit;
               end;
            end;
@@ -898,8 +902,8 @@ end;
     if assigned(procinfo.retdef) and
       (procinfo.retdef<>pdef(voiddef)) then
     begin
-      instr.operands[operandnum].ref.offset := procinfo.retoffset;
-      instr.operands[operandnum].ref.base :=  procinfo.framepointer;
+      instr.operands[operandnum].ref.offset:=procinfo.retoffset;
+      instr.operands[operandnum].ref.base:= procinfo.framepointer;
       { always assume that the result is valid. }
       procinfo.funcret_is_valid:=true;
     end
@@ -925,16 +929,16 @@ end;
     if (instr.operands[operandnum].size = S_NO) or (instr.operands[operandnum].overriden = FALSE) then
     Begin
       case size of
-       1: instr.operands[operandnum].size := S_B;
-       2: instr.operands[operandnum].size := S_W{ could be S_IS};
-       4: instr.operands[operandnum].size := S_L{ could be S_IL or S_FS};
-       8: instr.operands[operandnum].size := S_IQ{ could be S_D or S_FL};
-       extended_size: instr.operands[operandnum].size := S_FX;
+       1: instr.operands[operandnum].size:=S_B;
+       2: instr.operands[operandnum].size:=S_W{ could be S_IS};
+       4: instr.operands[operandnum].size:=S_L{ could be S_IL or S_FS};
+       8: instr.operands[operandnum].size:=S_IQ{ could be S_D or S_FL};
+       extended_size: instr.operands[operandnum].size:=S_FX;
       else
        { this is in the case where the instruction is LEA }
        { or something like that, in that case size is not }
        { important.                                       }
-        instr.operands[operandnum].size := S_NO;
+        instr.operands[operandnum].size:=S_NO;
       end; { end case }
     end;
   end;
@@ -951,7 +955,7 @@ var
   i    : longint;
   base : string;
 Begin
-  GetRecordOffsetSize := FALSE;
+  GetRecordOffsetSize:=FALSE;
   Offset:=0;
   Size:=0;
   i:=pos('.',s);
@@ -1028,7 +1032,7 @@ Function CreateVarInstr(var Instr: TInstruction; const hs:string;operandnum:byte
 var
   sym : psym;
 Begin
-  CreateVarInstr := FALSE;
+  CreateVarInstr:=FALSE;
 { are we in a routine ? }
   getsym(hs,false);
   sym:=srsym;
@@ -1048,10 +1052,10 @@ Begin
             instr.operands[operandnum].ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname);
           parasymtable :
             begin
-              instr.operands[operandnum].ref.base := procinfo.framepointer;
-              instr.operands[operandnum].ref.offset := pvarsym(sym)^.address;
+              instr.operands[operandnum].ref.base:=procinfo.framepointer;
+              instr.operands[operandnum].ref.offset:=pvarsym(sym)^.address;
               instr.operands[operandnum].ref.offsetfixup:=aktprocsym^.definition^.parast^.address_fixup;
-              instr.operands[operandnum].ref.options := ref_parafixup;
+              instr.operands[operandnum].ref.options:=ref_parafixup;
             end;
           localsymtable :
             begin
@@ -1059,9 +1063,9 @@ Begin
                 instr.operands[operandnum].ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname)
               else
                 begin
-                  instr.operands[operandnum].ref.base := procinfo.framepointer;
-                  instr.operands[operandnum].ref.offset := -(pvarsym(sym)^.address);
-                  instr.operands[operandnum].ref.options := ref_localfixup;
+                  instr.operands[operandnum].ref.base:=procinfo.framepointer;
+                  instr.operands[operandnum].ref.offset:=-(pvarsym(sym)^.address);
+                  instr.operands[operandnum].ref.options:=ref_localfixup;
                   instr.operands[operandnum].ref.offsetfixup:=aktprocsym^.definition^.localst^.address_fixup;
                 end;
             end;
@@ -1075,7 +1079,7 @@ Begin
             SetOperandSize(instr,operandnum,parraydef(pvarsym(sym)^.definition)^.elesize)
         end;
         instr.operands[operandnum].hasvar:=true;
-        CreateVarInstr := TRUE;
+        CreateVarInstr:=TRUE;
         Exit;
       end;
     typedconstsym :
@@ -1090,7 +1094,7 @@ Begin
             SetOperandSize(instr,operandnum,parraydef(ptypedconstsym(sym)^.definition)^.elesize)
         end;
         instr.operands[operandnum].hasvar:=true;
-        CreateVarInstr := TRUE;
+        CreateVarInstr:=TRUE;
         Exit;
       end;
     constsym :
@@ -1100,7 +1104,7 @@ Begin
            instr.operands[operandnum].operandtype:=OPR_CONSTANT;
            instr.operands[operandnum].val:=pconstsym(sym)^.value;
            instr.operands[operandnum].hasvar:=true;
-           CreateVarInstr := TRUE;
+           CreateVarInstr:=TRUE;
            Exit;
          end;
       end;
@@ -1111,7 +1115,7 @@ Begin
            instr.operands[operandnum].operandtype:=OPR_CONSTANT;
            instr.operands[operandnum].val:=0;
            instr.operands[operandnum].hasvar:=true;
-           CreateVarInstr := TRUE;
+           CreateVarInstr:=TRUE;
            Exit;
          end;
       end;
@@ -1122,7 +1126,7 @@ Begin
         instr.operands[operandnum].operandtype:=OPR_SYMBOL;
         instr.operands[operandnum].symbol:=newasmsymbol(pprocsym(sym)^.definition^.mangledname);
         instr.operands[operandnum].hasvar:=true;
-        CreateVarInstr := TRUE;
+        CreateVarInstr:=TRUE;
         Exit;
       end;
     else
@@ -1143,22 +1147,22 @@ end;
   var
     sym: psym;
   Begin
-    SearchLabel := FALSE;
+    SearchLabel:=FALSE;
     if assigned(aktprocsym) then
     Begin
       { Check the local constants }
     if assigned(aktprocsym^.definition) then
     Begin
         if assigned(aktprocsym^.definition^.localst) then
-          sym := aktprocsym^.definition^.localst^.search(s)
+          sym:=aktprocsym^.definition^.localst^.search(s)
       else
-       sym := nil;
+       sym:=nil;
       if assigned(sym) then
       Begin
        if (sym^.typ = labelsym) then
        Begin
           hl:=plabelsym(sym)^.number;
-          SearchLabel := TRUE;
+          SearchLabel:=TRUE;
           exit;
        end;
       end;
@@ -1171,7 +1175,7 @@ end;
       if (srsym^.typ=labelsym) then
       Begin
         hl:=plabelsym(srsym)^.number;
-        SearchLabel:= TRUE;
+        SearchLabel:=TRUE;
         exit;
       end;
     end;
@@ -1192,20 +1196,20 @@ Begin
      begin
        instr.operands[operandnum].ref.symbol:=p^.sym;
         case p^.exttyp of
-           EXT_BYTE   : instr.operands[operandnum].size := S_B;
-           EXT_WORD   : instr.operands[operandnum].size := S_W;
+           EXT_BYTE   : instr.operands[operandnum].size:=S_B;
+           EXT_WORD   : instr.operands[operandnum].size:=S_W;
            EXT_NEAR,EXT_FAR,EXT_PROC,EXT_DWORD,EXT_CODEPTR,EXT_DATAPTR:
-           instr.operands[operandnum].size := S_L;
-           EXT_QWORD  : instr.operands[operandnum].size := S_FL;
-           EXT_TBYTE  : instr.operands[operandnum].size := S_FX;
+           instr.operands[operandnum].size:=S_L;
+           EXT_QWORD  : instr.operands[operandnum].size:=S_FL;
+           EXT_TBYTE  : instr.operands[operandnum].size:=S_FX;
          else
            { this is in the case where the instruction is LEA }
            { or something like that, in that case size is not }
            { important.                                       }
-             instr.operands[operandnum].size := S_NO;
+             instr.operands[operandnum].size:=S_NO;
          end;
        instr.operands[operandnum].hasvar:=true;
-       SearchDirectVar := TRUE;
+       SearchDirectVar:=TRUE;
        Exit;
      end;
 end;
@@ -1273,7 +1277,7 @@ end;
       Begin
          Message(assem_e_constant_out_of_bounds);
          { assuming a value of maxvalue }
-         value := maxvalue;
+         value:=maxvalue;
       end;
       if maxvalue = $ff then
           p^.concat(new(pai_const,init_8bit(byte(value))))
@@ -1397,7 +1401,11 @@ end;
 end.
 {
   $Log$
-  Revision 1.10  1999-05-01 13:24:41  peter
+  Revision 1.11  1999-05-02 22:41:57  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.10  1999/05/01 13:24:41  peter
     * merged nasm compiler
     * old asm moved to oldasm/
 

+ 108 - 18
compiler/systems.pas

@@ -37,6 +37,12 @@ unit systems;
             ,MC68000,MC68100,MC68020
        );
 
+       tsection=(sec_none,
+         sec_code,sec_data,sec_bss,
+         sec_stab,sec_stabstr,
+         sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_edata,
+         sec_fake
+       );
 
      type
        tasmmode= (asmmode_none
@@ -150,6 +156,7 @@ unit systems;
           externals   : boolean;
           labelprefix : string[2];
           comment     : string[2];
+          secnames    : array[tsection] of string[20];
        end;
 
        tlinkinfo = packed record
@@ -471,7 +478,12 @@ implementation
             asmcmd : '-o $OBJ $ASM';
             externals : false;
             labelprefix : '.L';
-            comment : '# '
+            comment : '# ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '','','','','','',
+              '')
           )
           ,(
             id     : as_i386_as_aout;
@@ -480,7 +492,12 @@ implementation
             asmcmd : '-o $OBJ $ASM';
             externals : false;
             labelprefix : 'L';
-            comment : '# '
+            comment : '# ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '','','','','','',
+              '')
           )
           ,(
             id     : as_i386_asw;
@@ -489,7 +506,13 @@ implementation
             asmcmd : '-o $OBJ $ASM';
             externals : false;
             labelprefix : '.L';
-            comment : '# '
+            comment : '# ';
+            secnames : ('',
+              '.text','.data','.section .bss',
+              '.stab','.stabstr',
+              '.section .idata$2','.section .idata$4','.section .idata$5',
+                '.section .idata$6','.section .idata$7','.section .edata',
+              '')
           )
           ,(
             id     : as_i386_nasmcoff;
@@ -498,7 +521,12 @@ implementation
             asmcmd : '-f coff -o $OBJ $ASM';
             externals : true;
             labelprefix : 'L';
-            comment : '; '
+            comment : '; ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
+              '')
           )
           ,(
             id     : as_i386_nasmelf;
@@ -507,7 +535,12 @@ implementation
             asmcmd : '-f elf -o $OBJ $ASM';
             externals : true;
             labelprefix : 'L';
-            comment : '; '
+            comment : '; ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
+              '')
           )
           ,(
             id     : as_i386_nasmobj;
@@ -516,7 +549,12 @@ implementation
             asmcmd : '-f obj -o $OBJ $ASM';
             externals : true;
             labelprefix : 'L';
-            comment : '; '
+            comment : '; ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
+              '')
           )
           ,(
             id     : as_i386_tasm;
@@ -524,8 +562,12 @@ implementation
             asmbin : 'tasm';
             asmcmd : '/m2 $ASM $OBJ';
             externals : true;
-            labelprefix : 'L';
-            comment : '; '
+            labelprefix : '@@';
+            comment : '; ';
+            secnames : ('',
+              'CODE','DATA','BSS',
+              '','','','','','','','',
+              '')
           )
           ,(
             id     : as_i386_masm;
@@ -534,7 +576,11 @@ implementation
             asmcmd : '$ASM $OBJ';
             externals : true;
             labelprefix : '.L';
-            comment : '; '
+            comment : '; ';
+            secnames : ('',
+              'CODE','DATA','BSS',
+              '','','','','','','','',
+              '')
           )
           ,(
             id     : as_i386_dbg;
@@ -543,7 +589,12 @@ implementation
             asmcmd : '';
             externals : true;
             labelprefix : 'L';
-            comment : ''
+            comment : '';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
           ,(
             id     : as_i386_coff;
@@ -552,7 +603,12 @@ implementation
             asmcmd : '';
             externals : true;
             labelprefix : '.L';
-            comment : ''
+            comment : '';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
           ,(
             id     : as_i386_pecoff;
@@ -561,7 +617,12 @@ implementation
             asmcmd : '';
             externals : true;
             labelprefix : '.L';
-            comment : ''
+            comment : '';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
 {$endif i386}
 {$ifdef m68k}
@@ -572,7 +633,12 @@ implementation
             asmcmd : '-o $OBJ $ASM';
             externals : false;
             labelprefix : '.L';
-            comment : '# '
+            comment : '# ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
           ,(
             id     : as_m68k_gas;
@@ -581,7 +647,12 @@ implementation
             asmcmd : '--register-prefix-optional -o $OBJ $ASM';
             externals : false;
             labelprefix : '.L';
-            comment : '| '
+            comment : '| ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
           ,(
             id     : as_m68k_mit;
@@ -590,7 +661,12 @@ implementation
             asmcmd : '-o $OBJ $ASM';
             externals : false;
             labelprefix : '.L';
-            comment : '| '
+            comment : '| ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
           ,(
             id     : as_m68k_mot;
@@ -599,7 +675,12 @@ implementation
             asmcmd : '-o $OBJ $ASM';
             externals : false;
             labelprefix : '__L';
-            comment : '| '
+            comment : '| ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
           ,(
             id     : as_m68k_mpw;
@@ -608,7 +689,12 @@ implementation
             asmcmd : '-model far -o $OBJ $ASM';
             externals : false;
             labelprefix : '__L';
-            comment : '| '
+            comment : '| ';
+            secnames : ('',
+              '.text','.data','.bss',
+              '.stab','.stabstr',
+              '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+              '.fake')
           )
 {$endif m68k}
           );
@@ -1369,7 +1455,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.67  1999-05-01 14:18:12  peter
+  Revision 1.68  1999-05-02 22:41:59  peter
+    * moved section names to systems
+    * fixed nasm,intel writer
+
+  Revision 1.67  1999/05/01 14:18:12  peter
     * win32 pecoff disabled because it's still not ok
 
   Revision 1.66  1999/05/01 13:24:44  peter