3 Copyright (c) 1998-2000 by Peter Vreman
5 Contains the 386 binary writer for debugging purposes
7 * This code was inspired by the NASM sources
8 The Netwide Assembler is copyright (C) 1996 Simon Tatham and
9 Julian Hall. All rights reserved.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 ****************************************************************************
31 systems
,aasm
,cpubase
,og386
;
34 pdbgoutput
= ^tdbgoutput
;
35 tdbgoutput
= object(tobjectoutput
)
38 constructor init(smart
:boolean);
39 destructor done
;virtual;
40 procedure initwriting(Aplace
:tcutplace
);virtual;
41 procedure donewriting
;virtual;
42 procedure writebytes(var data
;len
:longint);virtual;
43 procedure writealloc(len
:longint);virtual;
44 procedure writereloc(data
,len
:longint;p
:pasmsymbol
;relative
:relative_type
);virtual;
45 procedure writesymbol(p
:pasmsymbol
);virtual;
46 procedure writestabs(section
:tsection
;offset
:longint;p
:pchar
;nidx
,nother
,line
:longint;reloc
:boolean);virtual;
51 {****************************************************************************
53 ****************************************************************************}
55 constructor tdbgoutput
.init(smart
:boolean);
57 inherited init(smart
);
63 destructor tdbgoutput
.done
;
68 procedure tdbgoutput
.initwriting(Aplace
:tcutplace
);
70 inherited initwriting(Aplace
);
71 writeln('initwriting '+Objfile
);
75 procedure tdbgoutput
.donewriting
;
82 writeln('donewriting');
86 procedure tdbgoutput
.writesymbol(p
:pasmsymbol
);
94 write('symbol [',nsyms
,'] '+p
^.name
+' (',target_asm
.secnames
[p
^.section
],',',p
^.address
,',',p
^.size
,',');
109 procedure tdbgoutput
.writereloc(data
,len
:longint;p
:pasmsymbol
;relative
:relative_type
);
117 write('reloc: ',data
,' [',target_asm
.secnames
[p
^.section
],',',p
^.address
,']')
119 write('reloc: ',data
);
121 relative_true
: writeln(' relative');
122 relative_false
: writeln(' not relative');
123 relative_rva
: writeln(' relative virtual address');
128 procedure tdbgoutput
.writebytes(var data
;len
:longint);
130 function hexstr(val
: longint;cnt
: byte) : string;
132 HexTbl
: array[0..15] of char='0123456789ABCDEF';
136 hexstr
[0]:=char(cnt
);
137 for i
:=cnt
downto 1 do
139 hexstr
[i
]:=hextbl
[val
and $f];
164 write(hexstr(ord(p
[i
-1]),2),' ');
169 procedure tdbgoutput
.writealloc(len
:longint);
171 writeln('alloc: ',len
);
174 procedure tdbgoutput
.writestabs(section
:tsection
;offset
:longint;p
:pchar
;nidx
,nother
,line
:longint;reloc
:boolean);
176 writeln('stabs: ',line
,',',nidx
,'"',p
,'"');
183 Revision 1.1 2002/02/19 08:22:37 sasu
186 Revision 1.1 2000/07/13 06:29:52 michael
189 Revision 1.8 2000/02/09 13:22:54 peter
192 Revision 1.7 2000/01/07 01:14:27 peter
193 * updated copyright to 2000
195 Revision 1.6 1999/11/02 15:06:57 peter
196 * import library fixes for win32
197 * alignment works again
199 Revision 1.5 1999/08/04 00:23:06 florian
200 * renamed i386asm and i386base to cpuasm and cpubase