ag68kmit.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  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 then
  265. begin
  266. if not (hp^.typ in [ait_external,ait_regalloc, ait_regdealloc,ait_stabn,ait_stabs,
  267. ait_label,ait_cut,ait_marker,ait_align,ait_stab_function_name]) then
  268. begin
  269. { file changed ? (must be before line info) }
  270. if lastfileindex<>hp^.fileinfo.fileindex then
  271. begin
  272. infile:=current_module^.sourcefiles^.get_file(hp^.fileinfo.fileindex);
  273. if includecount=0 then
  274. curr_n:=n_sourcefile
  275. else
  276. curr_n:=n_includefile;
  277. if (infile^.path^<>'') then
  278. begin
  279. AsmWriteLn(#9'.stabs "'+lower(BsToSlash(FixPath(infile^.path^,false)))+'",'+
  280. tostr(curr_n)+',0,0,'+'Ltext'+ToStr(IncludeCount));
  281. end;
  282. AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile^.name^))+'",'+
  283. tostr(curr_n)+',0,0,'+'Ltext'+ToStr(IncludeCount));
  284. AsmWriteLn('Ltext'+ToStr(IncludeCount)+':');
  285. inc(includecount);
  286. lastfileindex:=hp^.fileinfo.fileindex;
  287. end;
  288. { line changed ? }
  289. if (hp^.fileinfo.line<>lastline) and (hp^.fileinfo.line<>0) then
  290. begin
  291. if (n_line=n_textline) and assigned(funcname) and
  292. (target_os.use_function_relative_addresses) then
  293. begin
  294. AsmWriteLn(target_asm.labelprefix+'l'+tostr(linecount)+':');
  295. AsmWrite(#9'.stabn '+tostr(n_line)+',0,'+tostr(hp^.fileinfo.line)+','+
  296. target_asm.labelprefix+'l'+tostr(linecount)+' - ');
  297. AsmWritePChar(FuncName);
  298. AsmLn;
  299. inc(linecount);
  300. end
  301. else
  302. AsmWriteLn(#9'.stabd'#9+tostr(n_line)+',0,'+tostr(hp^.fileinfo.line));
  303. lastline:=hp^.fileinfo.line;
  304. end;
  305. end;
  306. end;
  307. {$endif GDB}
  308. case hp^.typ of
  309. ait_external : ; { external is ignored }
  310. ait_comment : Begin
  311. AsmWrite(target_asm.comment);
  312. AsmWritePChar(pai_asm_comment(hp)^.str);
  313. AsmLn;
  314. End;
  315. {$ifdef DREGALLOC}
  316. ait_regalloc : AsmWriteLn(target_asm.comment+'Register '+att_reg2str[pairegalloc(hp)^.reg]+' allocated');
  317. ait_regdealloc : AsmWriteLn(target_asm.comment+'Register '+att_reg2str[pairegalloc(hp)^.reg]+' released');
  318. {$endif DREGALLOC}
  319. ait_align : AsmWriteLn(#9'.align '+tostr(pai_align(hp)^.aligntype));
  320. ait_section : begin
  321. if pai_section(hp)^.sec<>sec_none then
  322. begin
  323. AsmLn;
  324. AsmWrite(ait_section2str[pai_section(hp)^.sec]);
  325. if pai_section(hp)^.idataidx>0 then
  326. AsmWrite('$'+tostr(pai_section(hp)^.idataidx));
  327. AsmLn;
  328. {$ifdef GDB}
  329. case pai_section(hp)^.sec of
  330. sec_code : n_line:=n_textline;
  331. sec_data : n_line:=n_dataline;
  332. sec_bss : n_line:=n_bssline;
  333. end;
  334. {$endif GDB}
  335. end;
  336. LastSec:=pai_section(hp)^.sec;
  337. end;
  338. ait_datablock : begin
  339. { ------------------------------------------------------- }
  340. { ----------- ALIGNMENT FOR ANY NON-BYTE VALUE ---------- }
  341. { ------------- REQUIREMENT FOR 680x0 ------------------- }
  342. { ------------------------------------------------------- }
  343. if pai_datablock(hp)^.size <> 1 then
  344. begin
  345. if not(cs_littlesize in aktglobalswitches) then
  346. AsmWriteLn(#9#9'.align 4')
  347. else
  348. AsmWriteLn(#9#9'.align 2');
  349. end;
  350. if pai_datablock(hp)^.is_global then
  351. AsmWrite(#9'.comm'#9)
  352. else
  353. AsmWrite(#9'.lcomm'#9);
  354. AsmWriteLn(StrPas(pai_datablock(hp)^.name)+','+tostr(pai_datablock(hp)^.size));
  355. end;
  356. ait_const_32bit, { alignment is required for 16/32 bit data! }
  357. ait_const_16bit: begin
  358. AsmWrite(ait_const2str[hp^.typ]+tostr(pai_const(hp)^.value));
  359. consttyp:=hp^.typ;
  360. l:=0;
  361. repeat
  362. found:=(not (Pai(hp^.next)=nil)) and (Pai(hp^.next)^.typ=consttyp);
  363. if found then
  364. begin
  365. hp:=Pai(hp^.next);
  366. s:=','+tostr(pai_const(hp)^.value);
  367. AsmWrite(s);
  368. inc(l,length(s));
  369. end;
  370. until (not found) or (l>line_length);
  371. AsmLn;
  372. end;
  373. ait_const_8bit : begin
  374. AsmWrite(ait_const2str[hp^.typ]+tostr(pai_const(hp)^.value));
  375. consttyp:=hp^.typ;
  376. l:=0;
  377. repeat
  378. found:=(not (Pai(hp^.next)=nil)) and (Pai(hp^.next)^.typ=consttyp);
  379. if found then
  380. begin
  381. hp:=Pai(hp^.next);
  382. s:=','+tostr(pai_const(hp)^.value);
  383. AsmWrite(s);
  384. inc(l,length(s));
  385. end;
  386. until (not found) or (l>line_length);
  387. AsmLn;
  388. end;
  389. ait_const_symbol : Begin
  390. AsmWriteLn(#9'.long'#9+StrPas(pchar(pai_const(hp)^.value)));
  391. end;
  392. ait_const_symbol_offset :
  393. Begin
  394. AsmWrite(#9'.long'#9);
  395. AsmWritePChar(pai_const_symbol_offset(hp)^.name);
  396. if pai_const_symbol_offset(hp)^.offset>0 then
  397. AsmWrite('+'+tostr(pai_const_symbol_offset(hp)^.offset))
  398. else if pai_const_symbol_offset(hp)^.offset<0 then
  399. AsmWrite(tostr(pai_const_symbol_offset(hp)^.offset));
  400. AsmLn;
  401. end;
  402. ait_real_64bit : Begin
  403. AsmWriteLn(#9'.double'#9+double2str(pai_double(hp)^.value));
  404. end;
  405. ait_real_32bit : Begin
  406. AsmWriteLn(#9'.single'#9+double2str(pai_single(hp)^.value));
  407. end;
  408. ait_real_extended : Begin
  409. AsmWriteLn(#9'.extend'#9+double2str(pai_extended(hp)^.value));
  410. { comp type is difficult to write so use double }
  411. end;
  412. { TO SUPPORT SOONER OR LATER!!!
  413. ait_comp : Begin
  414. AsmWriteLn(#9'.double'#9+comp2str(pai_extended(hp)^.value));
  415. end; }
  416. ait_direct : begin
  417. AsmWritePChar(pai_direct(hp)^.str);
  418. AsmLn;
  419. {$IfDef GDB}
  420. if strpos(pai_direct(hp)^.str,'.data')<>nil then
  421. n_line:=n_dataline
  422. else if strpos(pai_direct(hp)^.str,'.text')<>nil then
  423. n_line:=n_textline
  424. else if strpos(pai_direct(hp)^.str,'.bss')<>nil then
  425. n_line:=n_bssline;
  426. {$endif GDB}
  427. end;
  428. ait_string : begin
  429. pos:=0;
  430. for i:=1 to pai_string(hp)^.len do
  431. begin
  432. if pos=0 then
  433. begin
  434. AsmWrite(#9'.ascii'#9'"');
  435. pos:=20;
  436. end;
  437. ch:=pai_string(hp)^.str[i-1];
  438. case ch of
  439. #0, {This can't be done by range, because a bug in FPC}
  440. #1..#31,
  441. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  442. '"' : s:='\"';
  443. '\' : s:='\\';
  444. else
  445. s:=ch;
  446. end;
  447. AsmWrite(s);
  448. inc(pos,length(s));
  449. if (pos>line_length) or (i=pai_string(hp)^.len) then
  450. begin
  451. AsmWriteLn('"');
  452. pos:=0;
  453. end;
  454. end;
  455. end;
  456. ait_label : begin
  457. if assigned(hp^.next) and (pai(hp^.next)^.typ in
  458. [ait_const_32bit,ait_const_16bit,ait_const_8bit,
  459. ait_const_symbol,ait_const_symbol_offset,
  460. ait_real_64bit,ait_real_32bit,ait_string]) then
  461. begin
  462. if not(cs_littlesize in aktglobalswitches) then
  463. AsmWriteLn(#9#9'.align 4')
  464. else
  465. AsmWriteLn(#9#9'.align 2');
  466. end;
  467. if (pai_label(hp)^.l^.is_used) then
  468. AsmWriteLn(lab2str(pai_label(hp)^.l)+':');
  469. end;
  470. ait_labeled_instruction : begin
  471. { labeled operand }
  472. if pai_labeled(hp)^._op1 = R_NO then
  473. AsmWriteLn(#9+mot_op2str[pai_labeled(hp)^._operator]+#9+lab2str(pai_labeled(hp)^.lab))
  474. else
  475. { labeled operand with register }
  476. AsmWriteLn(#9+mot_op2str[pai_labeled(hp)^._operator]+#9+
  477. mit_reg2str[pai_labeled(hp)^._op1]+','+lab2str(pai_labeled(hp)^.lab))
  478. end;
  479. ait_symbol : begin
  480. { ------------------------------------------------------- }
  481. { ----------- ALIGNMENT FOR ANY NON-BYTE VALUE ---------- }
  482. { ------------- REQUIREMENT FOR 680x0 ------------------- }
  483. { ------------------------------------------------------- }
  484. if assigned(hp^.next) and (pai(hp^.next)^.typ in
  485. [ait_const_32bit,ait_const_16bit,ait_const_8bit,
  486. ait_const_symbol,ait_const_symbol_offset,
  487. ait_real_64bit,ait_real_32bit,ait_string]) then
  488. begin
  489. if not(cs_littlesize in aktglobalswitches) then
  490. AsmWriteLn(#9#9'.align 4')
  491. else
  492. AsmWriteLn(#9#9'.align 2');
  493. end;
  494. if pai_symbol(hp)^.is_global then
  495. AsmWriteLn('.globl '+StrPas(pai_symbol(hp)^.name));
  496. AsmWriteLn(StrPas(pai_symbol(hp)^.name)+':');
  497. end;
  498. ait_instruction : begin
  499. { old versions of GAS don't like PEA.L and LEA.L }
  500. if (pai68k(hp)^._operator in [
  501. A_LEA,A_PEA,A_ABCD,A_BCHG,A_BCLR,A_BSET,A_BTST,
  502. A_EXG,A_NBCD,A_SBCD,A_SWAP,A_TAS,A_SCC,A_SCS,
  503. A_SEQ,A_SGE,A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,
  504. A_SNE,A_SPL,A_ST,A_SVC,A_SVS,A_SF]) then
  505. s:=#9+mot_op2str[pai68k(hp)^._operator]
  506. else
  507. s:=#9+mot_op2str[pai68k(hp)^._operator]+mit_opsize2str[pai68k(hp)^.size];
  508. if pai68k(hp)^.op1t<>top_none then
  509. begin
  510. { call and jmp need an extra handling }
  511. { this code is only callded if jmp isn't a labeled instruction }
  512. if pai68k(hp)^._operator in [A_JSR,A_JMP] then
  513. s:=s+#9+getopstr_jmp(pai68k(hp)^.op1t,pai68k(hp)^.op1)
  514. else
  515. if pai68k(hp)^.op1t = top_reglist then
  516. s:=s+#9+getopstr(pai68k(hp)^.op1t,@(pai68k(hp)^.reglist))
  517. else
  518. s:=s+#9+getopstr(pai68k(hp)^.op1t,pai68k(hp)^.op1);
  519. if pai68k(hp)^.op2t<>top_none then
  520. begin
  521. if pai68k(hp)^.op2t = top_reglist then
  522. s:=s+','+getopstr(pai68k(hp)^.op2t,@pai68k(hp)^.reglist)
  523. else
  524. s:=s+','+getopstr(pai68k(hp)^.op2t,pai68k(hp)^.op2);
  525. { three operands }
  526. if pai68k(hp)^.op3t<>top_none then
  527. begin
  528. if (pai68k(hp)^._operator = A_DIVSL) or
  529. (pai68k(hp)^._operator = A_DIVUL) or
  530. (pai68k(hp)^._operator = A_MULU) or
  531. (pai68k(hp)^._operator = A_MULS) or
  532. (pai68k(hp)^._operator = A_DIVS) or
  533. (pai68k(hp)^._operator = A_DIVU) then
  534. s:=s+':'+getopstr(pai68k(hp)^.op3t,pai68k(hp)^.op3)
  535. else
  536. s:=s+','+getopstr(pai68k(hp)^.op3t,pai68k(hp)^.op3);
  537. end;
  538. end;
  539. end;
  540. AsmWriteLn(s);
  541. end;
  542. {$ifdef GDB}
  543. ait_stabs : begin
  544. AsmWrite(#9'.stabs ');
  545. AsmWritePChar(pai_stabs(hp)^.str);
  546. AsmLn;
  547. end;
  548. ait_stabn : begin
  549. AsmWrite(#9'.stabn ');
  550. AsmWritePChar(pai_stabn(hp)^.str);
  551. AsmLn;
  552. end;
  553. ait_force_line : begin
  554. stabslastfileinfo.line:=0;
  555. end;
  556. ait_stab_function_name : funcname:=pai_stab_function_name(hp)^.str;
  557. {$endif GDB}
  558. ait_cut : begin
  559. { create only a new file when the last is not empty }
  560. if AsmSize>0 then
  561. begin
  562. AsmClose;
  563. DoAssemble;
  564. AsmCreate;
  565. end;
  566. { avoid empty files }
  567. while assigned(hp^.next) and (pai(hp^.next)^.typ in [ait_cut,ait_section,ait_comment]) do
  568. begin
  569. if pai(hp^.next)^.typ=ait_section then
  570. begin
  571. lastsec:=pai_section(hp^.next)^.sec;
  572. lastsecidx:=pai_section(hp^.next)^.idataidx;
  573. end;
  574. hp:=pai(hp^.next);
  575. end;
  576. if lastsec<>sec_none then
  577. AsmWriteLn(ait_section2str[lastsec,lastsecidx]);
  578. end;
  579. ait_marker : ;
  580. else
  581. internalerror(10000);
  582. end;
  583. hp:=pai(hp^.next);
  584. end;
  585. end;
  586. procedure tm68kmitasmlist.WriteAsmList;
  587. var
  588. p:dirstr;
  589. n:namestr;
  590. e:extstr;
  591. begin
  592. {$ifdef EXTDEBUG}
  593. if assigned(current_module^.mainsource) then
  594. comment(v_info,'Start writing gas-styled assembler output for '+current_module^.mainsource^);
  595. {$endif}
  596. lastline:=0;
  597. lastfileindex:=0;
  598. LastSec:=sec_none;
  599. {$ifdef GDB}
  600. includecount:=0;
  601. n_line:=n_bssline;
  602. {$endif GDB}
  603. if assigned(current_module^.mainsource) then
  604. fsplit(current_module^.mainsource^,p,n,e)
  605. else
  606. begin
  607. p:=inputdir;
  608. n:=inputfile;
  609. e:=inputextension;
  610. end;
  611. { to get symify to work }
  612. AsmWriteLn(#9'.file "'+FixFileName(n+e)+'"');
  613. countlabelref:=false;
  614. { there should be nothing but externals so we don't need to process
  615. WriteTree(externals); }
  616. WriteTree(debuglist);
  617. WriteTree(codesegment);
  618. WriteTree(datasegment);
  619. WriteTree(consts);
  620. WriteTree(rttilist);
  621. WriteTree(bsssegment);
  622. Writetree(importssection);
  623. Writetree(exportssection);
  624. Writetree(resourcesection);
  625. countlabelref:=true;
  626. AsmLn;
  627. {$ifdef EXTDEBUG}
  628. if assigned(current_module^.mainsource) then
  629. comment(v_info,'Done writing gas-styled assembler output for '+current_module^.mainsource^);
  630. {$endif EXTDEBUG}
  631. end;
  632. end.
  633. {
  634. $Log$
  635. Revision 1.24 2000-02-09 13:22:44 peter
  636. * log truncated
  637. Revision 1.23 2000/01/07 01:14:18 peter
  638. * updated copyright to 2000
  639. Revision 1.22 1999/09/16 23:05:51 florian
  640. * m68k compiler is again compilable (only gas writer, no assembler reader)
  641. }