ag68kgas.pas 27 KB

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