ag68kmit.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. {
  2. $Id$
  3. Copyright (c) 1998 by the FPC development team
  4. This unit implements an asmoutput class for MIT syntax with
  5. Motorola 68000 (for MIT syntax TEST WITH GAS v1.34)
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. What's to do:
  19. o Verify if this actually work as indirect mode with name of variables
  20. o write lines numbers and file names to output file
  21. o generate debugging informations
  22. }
  23. unit ag68kmit;
  24. interface
  25. uses aasm,assemble;
  26. type
  27. pm68kmitasmlist=^tm68kmitasmlist;
  28. tm68kmitasmlist = object(tasmlist)
  29. procedure WriteTree(p:paasmoutput);virtual;
  30. procedure WriteAsmList;virtual;
  31. end;
  32. implementation
  33. uses
  34. dos,globals,systems,cobjects,m68k,
  35. strings,files,verbose
  36. {$ifdef GDB}
  37. ,gdb
  38. {$endif GDB}
  39. ;
  40. const
  41. line_length = 70;
  42. {$ifdef GDB}
  43. var
  44. infile : pextfile;
  45. includecount,
  46. lastline : longint;
  47. {$endif GDB}
  48. function double2str(d : double) : string;
  49. var
  50. hs : string;
  51. begin
  52. str(d,hs);
  53. { replace space with + }
  54. if hs[1]=' ' then
  55. hs[1]:='+';
  56. double2str:=hs;
  57. end;
  58. function comp2str(d : bestreal) : string;
  59. type
  60. pdouble = ^double;
  61. var
  62. c : comp;
  63. dd : pdouble;
  64. begin
  65. {$ifdef TP}
  66. c:=d;
  67. {$else}
  68. c:=comp(d);
  69. {$endif}
  70. dd:=pdouble(@c); { this makes a bitwise copy of c into a double }
  71. comp2str:=double2str(dd^);
  72. end;
  73. function getreferencestring(const ref : treference) : string;
  74. var
  75. s : string;
  76. begin
  77. s:='';
  78. if ref.isintvalue then
  79. s:='#'+tostr(ref.offset)
  80. else
  81. with ref do
  82. begin
  83. { symbol and offset }
  84. if (assigned(symbol)) and (offset<>0) then
  85. Begin
  86. s:=s+'('+tostr(offset)+symbol^;
  87. end
  88. else
  89. { symbol only }
  90. if (assigned(symbol)) and (offset=0) then
  91. Begin
  92. s:=s+'('+symbol^;
  93. end
  94. else
  95. { offset only }
  96. if (symbol=nil) and (offset<>0) then
  97. Begin
  98. s:=s+'('+tostr(offset);
  99. end
  100. else
  101. { NOTHING - put zero as offset }
  102. if (symbol=nil) and (offset=0) then
  103. Begin
  104. s:=s+'('+'0';
  105. end
  106. else
  107. InternalError(10004);
  108. if (index<>R_NO) and (base=R_NO) and (direction=dir_none) then
  109. InternalError(10004)
  110. else if (index=R_NO) and (base<>R_NO) and (direction=dir_inc) then
  111. begin
  112. if (scalefactor = 1) or (scalefactor = 0) then
  113. Begin
  114. if offset<>0 then
  115. s:=mit_reg2str[base]+'@+'+s+')'
  116. else
  117. s:=mit_reg2str[base]+'@+';
  118. end
  119. else
  120. InternalError(10002);
  121. end
  122. else if (index=R_NO) and (base<>R_NO) and (direction=dir_dec) then
  123. begin
  124. if (scalefactor = 1) or (scalefactor = 0) then
  125. Begin
  126. if offset<>0 then
  127. s:=mit_reg2str[base]+'@-'+s+')'
  128. else
  129. s:=mit_reg2str[base]+'@-';
  130. end
  131. else
  132. InternalError(10003);
  133. end
  134. else if (index=R_NO) and (base<>R_NO) and (direction=dir_none) then
  135. begin
  136. if (offset=0) and (symbol=nil) then
  137. s:=mit_reg2str[base]+'@'
  138. else
  139. s:=mit_reg2str[base]+'@'+s+')';
  140. end
  141. else if (index<>R_NO) and (base<>R_NO) and (direction=dir_none) then
  142. begin
  143. s:=mit_reg2str[base]+'@'+s+','+mit_reg2str[index]+':L';
  144. if (scalefactor = 1) or (scalefactor = 0) then
  145. s:=s+')'
  146. else
  147. s:=s+':'+tostr(scalefactor)+')';
  148. end
  149. else
  150. if assigned(symbol) then
  151. Begin
  152. s:=symbol^;
  153. if offset<>0 then
  154. s:=s+'+'+tostr(offset);
  155. end
  156. { this must be a physical address }
  157. else
  158. s:=s+')';
  159. { else if NOT assigned(symbol) then
  160. InternalError(10004);}
  161. end; { end with }
  162. getreferencestring:=s;
  163. end;
  164. function getopstr(t : byte;o : pointer) : string;
  165. var
  166. hs : string;
  167. i: tregister;
  168. begin
  169. case t of
  170. top_reg : getopstr:=mit_reg2str[tregister(o)];
  171. top_ref : getopstr:=getreferencestring(preference(o)^);
  172. top_reglist: begin
  173. hs:='';
  174. for i:=R_NO to R_FPSR do
  175. begin
  176. if i in tregisterlist(o^) then
  177. hs:=hs+mit_reg2str[i]+'/';
  178. end;
  179. delete(hs,length(hs),1);
  180. getopstr := hs;
  181. end;
  182. top_const : getopstr:='#'+tostr(longint(o));
  183. top_symbol :
  184. { compare with i386, where a symbol is considered }
  185. { a constant. }
  186. begin
  187. hs[0]:=chr(strlen(pchar(pcsymbol(o)^.symbol)));
  188. move(pchar(pcsymbol(o)^.symbol)^,hs[1],byte(hs[0]));
  189. { inc(byte(hs[0]));}
  190. if pcsymbol(o)^.offset>0 then
  191. hs:=hs+'+'+tostr(pcsymbol(o)^.offset)
  192. else if pcsymbol(o)^.offset<0 then
  193. hs:=hs+tostr(pcsymbol(o)^.offset);
  194. getopstr:=hs;
  195. end;
  196. else internalerror(10001);
  197. end;
  198. end;
  199. function getopstr_jmp(t : byte;o : pointer) : string;
  200. var
  201. hs : string;
  202. begin
  203. case t of
  204. top_reg : getopstr_jmp:=mit_reg2str[tregister(o)];
  205. top_ref : getopstr_jmp:=getreferencestring(preference(o)^);
  206. top_const : getopstr_jmp:=tostr(longint(o));
  207. top_symbol : begin
  208. hs[0]:=chr(strlen(pchar(pcsymbol(o)^.symbol)));
  209. move(pchar(pcsymbol(o)^.symbol)^,hs[1],byte(hs[0]));
  210. if pcsymbol(o)^.offset>0 then
  211. hs:=hs+'+'+tostr(pcsymbol(o)^.offset)
  212. else if pcsymbol(o)^.offset<0 then
  213. hs:=hs+tostr(pcsymbol(o)^.offset);
  214. getopstr_jmp:=hs;
  215. end;
  216. else internalerror(10001);
  217. end;
  218. end;
  219. {****************************************************************************
  220. T68kGASASMOUTPUT
  221. ****************************************************************************}
  222. var
  223. {$ifdef GDB}
  224. n_line : byte; { different types of source lines }
  225. {$endif}
  226. lastsec : tsection; { last section type written }
  227. const
  228. ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
  229. (#9'.long'#9,'',#9'.short'#9,#9'.byte'#9);
  230. ait_section2str : array[tsection] of string[6]=
  231. ('','.text','.data','.bss','.idata');
  232. procedure tm68kmitasmlist.WriteTree(p:paasmoutput);
  233. var
  234. hp : pai;
  235. ch : char;
  236. consttyp : tait;
  237. s : string;
  238. pos,l,i : longint;
  239. found : boolean;
  240. {$ifdef GDB}
  241. funcname : pchar;
  242. linecount : longint;
  243. {$endif GDB}
  244. begin
  245. if not assigned(p) then
  246. exit;
  247. {$ifdef GDB}
  248. funcname:=nil;
  249. linecount:=1;
  250. {$endif GDB}
  251. hp:=pai(p^.first);
  252. while assigned(hp) do
  253. begin
  254. { write debugger informations }
  255. {$ifdef GDB}
  256. if cs_debuginfo in aktswitches then
  257. begin
  258. if not (hp^.typ in [ait_external,ait_stabn,ait_stabs,ait_stab_function_name]) then
  259. begin
  260. if assigned(hp^.infile) and (pextfile(hp^.infile)<>infile) then
  261. begin
  262. infile:=hp^.infile;
  263. inc(includecount);
  264. if (hp^.infile^.path^<>'') then
  265. begin
  266. AsmWriteLn(#9'.stabs "'+FixPath(hp^.infile^.path^)+'",'+tostr(n_includefile)+
  267. ',0,0,Ltext'+ToStr(IncludeCount));
  268. end;
  269. AsmWriteLn(#9'.stabs "'+FixFileName(hp^.infile^.name^+hp^.infile^.ext^)+'",'+tostr(n_includefile)+
  270. ',0,0,Ltext'+ToStr(IncludeCount));
  271. AsmWriteLn('Ltext'+ToStr(IncludeCount)+':');
  272. end;
  273. { file name must be there before line number ! }
  274. if (hp^.line<>lastline) and (hp^.line<>0) then
  275. begin
  276. if (n_line = n_textline) and assigned(funcname) and
  277. (target_os.use_function_relative_addresses) then
  278. begin
  279. AsmWriteLn(target_asm.labelprefix+'l'+tostr(linecount)+':');
  280. AsmWriteLn(#9'.stabn '+tostr(n_line)+',0,'+tostr(hp^.line)+','+
  281. target_asm.labelprefix+'l'+tostr(linecount)+' - '+StrPas(FuncName));
  282. inc(linecount);
  283. end
  284. else
  285. AsmWriteLn(#9'.stabd'#9+tostr(n_line)+',0,'+tostr(hp^.line));
  286. lastline:=hp^.line;
  287. end;
  288. end;
  289. end;
  290. {$endif GDB}
  291. case hp^.typ of
  292. ait_external : ; { external is ignored }
  293. ait_comment : Begin
  294. AsmWrite(target_asm.comment);
  295. AsmWritePChar(pai_asm_comment(hp)^.str);
  296. AsmLn;
  297. End;
  298. {$ifdef DREGALLOC}
  299. ait_regalloc : AsmWriteLn(target_asm.comment+'Register '+att_reg2str[pairegalloc(hp)^.reg]+' allocated');
  300. ait_regdealloc : AsmWriteLn(target_asm.comment+'Register '+att_reg2str[pairegalloc(hp)^.reg]+' released');
  301. {$endif DREGALLOC}
  302. ait_align : AsmWriteLn(#9'.align '+tostr(pai_align(hp)^.aligntype));
  303. ait_section : begin
  304. if pai_section(hp)^.sec<>sec_none then
  305. begin
  306. AsmLn;
  307. AsmWrite(ait_section2str[pai_section(hp)^.sec]);
  308. if pai_section(hp)^.idataidx>0 then
  309. AsmWrite('$'+tostr(pai_section(hp)^.idataidx));
  310. AsmLn;
  311. {$ifdef GDB}
  312. case pai_section(hp)^.sec of
  313. sec_code : n_line:=n_textline;
  314. sec_data : n_line:=n_dataline;
  315. sec_bss : n_line:=n_bssline;
  316. end;
  317. {$endif GDB}
  318. end;
  319. LastSec:=pai_section(hp)^.sec;
  320. end;
  321. ait_datablock : begin
  322. { ------------------------------------------------------- }
  323. { ----------- ALIGNMENT FOR ANY NON-BYTE VALUE ---------- }
  324. { ------------- REQUIREMENT FOR 680x0 ------------------- }
  325. { ------------------------------------------------------- }
  326. if pai_datablock(hp)^.size <> 1 then
  327. begin
  328. if not(cs_littlesize in aktswitches) then
  329. AsmWriteLn(#9#9'.align 4')
  330. else
  331. AsmWriteLn(#9#9'.align 2');
  332. end;
  333. if pai_datablock(hp)^.is_global then
  334. AsmWrite(#9'.comm'#9)
  335. else
  336. AsmWrite(#9'.lcomm'#9);
  337. AsmWriteLn(StrPas(pai_datablock(hp)^.name)+','+tostr(pai_datablock(hp)^.size));
  338. end;
  339. ait_const_32bit, { alignment is required for 16/32 bit data! }
  340. ait_const_16bit: begin
  341. if not(cs_littlesize in aktswitches) then
  342. AsmWriteLn(#9#9'.align 4')
  343. else
  344. AsmWriteLn(#9#9'.align 2');
  345. AsmWrite(ait_const2str[hp^.typ]+tostr(pai_const(hp)^.value));
  346. consttyp:=hp^.typ;
  347. l:=0;
  348. repeat
  349. found:=(not (Pai(hp^.next)=nil)) and (Pai(hp^.next)^.typ=consttyp);
  350. if found then
  351. begin
  352. hp:=Pai(hp^.next);
  353. s:=','+tostr(pai_const(hp)^.value);
  354. AsmWrite(s);
  355. inc(l,length(s));
  356. end;
  357. until (not found) or (l>line_length);
  358. AsmLn;
  359. end;
  360. ait_const_8bit : begin
  361. AsmWrite(ait_const2str[hp^.typ]+tostr(pai_const(hp)^.value));
  362. consttyp:=hp^.typ;
  363. l:=0;
  364. repeat
  365. found:=(not (Pai(hp^.next)=nil)) and (Pai(hp^.next)^.typ=consttyp);
  366. if found then
  367. begin
  368. hp:=Pai(hp^.next);
  369. s:=','+tostr(pai_const(hp)^.value);
  370. AsmWrite(s);
  371. inc(l,length(s));
  372. end;
  373. until (not found) or (l>line_length);
  374. AsmLn;
  375. end;
  376. ait_const_symbol : begin
  377. if not(cs_littlesize in aktswitches) then
  378. AsmWriteLn(#9#9'.align 4')
  379. else
  380. AsmWriteLn(#9#9'.align 2');
  381. AsmWrite(#9'.long'#9);
  382. AsmWritePChar(pchar(pai_const(hp)^.value));
  383. AsmLn;
  384. end;
  385. ait_real_64bit : Begin
  386. if not(cs_littlesize in aktswitches) then
  387. AsmWriteLn(#9#9'.align 4')
  388. else
  389. AsmWriteLn(#9#9'.align 2');
  390. AsmWriteLn(#9'.double'#9+double2str(pai_double(hp)^.value));
  391. end;
  392. ait_real_32bit : Begin
  393. if not(cs_littlesize in aktswitches) then
  394. AsmWriteLn(#9#9'.align 4')
  395. else
  396. AsmWriteLn(#9#9'.align 2');
  397. AsmWriteLn(#9'.single'#9+double2str(pai_single(hp)^.value));
  398. end;
  399. ait_real_extended : Begin
  400. if not(cs_littlesize in aktswitches) then
  401. AsmWriteLn(#9#9'.align 4')
  402. else
  403. AsmWriteLn(#9#9'.align 2');
  404. AsmWriteLn(#9'.extend'#9+double2str(pai_extended(hp)^.value));
  405. { comp type is difficult to write so use double }
  406. end;
  407. ait_comp : Begin
  408. if not(cs_littlesize in aktswitches) then
  409. AsmWriteLn(#9#9'.align 4')
  410. else
  411. AsmWriteLn(#9#9'.align 2');
  412. AsmWriteLn(#9'.double'#9+comp2str(pai_extended(hp)^.value));
  413. end;
  414. ait_direct : begin
  415. AsmWritePChar(pai_direct(hp)^.str);
  416. AsmLn;
  417. {$IfDef GDB}
  418. if strpos(pai_direct(hp)^.str,'.data')<>nil then
  419. n_line:=n_dataline
  420. else if strpos(pai_direct(hp)^.str,'.text')<>nil then
  421. n_line:=n_textline
  422. else if strpos(pai_direct(hp)^.str,'.bss')<>nil then
  423. n_line:=n_bssline;
  424. {$endif GDB}
  425. end;
  426. ait_string : begin
  427. pos:=0;
  428. for i:=1 to pai_string(hp)^.len do
  429. begin
  430. if pos=0 then
  431. begin
  432. AsmWrite(#9'.ascii'#9'"');
  433. pos:=20;
  434. end;
  435. ch:=pai_string(hp)^.str[i-1];
  436. case ch of
  437. #0, {This can't be done by range, because a bug in FPC}
  438. #1..#31,
  439. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  440. '"' : s:='\"';
  441. '\' : s:='\\';
  442. else
  443. s:=ch;
  444. end;
  445. AsmWrite(s);
  446. inc(pos,length(s));
  447. if (pos>line_length) or (i=pai_string(hp)^.len) then
  448. begin
  449. AsmWriteLn('"');
  450. pos:=0;
  451. end;
  452. end;
  453. end;
  454. ait_label : begin
  455. if (pai_label(hp)^.l^.is_used) then
  456. AsmWriteLn(lab2str(pai_label(hp)^.l)+':');
  457. end;
  458. ait_labeled_instruction : begin
  459. { labeled operand }
  460. if pai_labeled(hp)^._op1 = R_NO then
  461. AsmWriteLn(#9+mot_op2str[pai_labeled(hp)^._operator]+#9+lab2str(pai_labeled(hp)^.lab))
  462. else
  463. { labeled operand with register }
  464. AsmWriteLn(#9+mot_op2str[pai_labeled(hp)^._operator]+#9+
  465. reg2str(pai_labeled(hp)^._op1)+','+lab2str(pai_labeled(hp)^.lab))
  466. end;
  467. ait_symbol : begin
  468. { ------------------------------------------------------- }
  469. { ----------- ALIGNMENT FOR ANY NON-BYTE VALUE ---------- }
  470. { ------------- REQUIREMENT FOR 680x0 ------------------- }
  471. { ------------------------------------------------------- }
  472. if assigned(hp^.next) and (pai(hp^.next)^.typ in
  473. [ait_const_32bit,ait_const_16bit,ait_const_symbol,
  474. ait_real_64bit,ait_real_32bit,ait_string]) then
  475. begin
  476. if not(cs_littlesize in aktswitches) then
  477. AsmWriteLn(#9#9'.align 4')
  478. else
  479. AsmWriteLn(#9#9'.align 2');
  480. end;
  481. if pai_symbol(hp)^.is_global then
  482. AsmWriteLn('.globl '+StrPas(pai_symbol(hp)^.name));
  483. AsmWriteLn(StrPas(pai_symbol(hp)^.name)+':');
  484. end;
  485. ait_instruction : begin
  486. { old versions of GAS don't like PEA.L and LEA.L }
  487. if (pai68k(hp)^._operator in [
  488. A_LEA,A_PEA,A_ABCD,A_BCHG,A_BCLR,A_BSET,A_BTST,
  489. A_EXG,A_NBCD,A_SBCD,A_SWAP,A_TAS,A_SCC,A_SCS,
  490. A_SEQ,A_SGE,A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,
  491. A_SNE,A_SPL,A_ST,A_SVC,A_SVS,A_SF]) then
  492. s:=#9+mot_op2str[pai68k(hp)^._operator]
  493. else
  494. s:=#9+mot_op2str[pai68k(hp)^._operator]+mit_opsize2str[pai68k(hp)^.size];
  495. if pai68k(hp)^.op1t<>top_none then
  496. begin
  497. { call and jmp need an extra handling }
  498. { this code is only callded if jmp isn't a labeled instruction }
  499. if pai68k(hp)^._operator in [A_JSR,A_JMP] then
  500. s:=s+#9+getopstr_jmp(pai68k(hp)^.op1t,pai68k(hp)^.op1)
  501. else
  502. if pai68k(hp)^.op1t = top_reglist then
  503. s:=s+#9+getopstr(pai68k(hp)^.op1t,@(pai68k(hp)^.reglist))
  504. else
  505. s:=s+#9+getopstr(pai68k(hp)^.op1t,pai68k(hp)^.op1);
  506. if pai68k(hp)^.op2t<>top_none then
  507. begin
  508. if pai68k(hp)^.op2t = top_reglist then
  509. s:=s+','+getopstr(pai68k(hp)^.op2t,@pai68k(hp)^.reglist)
  510. else
  511. s:=s+','+getopstr(pai68k(hp)^.op2t,pai68k(hp)^.op2);
  512. { three operands }
  513. if pai68k(hp)^.op3t<>top_none then
  514. begin
  515. if (pai68k(hp)^._operator = A_DIVSL) or
  516. (pai68k(hp)^._operator = A_DIVUL) or
  517. (pai68k(hp)^._operator = A_MULU) or
  518. (pai68k(hp)^._operator = A_MULS) or
  519. (pai68k(hp)^._operator = A_DIVS) or
  520. (pai68k(hp)^._operator = A_DIVU) then
  521. s:=s+':'+getopstr(pai68k(hp)^.op3t,pai68k(hp)^.op3)
  522. else
  523. s:=s+','+getopstr(pai68k(hp)^.op3t,pai68k(hp)^.op3);
  524. end;
  525. end;
  526. end;
  527. AsmWriteLn(s);
  528. end;
  529. {$ifdef GDB}
  530. ait_stabs : begin
  531. AsmWrite(#9'.stabs ');
  532. AsmWritePChar(pai_stabs(hp)^.str);
  533. AsmLn;
  534. end;
  535. ait_stabn : begin
  536. AsmWrite(#9'.stabn ');
  537. AsmWritePChar(pai_stabn(hp)^.str);
  538. AsmLn;
  539. end;
  540. ait_stab_function_name : funcname:=pai_stab_function_name(hp)^.str;
  541. {$endif GDB}
  542. else
  543. internalerror(10000);
  544. end;
  545. hp:=pai(hp^.next);
  546. end;
  547. end;
  548. procedure tm68kmitasmlist.WriteAsmList;
  549. {$ifdef GDB}
  550. var
  551. p:dirstr;
  552. n:namestr;
  553. e:extstr;
  554. {$endif}
  555. begin
  556. {$ifdef EXTDEBUG}
  557. if assigned(current_module^.mainsource) then
  558. comment(v_info,'Start writing gas-styled assembler output for '+current_module^.mainsource^);
  559. {$endif}
  560. {$ifdef GDB}
  561. infile:=nil;
  562. includecount:=0;
  563. if assigned(current_module^.mainsource) then
  564. fsplit(current_module^.mainsource^,p,n,e)
  565. else
  566. begin
  567. p:=inputdir;
  568. n:=inputfile;
  569. e:=inputextension;
  570. end;
  571. { to get symify to work }
  572. AsmWriteLn(#9'.file "'+FixFileName(n+e)+'"');
  573. { stabs }
  574. n_line:=n_bssline;
  575. if (cs_debuginfo in aktswitches) then
  576. begin
  577. if (p<>'') then
  578. AsmWriteLn(#9'.stabs "'+FixPath(p)+'",'+tostr(n_sourcefile)+',0,0,Ltext0');
  579. AsmWriteLn(#9'.stabs "'+FixFileName(n+e)+'",'+tostr(n_sourcefile)+',0,0,Ltext0');
  580. AsmWriteLn('Ltext0:');
  581. end;
  582. infile:=current_module^.sourcefiles.files;
  583. { main source file is last in list }
  584. while assigned(infile^._next) do
  585. infile:=infile^._next;
  586. lastline:=0;
  587. {$endif GDB}
  588. { there should be nothing but externals so we don't need to process
  589. WriteTree(externals); }
  590. WriteTree(debuglist);
  591. WriteTree(codesegment);
  592. WriteTree(datasegment);
  593. WriteTree(consts);
  594. WriteTree(rttilist);
  595. WriteTree(bsssegment);
  596. Writetree(importssection);
  597. Writetree(exportssection);
  598. Writetree(resourcesection);
  599. AsmLn;
  600. {$ifdef EXTDEBUG}
  601. if assigned(current_module^.mainsource) then
  602. comment(v_info,'Done writing gas-styled assembler output for '+current_module^.mainsource^);
  603. {$endif EXTDEBUG}
  604. end;
  605. end.
  606. {
  607. $Log$
  608. Revision 1.5 1998-06-05 17:46:05 peter
  609. * tp doesn't like comp() typecast
  610. Revision 1.4 1998/06/04 23:51:29 peter
  611. * m68k compiles
  612. + .def file creation moved to gendef.pas so it could also be used
  613. for win32
  614. }