ag68kmit.pas 26 KB

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