agppcmpw.pas 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Florian Klaempfl
  4. This unit implements an asmoutput class for PowerPC with MPW syntax
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. {
  19. This unit implements an asmoutput class for PowerPC with MPW syntax
  20. }
  21. unit agppcmpw;
  22. {$i fpcdefs.inc}
  23. interface
  24. uses
  25. aasmtai,
  26. globals,aasmbase,aasmcpu,assemble,
  27. cpubase;
  28. type
  29. TPPCMPWAssembler = class(TExternalAssembler)
  30. procedure WriteTree(p:TAAsmoutput);override;
  31. procedure WriteAsmList;override;
  32. Function DoAssemble:boolean;override;
  33. procedure WriteExternals;
  34. {$ifdef GDB}
  35. procedure WriteFileLineInfo(var fileinfo : tfileposinfo);
  36. procedure WriteFileEndInfo;
  37. {$endif}
  38. procedure WriteAsmFileHeader;
  39. private
  40. procedure GenProcedureHeader(var hp:tai);
  41. end;
  42. implementation
  43. uses
  44. {$ifdef delphi}
  45. sysutils,
  46. {$endif}
  47. cutils,globtype,systems,cclasses,
  48. verbose,finput,fmodule,script,cpuinfo,
  49. cginfo,
  50. itppcgas
  51. ;
  52. const
  53. line_length = 70;
  54. {Whether internal procedure references should be xxx[PR]: }
  55. use_PR = false;
  56. const_storage_class = '[RW]';
  57. {$ifdef GDB}
  58. var
  59. n_line : byte; { different types of source lines }
  60. linecount,
  61. includecount : longint;
  62. funcname : pchar;
  63. stabslastfileinfo : tfileposinfo;
  64. isInFunction: Boolean;
  65. firstLineInFunction: longint;
  66. {$endif}
  67. function ReplaceForbiddenChars(var s: string):Boolean;
  68. {Returns wheater a replacement has occured.}
  69. var
  70. i:Integer;
  71. {The dollar sign is not allowed in MPW PPCAsm}
  72. begin
  73. ReplaceForbiddenChars:=false;
  74. for i:=1 to Length(s) do
  75. if s[i]='$' then
  76. begin
  77. s[i]:='s';
  78. ReplaceForbiddenChars:=true;
  79. end;
  80. end;
  81. {*** From here is copyed from agppcgas.pp, except where marked with CHANGED.
  82. Perhaps put in a third common file. ***}
  83. function getreferencestring(var ref : treference) : string;
  84. var
  85. s : string;
  86. i,b:boolean;
  87. begin
  88. with ref do
  89. begin
  90. inc(offset,offsetfixup);
  91. if (symaddr <> refs_full) then
  92. InternalError(2002110301)
  93. else if ((offset < -32768) or (offset > 32767)) then
  94. InternalError(19991);
  95. if assigned(symbol) then
  96. begin
  97. s:= symbol.name;
  98. ReplaceForbiddenChars(s);
  99. {if symbol.typ = AT_FUNCTION then
  100. ;}
  101. s:= s+'[TC]' {ref to TOC entry }
  102. end
  103. else
  104. s:= '';
  105. if offset<0 then
  106. s:=s+tostr(offset)
  107. else
  108. if (offset>0) then
  109. begin
  110. if assigned(symbol) then
  111. s:=s+'+'+tostr(offset)
  112. else
  113. s:=s+tostr(offset);
  114. end;
  115. if (index=NR_NO) and (base<>NR_NO) then
  116. begin
  117. if offset=0 then
  118. if not assigned(symbol) then
  119. s:=s+'0';
  120. s:=s+'('+gas_regname(base)+')';
  121. end
  122. else if (index<>NR_NO) and (base<>NR_NO) and (offset=0) then
  123. begin
  124. if (offset=0) then
  125. s:=s+gas_regname(base)+','+gas_regname(index)
  126. else
  127. internalerror(19992);
  128. end;
  129. end;
  130. getreferencestring:=s;
  131. end;
  132. function getopstr_jmp(const o:toper) : string;
  133. var
  134. hs : string;
  135. begin
  136. case o.typ of
  137. top_reg :
  138. getopstr_jmp:=gas_regname(o.reg);
  139. { no top_ref jumping for powerpc }
  140. top_const :
  141. getopstr_jmp:=tostr(o.val);
  142. top_symbol :
  143. begin
  144. hs:=o.sym.name;
  145. ReplaceForbiddenChars(hs);
  146. if o.symofs>0 then
  147. hs:=hs+'+'+tostr(o.symofs)
  148. else
  149. if o.symofs<0 then
  150. hs:=hs+tostr(o.symofs);
  151. getopstr_jmp:=hs;
  152. end;
  153. top_none:
  154. getopstr_jmp:='';
  155. else
  156. internalerror(2002070603);
  157. end;
  158. end;
  159. function getopstr(const o:toper) : string;
  160. var
  161. hs : string;
  162. begin
  163. case o.typ of
  164. top_reg:
  165. getopstr:=gas_regname(o.reg);
  166. top_const:
  167. getopstr:=tostr(longint(o.val));
  168. top_ref:
  169. getopstr:=getreferencestring(o.ref^);
  170. top_symbol:
  171. begin
  172. hs:=o.sym.name;
  173. ReplaceForbiddenChars(hs);
  174. if o.symofs>0 then
  175. hs:=hs+'+'+tostr(o.symofs)
  176. else
  177. if o.symofs<0 then
  178. hs:=hs+tostr(o.symofs);
  179. getopstr:=hs;
  180. end;
  181. else
  182. internalerror(2002070604);
  183. end;
  184. end;
  185. function branchmode(o: tasmop): string[4];
  186. var tempstr: string[4];
  187. begin
  188. tempstr := '';
  189. case o of
  190. A_BCCTR,A_BCCTRL: tempstr := 'ctr';
  191. A_BCLR,A_BCLRL: tempstr := 'lr';
  192. end;
  193. case o of
  194. A_BL,A_BLA,A_BCL,A_BCLA,A_BCCTRL,A_BCLRL: tempstr := tempstr+'l';
  195. end;
  196. case o of
  197. A_BA,A_BLA,A_BCA,A_BCLA: tempstr:=tempstr+'a';
  198. end;
  199. branchmode := tempstr;
  200. end;
  201. function cond2str(op: tasmop; c: tasmcond): string;
  202. { note: no checking is performed whether the given combination of }
  203. { conditions is valid }
  204. var tempstr: string;
  205. begin
  206. tempstr:=#9;
  207. case c.simple of
  208. false: cond2str := tempstr+gas_op2str[op]+#9+tostr(c.bo)+','+
  209. tostr(c.bi);
  210. true:
  211. if (op >= A_B) and (op <= A_BCLRL) then
  212. case c.cond of
  213. { unconditional branch }
  214. C_NONE:
  215. cond2str := tempstr+gas_op2str[op];
  216. { bdnzt etc }
  217. else
  218. begin
  219. tempstr := tempstr+'b'+asmcondflag2str[c.cond]+
  220. branchmode(op)+#9;
  221. case c.cond of
  222. C_LT..C_NU:
  223. cond2str := tempstr+gas_regname(newreg(R_SPECIALREGISTER,c.cr,R_SUBNONE));
  224. C_T..C_DZF:
  225. cond2str := tempstr+tostr(c.crbit);
  226. end;
  227. end;
  228. end
  229. { we have a trap instruction }
  230. else
  231. begin
  232. internalerror(2002070601);
  233. { not yet implemented !!!!!!!!!!!!!!!!!!!!! }
  234. { case tempstr := 'tw';}
  235. end;
  236. end;
  237. end;
  238. Function GetInstruction(hp : tai):string; {CHANGED from method to proc}
  239. var op: TAsmOp;
  240. s: string;
  241. i: byte;
  242. sep: string[3];
  243. begin
  244. op:=taicpu(hp).opcode;
  245. if is_calljmp(op) then
  246. begin
  247. { direct BO/BI in op[0] and op[1] not supported, put them in condition! }
  248. case op of
  249. A_B,A_BA:
  250. s:=#9+gas_op2str[op]+#9;
  251. A_BCTR,A_BCTRL,A_BLR,A_BLRL:
  252. s:=#9+gas_op2str[op];
  253. A_BL,A_BLA:
  254. s:=#9+gas_op2str[op]+#9'.';
  255. else
  256. s:=cond2str(op,taicpu(hp).condition)+',';
  257. end;
  258. if (taicpu(hp).oper[0].typ <> top_none) then
  259. s:=s+getopstr_jmp(taicpu(hp).oper[0]);
  260. if use_PR then
  261. if (op=A_BL) or (op=A_BLA) then
  262. s:=s+'[PR]';
  263. end
  264. else
  265. { process operands }
  266. begin
  267. case op of
  268. A_MFSPR:
  269. case taicpu(hp).oper[1].reg of
  270. NR_CR:
  271. begin
  272. op:=A_MFCR;
  273. taicpu(hp).ops:=1;
  274. end;
  275. NR_LR:
  276. begin
  277. op:=A_MFLR;
  278. taicpu(hp).ops:=1;
  279. end;
  280. else
  281. internalerror(2002100701);
  282. end;
  283. A_MTSPR:
  284. case taicpu(hp).oper[1].reg of
  285. NR_CR:
  286. begin
  287. op:=A_MTCR;
  288. taicpu(hp).ops:=1;
  289. end;
  290. NR_LR:
  291. begin
  292. op:=A_MTLR;
  293. taicpu(hp).ops:=1;
  294. end;
  295. else
  296. internalerror(2002100701);
  297. end;
  298. end;
  299. s:=#9+gas_op2str[op];
  300. if taicpu(hp).ops<>0 then
  301. begin
  302. sep:=#9;
  303. for i:=0 to taicpu(hp).ops-1 do
  304. begin
  305. s:=s+sep+getopstr(taicpu(hp).oper[i]);
  306. sep:=',';
  307. end;
  308. end;
  309. end;
  310. GetInstruction:=s;
  311. end;
  312. {*** Until here is copyed from agppcgas.pp. ***}
  313. function single2str(d : single) : string;
  314. var
  315. hs : string;
  316. p : byte;
  317. begin
  318. str(d,hs);
  319. { nasm expects a lowercase e }
  320. p:=pos('E',hs);
  321. if p>0 then
  322. hs[p]:='e';
  323. p:=pos('+',hs);
  324. if p>0 then
  325. delete(hs,p,1);
  326. single2str:=lower(hs);
  327. end;
  328. function double2str(d : double) : string;
  329. var
  330. hs : string;
  331. p : byte;
  332. begin
  333. str(d,hs);
  334. { nasm expects a lowercase e }
  335. p:=pos('E',hs);
  336. if p>0 then
  337. hs[p]:='e';
  338. p:=pos('+',hs);
  339. if p>0 then
  340. delete(hs,p,1);
  341. double2str:=lower(hs);
  342. end;
  343. function fixline(s:string):string;
  344. {
  345. return s with all leading and ending spaces and tabs removed
  346. }
  347. var
  348. i,j,k : longint;
  349. begin
  350. i:=length(s);
  351. while (i>0) and (s[i] in [#9,' ']) do
  352. dec(i);
  353. j:=1;
  354. while (j<i) and (s[j] in [#9,' ']) do
  355. inc(j);
  356. for k:=j to i do
  357. if s[k] in [#0..#31,#127..#255] then
  358. s[k]:='.';
  359. fixline:=Copy(s,j,i-j+1);
  360. end;
  361. {****************************************************************************
  362. PowerPC MPW Assembler
  363. ****************************************************************************}
  364. procedure TPPCMPWAssembler.GenProcedureHeader(var hp:tai);
  365. {Returns the current hp where the caller should continue from}
  366. {For multiple entry procedures, only the last is exported as xxx[PR]
  367. (if use_PR is set) }
  368. procedure WriteExportHeader(hp:tai);
  369. var
  370. s: string;
  371. replaced: boolean;
  372. begin
  373. s:= tai_symbol(hp).sym.name;
  374. replaced:= ReplaceForbiddenChars(s);
  375. if replaced then
  376. begin
  377. if not use_PR then
  378. AsmWriteLn(#9'export'#9'.'+s+' => ''.'+tai_symbol(hp).sym.name+'''');
  379. AsmWriteLn(#9'export'#9+s+'[DS] => '''+tai_symbol(hp).sym.name+'[DS]''');
  380. end
  381. else
  382. begin
  383. if not use_PR then
  384. AsmWriteLn(#9'export'#9'.'+s);
  385. AsmWriteLn(#9'export'#9+s+'[DS]');
  386. end;
  387. {Entry in transition vector: }
  388. AsmWriteLn(#9'csect'#9+s+'[DS]');
  389. AsmWriteLn(#9'dc.l'#9'.'+s);
  390. AsmWriteln(#9'dc.l'#9'TOC[tc0]');
  391. {Entry in TOC: }
  392. AsmWriteLn(#9'toc');
  393. AsmWriteLn(#9'tc'#9+s+'[TC],'+s+'[DS]');
  394. end;
  395. function GetAdjacentTaiSymbol(var hp:tai):Boolean;
  396. begin
  397. GetAdjacentTaiSymbol:= false;
  398. while assigned(hp.next) do
  399. case tai(hp.next).typ of
  400. ait_symbol:
  401. begin
  402. hp:=tai(hp.next);
  403. GetAdjacentTaiSymbol:= true;
  404. Break;
  405. end;
  406. ait_stab_function_name:
  407. hp:=tai(hp.next);
  408. else
  409. begin
  410. //AsmWriteln(' ;#*#*# ' + tostr(Ord(tai(hp.next).typ)));
  411. Break;
  412. end;
  413. end;
  414. end;
  415. var
  416. first,last: tai;
  417. s: string;
  418. replaced: boolean;
  419. begin
  420. s:= tai_symbol(hp).sym.name;
  421. {Write all headers}
  422. first:= hp;
  423. repeat
  424. WriteExportHeader(hp);
  425. last:= hp;
  426. until not GetAdjacentTaiSymbol(hp);
  427. {Start the section of the body of the proc: }
  428. s:= tai_symbol(last).sym.name;
  429. replaced:= ReplaceForbiddenChars(s);
  430. if use_PR then
  431. if replaced then
  432. AsmWriteLn(#9'export'#9'.'+s+'[PR] => ''.'+tai_symbol(last).sym.name+'[PR]''')
  433. else
  434. AsmWriteLn(#9'export'#9'.'+s+'[PR]');
  435. AsmWriteLn(#9'csect'#9'.'+s+'[PR]'); //starts the section
  436. AsmWriteLn(#9'function'#9'.'+s+'[PR]'); //info for debugger
  437. {$ifdef GDB}
  438. if ((cs_debuginfo in aktmoduleswitches) or
  439. (cs_gdb_lineinfo in aktglobalswitches)) then
  440. begin
  441. //info for debuggers:
  442. firstLineInFunction:= stabslastfileinfo.line;
  443. AsmWriteLn(#9'beginf ' + tostr(firstLineInFunction));
  444. isInFunction:= true;
  445. end;
  446. {$endif}
  447. {Write all labels: }
  448. hp:= first;
  449. repeat
  450. s:= tai_symbol(hp).sym.name;
  451. ReplaceForbiddenChars(s);
  452. AsmWriteLn('.'+s+':');
  453. until not GetAdjacentTaiSymbol(hp);
  454. end;
  455. (*
  456. procedure TPPCMPWAssembler.GenProcedureHeader(hp:tai);
  457. var
  458. s: string;
  459. replaced: boolean;
  460. begin
  461. s:= tai_symbol(hp).sym.name;
  462. replaced:= ReplaceForbiddenChars(s);
  463. if replaced then
  464. begin
  465. AsmWriteLn(#9'export'#9'.'+s+'[PR] => ''.'+tai_symbol(hp).sym.name+'[PR]''');
  466. AsmWriteLn(#9'export'#9+s+'[DS] => '''+tai_symbol(hp).sym.name+'[DS]''');
  467. end
  468. else
  469. begin
  470. AsmWriteLn(#9'export'#9'.'+s+'[PR]');
  471. AsmWriteLn(#9'export'#9+s+'[DS]');
  472. end;
  473. {Entry in transition vector: }
  474. AsmWriteLn(#9'csect'#9+s+'[DS]');
  475. AsmWriteLn(#9'dc.l'#9'.'+s);
  476. AsmWriteln(#9'dc.l'#9'TOC[tc0]');
  477. {Entry in TOC: }
  478. AsmWriteLn(#9'toc');
  479. AsmWriteLn(#9'tc'#9+s+'[TC],'+s+'[DS]');
  480. {Start the section of the body of the proc: }
  481. AsmWriteLn(#9'csect'#9'.'+s+'[PR]');
  482. AsmWriteLn('.'+s+':');
  483. end;
  484. *)
  485. var
  486. LasTSec : TSection;
  487. lastfileinfo : tfileposinfo;
  488. infile,
  489. lastinfile : tinputfile;
  490. const
  491. ait_const2str:array[ait_const_32bit..ait_const_8bit] of string[8]=
  492. (#9'dc.l'#9,#9'dc.w'#9,#9'dc.b'#9);
  493. Function PadTabs(const p:string;addch:char):string;
  494. var
  495. s : string;
  496. i : longint;
  497. begin
  498. i:=length(p);
  499. if addch<>#0 then
  500. begin
  501. inc(i);
  502. s:=p+addch;
  503. end
  504. else
  505. s:=p;
  506. if i<8 then
  507. PadTabs:=s+#9#9
  508. else
  509. PadTabs:=s+#9;
  510. end;
  511. {$ifdef GDB}
  512. procedure TPPCMPWAssembler.WriteFileLineInfo(var fileinfo : tfileposinfo);
  513. var
  514. curr_n : byte;
  515. begin
  516. if not ((cs_debuginfo in aktmoduleswitches) or
  517. (cs_gdb_lineinfo in aktglobalswitches)) then
  518. exit;
  519. { file changed ? (must be before line info) }
  520. if (fileinfo.fileindex<>0) and
  521. (stabslastfileinfo.fileindex<>fileinfo.fileindex) then
  522. begin
  523. infile:=current_module.sourcefiles.get_file(fileinfo.fileindex);
  524. if assigned(infile) then
  525. begin
  526. (*
  527. if includecount=0 then
  528. curr_n:=n_sourcefile
  529. else
  530. curr_n:=n_includefile;
  531. if (infile.path^<>'') then
  532. begin
  533. AsmWriteLn(#9'.stabs "'+lower(BsToSlash(FixPath(infile.path^,false)))+'",'+
  534. tostr(curr_n)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
  535. end;
  536. AsmWriteLn(#9'.stabs "'+lower(FixFileName(infile.name^))+'",'+
  537. tostr(curr_n)+',0,0,'+target_asm.labelprefix+'text'+ToStr(IncludeCount));
  538. *)
  539. AsmWriteLn(#9'file '''+lower(FixFileName(infile.name^))+'''');
  540. (*
  541. AsmWriteLn(target_asm.labelprefix+'text'+ToStr(IncludeCount)+':');
  542. *)
  543. inc(includecount);
  544. { force new line info }
  545. stabslastfileinfo.line:=-1;
  546. end;
  547. end;
  548. { line changed ? }
  549. if (stabslastfileinfo.line<>fileinfo.line) and (fileinfo.line<>0) then
  550. begin
  551. (*
  552. if (n_line=n_textline) and assigned(funcname) and
  553. (target_info.use_function_relative_addresses) then
  554. begin
  555. AsmWriteLn(target_asm.labelprefix+'l'+tostr(linecount)+':');
  556. AsmWrite(#9'.stabn '+tostr(n_line)+',0,'+tostr(fileinfo.line)+','+
  557. target_asm.labelprefix+'l'+tostr(linecount)+' - ');
  558. AsmWritePChar(FuncName);
  559. AsmLn;
  560. inc(linecount);
  561. end
  562. else
  563. AsmWriteLn(#9'.stabd'#9+tostr(n_line)+',0,'+tostr(fileinfo.line));
  564. *)
  565. if isInFunction then
  566. AsmWriteln(#9'line '+ tostr(fileinfo.line - firstLineInFunction - 1));
  567. end;
  568. stabslastfileinfo:=fileinfo;
  569. end;
  570. procedure TPPCMPWAssembler.WriteFileEndInfo;
  571. begin
  572. if not ((cs_debuginfo in aktmoduleswitches) or
  573. (cs_gdb_lineinfo in aktglobalswitches)) then
  574. exit;
  575. AsmLn;
  576. (*
  577. AsmWriteLn(ait_section2str(sec_code));
  578. AsmWriteLn(#9'.stabs "",'+tostr(n_sourcefile)+',0,0,'+target_asm.labelprefix+'etext');
  579. AsmWriteLn(target_asm.labelprefix+'etext:');
  580. *)
  581. end;
  582. {$endif}
  583. procedure TPPCMPWAssembler.WriteTree(p:TAAsmoutput);
  584. var
  585. s,
  586. prefix,
  587. suffix : string;
  588. hp : tai;
  589. hp1 : tailineinfo;
  590. counter,
  591. lines,
  592. InlineLevel : longint;
  593. i,j,l : longint;
  594. consttyp : taitype;
  595. found,
  596. do_line,DoNotSplitLine,
  597. quoted : boolean;
  598. sep : char;
  599. replaced : boolean;
  600. begin
  601. if not assigned(p) then
  602. exit;
  603. InlineLevel:=0;
  604. { lineinfo is only needed for codesegment (PFV) }
  605. do_line:=((cs_asm_source in aktglobalswitches) or
  606. (cs_lineinfo in aktmoduleswitches))
  607. and (p=codesegment);
  608. DoNotSplitLine:=false;
  609. hp:=tai(p.first);
  610. while assigned(hp) do
  611. begin
  612. if not(hp.typ in SkipLineInfo) and
  613. not DoNotSplitLine then
  614. begin
  615. hp1 := hp as tailineinfo;
  616. {$ifdef GDB}
  617. { write debug info }
  618. if (cs_debuginfo in aktmoduleswitches) or
  619. (cs_gdb_lineinfo in aktglobalswitches) then
  620. WriteFileLineInfo(hp1.fileinfo);
  621. {$endif GDB}
  622. if do_line then
  623. begin
  624. { load infile }
  625. if lastfileinfo.fileindex<>hp1.fileinfo.fileindex then
  626. begin
  627. infile:=current_module.sourcefiles.get_file(hp1.fileinfo.fileindex);
  628. if assigned(infile) then
  629. begin
  630. { open only if needed !! }
  631. if (cs_asm_source in aktglobalswitches) then
  632. infile.open;
  633. end;
  634. { avoid unnecessary reopens of the same file !! }
  635. lastfileinfo.fileindex:=hp1.fileinfo.fileindex;
  636. { be sure to change line !! }
  637. lastfileinfo.line:=-1;
  638. end;
  639. { write source }
  640. if (cs_asm_source in aktglobalswitches) and
  641. assigned(infile) then
  642. begin
  643. if (infile<>lastinfile) then
  644. begin
  645. AsmWriteLn(target_asm.comment+'['+infile.name^+']');
  646. if assigned(lastinfile) then
  647. lastinfile.close;
  648. end;
  649. if (hp1.fileinfo.line<>lastfileinfo.line) and
  650. ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
  651. begin
  652. if (hp1.fileinfo.line<>0) and
  653. ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
  654. AsmWriteLn(target_asm.comment+'['+tostr(hp1.fileinfo.line)+'] '+
  655. fixline(infile.GetLineStr(hp1.fileinfo.line)));
  656. { set it to a negative value !
  657. to make that is has been read already !! PM }
  658. if (infile.linebuf^[hp1.fileinfo.line]>=0) then
  659. infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
  660. end;
  661. end;
  662. lastfileinfo:=hp1.fileinfo;
  663. lastinfile:=infile;
  664. end;
  665. end;
  666. DoNotSplitLine:=false;
  667. case hp.typ of
  668. ait_comment:
  669. begin
  670. AsmWrite(target_asm.comment);
  671. AsmWritePChar(tai_comment(hp).str);
  672. AsmLn;
  673. end;
  674. ait_regalloc,
  675. ait_tempalloc:
  676. ;
  677. ait_section:
  678. begin
  679. {if LasTSec<>sec_none then
  680. AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ENDS');}
  681. if tai_section(hp).sec<>sec_none then
  682. begin
  683. AsmLn;
  684. AsmWriteLn(#9+target_asm.secnames[tai_section(hp).sec]);
  685. {$ifdef GDB}
  686. lastfileinfo.line:=-1;
  687. {$endif GDB}
  688. end;
  689. LasTSec:=tai_section(hp).sec;
  690. end;
  691. ait_align:
  692. begin
  693. case tai_align(hp).aligntype of
  694. 1:AsmWriteLn(#9'align 0');
  695. 2:AsmWriteLn(#9'align 1');
  696. 4:AsmWriteLn(#9'align 2');
  697. otherwise internalerror(2002110302);
  698. end;
  699. end;
  700. ait_datablock:
  701. begin
  702. s:= tai_datablock(hp).sym.name;
  703. replaced:= ReplaceForbiddenChars(s);
  704. if tai_datablock(hp).is_global then
  705. if replaced then
  706. AsmWriteLn(#9'export'#9+s+'[RW] => '''+tai_datablock(hp).sym.name+'''')
  707. else
  708. AsmWriteLn(#9'export'#9+s+'[RW]');
  709. if not macos_direct_globals then
  710. begin
  711. AsmWriteLn(#9'toc');
  712. AsmWriteLn(#9'tc'#9+s+'[TC], '+s+'[RW]');
  713. AsmWriteLn(#9'csect'#9+s+'[RW]');
  714. AsmWriteLn(#9'ds.b '+tostr(tai_datablock(hp).size));
  715. end
  716. else
  717. begin
  718. AsmWriteLn(#9'csect'#9+s+'[TC]');
  719. AsmWriteLn(PadTabs(s+':',#0)+'ds.b '+tostr(tai_datablock(hp).size));
  720. {TODO: ? PadTabs(s,#0) }
  721. end;
  722. end;
  723. ait_const_32bit,
  724. ait_const_8bit,
  725. ait_const_16bit :
  726. begin
  727. AsmWrite(ait_const2str[hp.typ]+tostr(tai_const(hp).value));
  728. consttyp:=hp.typ;
  729. l:=0;
  730. repeat
  731. found:=(not (tai(hp.next)=nil)) and (tai(hp.next).typ=consttyp);
  732. if found then
  733. begin
  734. hp:=tai(hp.next);
  735. s:=','+tostr(tai_const(hp).value);
  736. AsmWrite(s);
  737. inc(l,length(s));
  738. end;
  739. until (not found) or (l>line_length);
  740. AsmLn;
  741. end;
  742. ait_const_symbol:
  743. begin
  744. (*
  745. AsmWriteLn(#9#9'dd'#9'offset '+tai_const_symbol(hp).sym.name);
  746. if tai_const_symbol(hp).offset>0 then
  747. AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
  748. else if tai_const_symbol(hp).offset<0 then
  749. AsmWrite(tostr(tai_const_symbol(hp).offset));
  750. AsmLn;
  751. *)
  752. s:= tai_const_symbol(hp).sym.name;
  753. ReplaceForbiddenChars(s);
  754. if tai_const_symbol(hp).sym.typ = AT_FUNCTION then
  755. begin
  756. if use_PR then
  757. AsmWriteLn(#9'dc.l'#9'.'+ s +'[PR]')
  758. else
  759. AsmWriteLn(#9'dc.l'#9 + s + '[DS]')
  760. end
  761. else
  762. begin
  763. if macos_direct_globals then
  764. AsmWriteLn(#9'dc.l'#9+s)
  765. else
  766. AsmWriteLn(#9'dc.l'#9+s+const_storage_class);
  767. end;
  768. (* TODO: the following might need to be included. Temporaily we
  769. generate an error
  770. if tai_const_symbol(hp).offset>0 then
  771. AsmWrite('+'+tostr(tai_const_symbol(hp).offset))
  772. else if tai_const_symbol(hp).offset<0 then
  773. AsmWrite(tostr(tai_const_symbol(hp).offset));
  774. *)
  775. if tai_const_symbol(hp).offset <> 0 then
  776. InternalError(2002110101);
  777. AsmLn;
  778. end;
  779. ait_real_32bit:
  780. AsmWriteLn(#9'dc.l'#9'"'+single2str(tai_real_32bit(hp).value)+'"');
  781. ait_real_64bit:
  782. AsmWriteLn(#9'dc.d'#9'"'+double2str(tai_real_64bit(hp).value)+'"');
  783. ait_string:
  784. begin
  785. {NOTE When a single quote char is encountered, it is
  786. replaced with a numeric ascii value. It could also
  787. have been replaced with the escape seq of double quotes.}
  788. counter := 0;
  789. lines := tai_string(hp).len div line_length;
  790. { separate lines in different parts }
  791. if tai_string(hp).len > 0 then
  792. Begin
  793. for j := 0 to lines-1 do
  794. begin
  795. AsmWrite(#9'dc.b'#9);
  796. quoted:=false;
  797. for i:=counter to counter+line_length do
  798. begin
  799. { it is an ascii character. }
  800. if (ord(tai_string(hp).str[i])>31) and
  801. (ord(tai_string(hp).str[i])<128) and
  802. (tai_string(hp).str[i]<>'''') then
  803. begin
  804. if not(quoted) then
  805. begin
  806. if i>counter then
  807. AsmWrite(',');
  808. AsmWrite('''');
  809. end;
  810. AsmWrite(tai_string(hp).str[i]);
  811. quoted:=true;
  812. end { if > 31 and < 128 and ord('"') }
  813. else
  814. begin
  815. if quoted then
  816. AsmWrite('''');
  817. if i>counter then
  818. AsmWrite(',');
  819. quoted:=false;
  820. AsmWrite(tostr(ord(tai_string(hp).str[i])));
  821. end;
  822. end; { end for i:=0 to... }
  823. if quoted then AsmWrite('''');
  824. AsmWrite(target_info.newline);
  825. counter := counter+line_length;
  826. end; { end for j:=0 ... }
  827. { do last line of lines }
  828. AsmWrite(#9'dc.b'#9);
  829. quoted:=false;
  830. for i:=counter to tai_string(hp).len-1 do
  831. begin
  832. { it is an ascii character. }
  833. if (ord(tai_string(hp).str[i])>31) and
  834. (ord(tai_string(hp).str[i])<128) and
  835. (tai_string(hp).str[i]<>'''') then
  836. begin
  837. if not(quoted) then
  838. begin
  839. if i>counter then
  840. AsmWrite(',');
  841. AsmWrite('''');
  842. end;
  843. AsmWrite(tai_string(hp).str[i]);
  844. quoted:=true;
  845. end { if > 31 and < 128 and " }
  846. else
  847. begin
  848. if quoted then
  849. AsmWrite('''');
  850. if i>counter then
  851. AsmWrite(',');
  852. quoted:=false;
  853. AsmWrite(tostr(ord(tai_string(hp).str[i])));
  854. end;
  855. end; { end for i:=0 to... }
  856. if quoted then
  857. AsmWrite('''');
  858. end;
  859. AsmLn;
  860. end;
  861. ait_label:
  862. begin
  863. if tai_label(hp).l.is_used then
  864. begin
  865. s:= tai_label(hp).l.name;
  866. ReplaceForbiddenChars(s);
  867. if s[1] = '@' then
  868. AsmWriteLn(s+':')
  869. else
  870. begin
  871. if not macos_direct_globals then
  872. begin
  873. AsmWriteLn(#9'toc');
  874. AsmWriteLn(#9'tc'#9+s+'[TC], '+s+const_storage_class);
  875. AsmWriteLn(#9'csect'#9+s+const_storage_class);
  876. end
  877. else
  878. begin
  879. AsmWriteLn(#9'csect'#9+s+'[TC]');
  880. AsmWriteLn(PadTabs(s+':',#0));
  881. end;
  882. end;
  883. end;
  884. end;
  885. ait_direct:
  886. begin
  887. AsmWritePChar(tai_direct(hp).str);
  888. AsmLn;
  889. end;
  890. ait_symbol:
  891. begin
  892. if tai_symbol(hp).sym.typ=AT_FUNCTION then
  893. GenProcedureHeader(hp)
  894. else if tai_symbol(hp).sym.typ=AT_DATA then
  895. begin
  896. s:= tai_symbol(hp).sym.name;
  897. replaced:= ReplaceForbiddenChars(s);
  898. if tai_symbol(hp).is_global then
  899. if replaced then
  900. AsmWriteLn(#9'export'#9+s+'[RW] => '''+tai_symbol(hp).sym.name+'''')
  901. else
  902. AsmWriteLn(#9'export'#9+s+'[RW]');
  903. if not macos_direct_globals then
  904. begin
  905. AsmWriteLn(#9'toc');
  906. AsmWriteLn(#9'tc'#9+s+'[TC], '+s+ const_storage_class);
  907. AsmWriteLn(#9'csect'#9+s+ const_storage_class);
  908. end
  909. else
  910. begin
  911. AsmWriteLn(#9'csect'#9+s+'[TC]');
  912. AsmWriteLn(s+':');
  913. end;
  914. end
  915. else
  916. InternalError(2003071301);
  917. end;
  918. ait_symbol_end:
  919. {$ifdef GDB}
  920. if isInFunction then
  921. if ((cs_debuginfo in aktmoduleswitches) or
  922. (cs_gdb_lineinfo in aktglobalswitches)) then
  923. begin
  924. //info for debuggers:
  925. AsmWriteLn(#9'endf ' + tostr(stabslastfileinfo.line));
  926. isInFunction:= false;
  927. end
  928. {$endif GDB}
  929. ;
  930. ait_instruction:
  931. AsmWriteLn(GetInstruction(hp));
  932. {$ifdef GDB}
  933. ait_stabn: ;
  934. ait_stabs: ;
  935. ait_force_line :
  936. stabslastfileinfo.line:=0;
  937. ait_stab_function_name: ;
  938. {$endif GDB}
  939. ait_cut :
  940. begin
  941. { only reset buffer if nothing has changed }
  942. if AsmSize=AsmStartSize then
  943. AsmClear
  944. else
  945. begin
  946. {
  947. if LasTSec<>sec_none then
  948. AsmWriteLn('_'+target_asm.secnames[LasTSec]+#9#9'ends');
  949. AsmLn;
  950. }
  951. AsmWriteLn(#9'end');
  952. AsmClose;
  953. DoAssemble;
  954. AsmCreate(tai_cut(hp).place);
  955. end;
  956. { avoid empty files }
  957. while assigned(hp.next) and (tai(hp.next).typ in [ait_cut,ait_section,ait_comment]) do
  958. begin
  959. if tai(hp.next).typ=ait_section then
  960. begin
  961. lasTSec:=tai_section(hp.next).sec;
  962. end;
  963. hp:=tai(hp.next);
  964. end;
  965. WriteAsmFileHeader;
  966. if lasTSec<>sec_none then
  967. AsmWriteLn(#9+target_asm.secnames[lasTSec]);
  968. { AsmWriteLn('_'+target_asm.secnames[lasTSec]+#9#9+
  969. 'SEGMENT'#9'PARA PUBLIC USE32 '''+
  970. target_asm.secnames[lasTSec]+'''');
  971. }
  972. AsmStartSize:=AsmSize;
  973. end;
  974. ait_marker :
  975. begin
  976. if tai_marker(hp).kind=InlineStart then
  977. inc(InlineLevel)
  978. else if tai_marker(hp).kind=InlineEnd then
  979. dec(InlineLevel);
  980. end;
  981. else
  982. internalerror(2002110303);
  983. end;
  984. hp:=tai(hp.next);
  985. end;
  986. end;
  987. var
  988. currentasmlist : TExternalAssembler;
  989. procedure writeexternal(p:tnamedindexitem;arg:pointer);
  990. var
  991. s:string;
  992. begin
  993. if tasmsymbol(p).defbind=AB_EXTERNAL then
  994. begin
  995. //Writeln('ZZZ ',p.name,' ',p.classname,' ',Ord(tasmsymbol(p).typ));
  996. s:= p.name;
  997. case tasmsymbol(p).typ of
  998. AT_FUNCTION:
  999. begin
  1000. if ReplaceForbiddenChars(s) then
  1001. begin
  1002. if not use_PR then
  1003. currentasmlist.AsmWriteLn(#9'import'#9'.'+s+' <= ''.'+p.name+'''')
  1004. else
  1005. currentasmlist.AsmWriteLn(#9'import'#9'.'+s+'[PR] <= ''.'+p.name+'[PR]''');
  1006. currentasmlist.AsmWriteLn(#9'import'#9+s+'[DS] <= '''+p.name+'[DS]''');
  1007. end
  1008. else
  1009. begin
  1010. if not use_PR then
  1011. currentasmlist.AsmWriteLn(#9'import'#9'.'+s)
  1012. else
  1013. currentasmlist.AsmWriteLn(#9'import'#9'.'+s+'[PR]');
  1014. currentasmlist.AsmWriteLn(#9'import'#9+s+'[DS]');
  1015. end;
  1016. currentasmlist.AsmWriteLn(#9'toc');
  1017. currentasmlist.AsmWriteLn(#9'tc'#9+s+'[TC],'+s+'[DS]');
  1018. end
  1019. else
  1020. begin
  1021. if ReplaceForbiddenChars(s) then
  1022. currentasmlist.AsmWriteLn(#9'import'#9+s+'[RW] <= '''+p.name+'''')
  1023. else
  1024. currentasmlist.AsmWriteLn(#9'import'#9+s+'[RW]');
  1025. currentasmlist.AsmWriteLn(#9'toc');
  1026. currentasmlist.AsmWriteLn(#9'tc'#9+s+'[TC],'+s+'[RW]');
  1027. end;
  1028. end;
  1029. end;
  1030. end;
  1031. procedure TPPCMPWAssembler.WriteExternals;
  1032. begin
  1033. currentasmlist:=self;
  1034. objectlibrary.symbolsearch.foreach_static({$ifdef fpcprocvar}@{$endif}writeexternal,nil);
  1035. end;
  1036. function TPPCMPWAssembler.DoAssemble : boolean;
  1037. var f : file;
  1038. begin
  1039. DoAssemble:=Inherited DoAssemble;
  1040. (*
  1041. { masm does not seem to recognize specific extensions and uses .obj allways PM }
  1042. if (aktoutputformat = as_i386_masm) then
  1043. begin
  1044. if not(cs_asm_extern in aktglobalswitches) then
  1045. begin
  1046. if Not FileExists(objfile) and
  1047. FileExists(ForceExtension(objfile,'.obj')) then
  1048. begin
  1049. Assign(F,ForceExtension(objfile,'.obj'));
  1050. Rename(F,objfile);
  1051. end;
  1052. end
  1053. else
  1054. AsmRes.AddAsmCommand('mv',ForceExtension(objfile,'.obj')+' '+objfile,objfile);
  1055. end;
  1056. *)
  1057. end;
  1058. procedure TPPCMPWAssembler.WriteAsmFileHeader;
  1059. begin
  1060. (*
  1061. AsmWriteLn(#9'.386p');
  1062. { masm 6.11 does not seem to like LOCALS PM }
  1063. if (aktoutputformat = as_i386_tasm) then
  1064. begin
  1065. AsmWriteLn(#9'LOCALS '+target_asm.labelprefix);
  1066. end;
  1067. AsmWriteLn('DGROUP'#9'GROUP'#9'_BSS,_DATA');
  1068. AsmWriteLn(#9'ASSUME'#9'CS:_CODE,ES:DGROUP,DS:DGROUP,SS:DGROUP');
  1069. AsmLn;
  1070. *)
  1071. AsmWriteLn(#9'string asis'); {Interpret strings just to be the content between the quotes.}
  1072. AsmWriteLn(#9'aligning off'); {We do our own aligning.}
  1073. AsmLn;
  1074. end;
  1075. procedure TPPCMPWAssembler.WriteAsmList;
  1076. {$ifdef GDB}
  1077. var
  1078. fileinfo : tfileposinfo;
  1079. {$endif GDB}
  1080. begin
  1081. {$ifdef EXTDEBUG}
  1082. if assigned(current_module.mainsource) then
  1083. comment(v_info,'Start writing MPW-styled assembler output for '+current_module.mainsource^);
  1084. {$endif}
  1085. LasTSec:=sec_none;
  1086. {$ifdef GDB}
  1087. FillChar(stabslastfileinfo,sizeof(stabslastfileinfo),0);
  1088. {$endif GDB}
  1089. {$ifdef GDB}
  1090. //n_line:=n_bssline;
  1091. funcname:=nil;
  1092. linecount:=1;
  1093. includecount:=0;
  1094. fileinfo.fileindex:=1;
  1095. fileinfo.line:=1;
  1096. isInFunction:= false;
  1097. firstLineInFunction:= 0;
  1098. { Write main file }
  1099. WriteFileLineInfo(fileinfo);
  1100. {$endif GDB}
  1101. WriteAsmFileHeader;
  1102. WriteExternals;
  1103. { PowerPC MPW ASM doesn't support stabs, as we know.
  1104. WriteTree(debuglist);}
  1105. WriteTree(codesegment);
  1106. WriteTree(datasegment);
  1107. WriteTree(consts);
  1108. WriteTree(rttilist);
  1109. WriteTree(resourcestringlist);
  1110. WriteTree(bsssegment);
  1111. {$ifdef GDB}
  1112. WriteFileEndInfo;
  1113. {$ENDIF}
  1114. AsmWriteLn(#9'end');
  1115. AsmLn;
  1116. {$ifdef EXTDEBUG}
  1117. if assigned(current_module.mainsource) then
  1118. comment(v_info,'Done writing MPW-styled assembler output for '+current_module.mainsource^);
  1119. {$endif EXTDEBUG}
  1120. end;
  1121. {*****************************************************************************
  1122. Initialize
  1123. *****************************************************************************}
  1124. const
  1125. as_powerpc_mpw_info : tasminfo =
  1126. (
  1127. id : as_powerpc_mpw;
  1128. idtxt : 'MPW';
  1129. asmbin : 'PPCAsm';
  1130. asmcmd : '';
  1131. supported_target : system_any; { what should I write here ?? }
  1132. outputbinary: false;
  1133. allowdirect : true;
  1134. needar : true;
  1135. labelprefix_only_inside_procedure : true;
  1136. labelprefix : '@';
  1137. comment : '; ';
  1138. secnames : ('',
  1139. 'csect','csect [TC]','csect [TC]', {TODO: Perhaps use other section types.}
  1140. '','','','','','',
  1141. '','','')
  1142. );
  1143. initialization
  1144. RegisterAssembler(as_powerpc_mpw_info,TPPCMPWAssembler);
  1145. end.
  1146. {
  1147. $Log$
  1148. Revision 1.24 2003-09-03 19:35:24 peter
  1149. * powerpc compiles again
  1150. Revision 1.23 2003/08/24 21:40:12 olle
  1151. * minor adjustment
  1152. Revision 1.21 2003/08/18 11:47:15 olle
  1153. + added asm directive ALIGNING OFF to avoid unexpected aligning by the assembler
  1154. Revision 1.20 2002/10/01 05:17:27 olle
  1155. * minor fix
  1156. Revision 1.19 2003/04/06 21:01:40 olle
  1157. + line numbers are now emitted in the assembler code
  1158. * bug in export and import directive fixed
  1159. * made code more in sync with aggas.pas
  1160. Revision 1.18 2003/01/13 17:17:50 olle
  1161. * changed global var access, TOC now contain pointers to globals
  1162. * fixed handling of function pointers
  1163. Revision 1.17 2003/01/08 18:43:57 daniel
  1164. * Tregister changed into a record
  1165. Revision 1.16 2002/11/28 10:56:07 olle
  1166. * changed proc ref from .xxx[PR] (refering to its section)
  1167. to .xxx (refering to its label) to allow for multiple ref to a proc.
  1168. Revision 1.15 2002/11/17 16:31:59 carl
  1169. * memory optimization (3-4%) : cleanup of tai fields,
  1170. cleanup of tdef and tsym fields.
  1171. * make it work for m68k
  1172. Revision 1.14 2002/11/07 15:50:23 jonas
  1173. * fixed bctr(l) problems
  1174. Revision 1.13 2002/11/04 18:24:53 olle
  1175. * globals are located in TOC and relative r2, instead of absolute
  1176. * symbols which only differs in case are treated as a single symbol
  1177. + tai_const_symbol supported
  1178. * only refs_full accepted
  1179. Revision 1.12 2002/10/23 15:31:01 olle
  1180. * branch b does not jump to dotted symbol now
  1181. Revision 1.11 2002/10/19 23:52:40 olle
  1182. * import directive changed
  1183. Revision 1.10 2002/10/10 19:39:37 florian
  1184. * changes from Olle to get simple programs compiled and assembled
  1185. Revision 1.9 2002/10/07 21:19:53 florian
  1186. * more mpw fixes
  1187. Revision 1.8 2002/10/06 22:46:20 florian
  1188. * fixed function exporting
  1189. Revision 1.7 2002/10/02 22:14:15 florian
  1190. * improve function imports
  1191. Revision 1.6 2002/09/27 21:09:49 florian
  1192. + readed because previous version was broken
  1193. Revision 1.2 2002/08/31 12:43:31 florian
  1194. * ppc compilation fixed
  1195. Revision 1.1 2002/08/20 21:40:44 florian
  1196. + target macos for ppc added
  1197. + frame work for mpw assembler output
  1198. }