ag68kmit.pas 26 KB

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