Browse Source

* small fixes for the binary writer

peter 26 years ago
parent
commit
23f7e0c601
2 changed files with 59 additions and 24 deletions
  1. 33 19
      compiler/aasm.pas
  2. 26 5
      compiler/assemble.pas

+ 33 - 19
compiler/aasm.pas

@@ -121,6 +121,7 @@ unit aasm;
        plabel = ^tlabel;
        tlabel = record
                   nb       : longint;
+                  address  : longint;
                   is_data  : boolean;
                   is_used  : boolean;
                   is_set   : boolean;
@@ -132,6 +133,7 @@ unit aasm;
           l : plabel;
           constructor init(_l : plabel);
           destructor done; virtual;
+          procedure setaddress(offset:longint);
        end;
 
 
@@ -155,9 +157,10 @@ unit aasm;
        { alignment for operator }
        pai_align = ^tai_align;
        tai_align = object(tai)
-          aligntype: byte;   { 1 = no align, 2 = word align, 4 = dword align }
-          op: byte;          { value to fill with - optional                 }
-          use_op : boolean;
+          aligntype : byte;   { 1 = no align, 2 = word align, 4 = dword align }
+          fillsize  : byte;   { real size to fill }
+          fillop    : byte;   { value to fill with - optional }
+          use_op    : boolean;
           constructor init(b:byte);
           constructor init_op(b: byte; _op: byte);
           destructor done;virtual;
@@ -622,26 +625,32 @@ uses
                                TAI_LABEL
  ****************************************************************************}
 
-     constructor tai_label.init(_l : plabel);
+    constructor tai_label.init(_l : plabel);
+      begin
+        inherited init;
+        typ:=ait_label;
+        l:=_l;
+        l^.is_set:=true;
+      end;
 
-       begin
-          inherited init;
-          typ:=ait_label;
-          l:=_l;
-          l^.is_set:=true;
-       end;
 
     destructor tai_label.done;
+      begin
+        if (l^.refcount>0) then
+        { can now be disposed by a tai_labeled instruction !! }
+          l^.is_set:=false
+        else
+          dispose(l);
+        inherited done;
+      end;
 
+
+   procedure tai_label.setaddress(offset:longint);
       begin
-         if (l^.refcount>0) then
-         { can now be disposed by a tai_labeled instruction !! }
-           l^.is_set:=false
-         else
-           dispose(l);
-         inherited done;
+        l^.address:=offset;
       end;
 
+
 {****************************************************************************
                               TAI_DIRECT
  ****************************************************************************}
@@ -693,7 +702,8 @@ uses
             aligntype := b
           else
             aligntype := 1;
-          op:=0;
+          fillsize:=0;
+          fillop:=0;
           use_op:=false;
        end;
 
@@ -707,7 +717,8 @@ uses
             aligntype := b
           else
             aligntype := 1;
-          op:=_op;
+          fillsize:=0;
+          fillop:=_op;
           use_op:=true;
        end;
 
@@ -912,7 +923,10 @@ uses
 end.
 {
   $Log$
-  Revision 1.29  1998-12-29 18:48:24  jonas
+  Revision 1.30  1999-02-17 10:16:24  peter
+    * small fixes for the binary writer
+
+  Revision 1.29  1998/12/29 18:48:24  jonas
     + optimize pascal code surrounding assembler blocks
 
   Revision 1.28  1998/12/16 00:27:16  peter

+ 26 - 5
compiler/assemble.pas

@@ -472,13 +472,31 @@ end;
 Procedure GenerateAsm;
 var
   a : PAsmList;
+{$ifdef i386}
+  {$ifdef Ag386Bin}
+    b : Pi386binasmlist
+  {$endif}
+{$endif}
 begin
   case aktoutputformat of
 {$ifdef i386}
-  {$ifdef Ag386Cof}
-     as_i386_coff :
-       a:=new(pi386coffasmlist,Init);
-  {$endif Ag386Cof}
+  {$ifdef Ag386Bin}
+     as_i386_dbg,
+     as_i386_coff,
+     as_i386_pecoff :
+       begin
+         case aktoutputformat of
+           as_i386_dbg :
+             b:=new(pi386binasmlist,Init(og_dbg));
+           as_i386_coff :
+             b:=new(pi386binasmlist,Init(og_coff));
+           as_i386_pecoff :
+             b:=new(pi386binasmlist,Init(og_pecoff));
+         end;
+         b^.WriteBin;
+         dispose(b,done);
+       end;
+  {$endif Ag386Bin}
   {$ifndef NoAg386Att}
      as_i386_o,
      as_i386_o_aout,
@@ -540,7 +558,10 @@ end;
 end.
 {
   $Log$
-  Revision 1.34  1999-01-10 15:37:52  peter
+  Revision 1.35  1999-02-17 10:16:26  peter
+    * small fixes for the binary writer
+
+  Revision 1.34  1999/01/10 15:37:52  peter
     * moved some tables from ra386*.pas -> i386.pas
     + start of coff writer
     * renamed asmutils unit to rautils