assemble.pas 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  1. {
  2. Copyright (c) 1998-2004 by Peter Vreman
  3. This unit handles the assemblerfile write and assembler calls of FPC
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. {# @abstract(This unit handles the assembler file write and assembler calls of FPC)
  18. Handles the calls to the actual external assemblers, as well as the generation
  19. of object files for smart linking. Also contains the base class for writing
  20. the assembler statements to file.
  21. }
  22. unit assemble;
  23. {$i fpcdefs.inc}
  24. interface
  25. uses
  26. SysUtils,
  27. systems,globtype,globals,aasmbase,aasmtai,aasmdata,ogbase;
  28. const
  29. { maximum of aasmoutput lists there will be }
  30. maxoutputlists = 20;
  31. { buffer size for writing the .s file }
  32. AsmOutSize=32768;
  33. type
  34. TAssembler=class(TAbstractAssembler)
  35. public
  36. {filenames}
  37. path : string;
  38. name : string;
  39. AsmFileName, { current .s and .o file }
  40. ObjFileName,
  41. ppufilename : string;
  42. asmprefix : string;
  43. SmartAsm : boolean;
  44. SmartFilesCount,
  45. SmartHeaderCount : longint;
  46. Constructor Create(smart:boolean);virtual;
  47. Destructor Destroy;override;
  48. procedure NextSmartName(place:tcutplace);
  49. procedure MakeObject;virtual;abstract;
  50. end;
  51. {# This is the base class which should be overriden for each each
  52. assembler writer. It is used to actually assembler a file,
  53. and write the output to the assembler file.
  54. }
  55. TExternalAssembler=class(TAssembler)
  56. private
  57. procedure CreateSmartLinkPath(const s:string);
  58. protected
  59. {outfile}
  60. AsmSize,
  61. AsmStartSize,
  62. outcnt : longint;
  63. outbuf : array[0..AsmOutSize-1] of char;
  64. outfile : file;
  65. ioerror : boolean;
  66. public
  67. {# Returns the complete path and executable name of the assembler
  68. program.
  69. It first tries looking in the UTIL directory if specified,
  70. otherwise it searches in the free pascal binary directory, in
  71. the current working directory and then in the directories
  72. in the $PATH environment.}
  73. Function FindAssembler:string;
  74. {# Actually does the call to the assembler file. Returns false
  75. if the assembling of the file failed.}
  76. Function CallAssembler(const command:string; const para:TCmdStr):Boolean;
  77. Function DoAssemble:boolean;virtual;
  78. Procedure RemoveAsm;
  79. Procedure AsmFlush;
  80. Procedure AsmClear;
  81. {# Write a string to the assembler file }
  82. Procedure AsmWrite(const s:string);
  83. {# Write a string to the assembler file }
  84. Procedure AsmWritePChar(p:pchar);
  85. {# Write a string to the assembler file followed by a new line }
  86. Procedure AsmWriteLn(const s:string);
  87. {# Write a new line to the assembler file }
  88. Procedure AsmLn;
  89. procedure AsmCreate(Aplace:tcutplace);
  90. procedure AsmClose;
  91. {# This routine should be overriden for each assembler, it is used
  92. to actually write the abstract assembler stream to file.}
  93. procedure WriteTree(p:TAsmList);virtual;
  94. {# This routine should be overriden for each assembler, it is used
  95. to actually write all the different abstract assembler streams
  96. by calling for each stream type, the @var(WriteTree) method.}
  97. procedure WriteAsmList;virtual;
  98. {# Constructs the command line for calling the assembler }
  99. function MakeCmdLine: TCmdStr; virtual;
  100. public
  101. Constructor Create(smart:boolean);override;
  102. procedure MakeObject;override;
  103. end;
  104. TInternalAssembler=class(TAssembler)
  105. private
  106. FCObjOutput : TObjOutputclass;
  107. { the aasmoutput lists that need to be processed }
  108. lists : byte;
  109. list : array[1..maxoutputlists] of TAsmList;
  110. { current processing }
  111. currlistidx : byte;
  112. currlist : TAsmList;
  113. procedure WriteStab(p:pchar);
  114. function MaybeNextList(var hp:Tai):boolean;
  115. function TreePass0(hp:Tai):Tai;
  116. function TreePass1(hp:Tai):Tai;
  117. function TreePass2(hp:Tai):Tai;
  118. procedure writetree;
  119. procedure writetreesmart;
  120. protected
  121. ObjData : TObjData;
  122. ObjOutput : tObjOutput;
  123. property CObjOutput:TObjOutputclass read FCObjOutput write FCObjOutput;
  124. public
  125. constructor create(smart:boolean);override;
  126. destructor destroy;override;
  127. procedure MakeObject;override;
  128. end;
  129. TAssemblerClass = class of TAssembler;
  130. Procedure GenerateAsm(smart:boolean);
  131. Procedure OnlyAsm;
  132. procedure RegisterAssembler(const r:tasminfo;c:TAssemblerClass);
  133. procedure InitAssembler;
  134. procedure DoneAssembler;
  135. Implementation
  136. uses
  137. {$ifdef hasunix}
  138. unix,
  139. {$endif}
  140. cutils,cfileutils,
  141. {$ifdef memdebug}
  142. cclasses,
  143. {$endif memdebug}
  144. script,fmodule,verbose,
  145. {$ifdef m68k}
  146. cpuinfo,
  147. {$endif m68k}
  148. aasmcpu,
  149. owbase,owar
  150. ;
  151. var
  152. CAssembler : array[tasm] of TAssemblerClass;
  153. {*****************************************************************************
  154. TAssembler
  155. *****************************************************************************}
  156. Constructor TAssembler.Create(smart:boolean);
  157. begin
  158. { load start values }
  159. AsmFileName:=current_module.AsmFilename^;
  160. ObjFileName:=current_module.ObjFileName^;
  161. name:=Lower(current_module.modulename^);
  162. path:=current_module.outputpath^;
  163. asmprefix := current_module.asmprefix^;
  164. if not assigned(current_module.outputpath) then
  165. ppufilename := ''
  166. else
  167. ppufilename := current_module.ppufilename^;
  168. SmartAsm:=smart;
  169. SmartFilesCount:=0;
  170. SmartHeaderCount:=0;
  171. SmartLinkOFiles.Clear;
  172. end;
  173. Destructor TAssembler.Destroy;
  174. begin
  175. end;
  176. procedure TAssembler.NextSmartName(place:tcutplace);
  177. var
  178. s : string;
  179. begin
  180. inc(SmartFilesCount);
  181. if SmartFilesCount>999999 then
  182. Message(asmw_f_too_many_asm_files);
  183. case place of
  184. cut_begin :
  185. begin
  186. inc(SmartHeaderCount);
  187. s:=asmprefix+tostr(SmartHeaderCount)+'h';
  188. end;
  189. cut_normal :
  190. s:=asmprefix+tostr(SmartHeaderCount)+'s';
  191. cut_end :
  192. s:=asmprefix+tostr(SmartHeaderCount)+'t';
  193. end;
  194. AsmFileName:=Path+FixFileName(s+tostr(SmartFilesCount)+target_info.asmext);
  195. ObjFileName:=Path+FixFileName(s+tostr(SmartFilesCount)+target_info.objext);
  196. { insert in container so it can be cleared after the linking }
  197. SmartLinkOFiles.Insert(ObjFileName);
  198. end;
  199. {*****************************************************************************
  200. TExternalAssembler
  201. *****************************************************************************}
  202. Function DoPipe:boolean;
  203. begin
  204. DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
  205. (([cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) and
  206. ((target_asm.id in [as_gas,as_ggas,as_darwin]));
  207. end;
  208. Constructor TExternalAssembler.Create(smart:boolean);
  209. begin
  210. inherited Create(smart);
  211. if SmartAsm then
  212. begin
  213. path:=FixPath(ChangeFileExt(AsmFileName,target_info.smartext),false);
  214. CreateSmartLinkPath(path);
  215. end;
  216. Outcnt:=0;
  217. end;
  218. procedure TExternalAssembler.CreateSmartLinkPath(const s:string);
  219. procedure DeleteFilesWithExt(const AExt:string);
  220. var
  221. dir : TSearchRec;
  222. begin
  223. if findfirst(s+source_info.dirsep+'*'+AExt,faAnyFile,dir) = 0 then
  224. begin
  225. repeat
  226. DeleteFile(s+source_info.dirsep+dir.name);
  227. until findnext(dir) <> 0;
  228. end;
  229. findclose(dir);
  230. end;
  231. var
  232. dir : TSearchRec;
  233. hs : string;
  234. begin
  235. if PathExists(s,false) then
  236. begin
  237. { the path exists, now we clean only all the .o and .s files }
  238. DeleteFilesWithExt(target_info.objext);
  239. DeleteFilesWithExt(target_info.asmext);
  240. end
  241. else
  242. begin
  243. hs:=s;
  244. if hs[length(hs)] in ['/','\'] then
  245. delete(hs,length(hs),1);
  246. {$I-}
  247. mkdir(hs);
  248. {$I+}
  249. if ioresult<>0 then;
  250. end;
  251. end;
  252. const
  253. lastas : byte=255;
  254. var
  255. LastASBin : string;
  256. Function TExternalAssembler.FindAssembler:string;
  257. var
  258. asfound : boolean;
  259. UtilExe : string;
  260. begin
  261. asfound:=false;
  262. if cs_link_on_target in current_settings.globalswitches then
  263. begin
  264. { If linking on target, don't add any path PM }
  265. FindAssembler:=utilsprefix+ChangeFileExt(target_asm.asmbin,target_info.exeext);
  266. exit;
  267. end
  268. else
  269. UtilExe:=utilsprefix+ChangeFileExt(target_asm.asmbin,source_info.exeext);
  270. if lastas<>ord(target_asm.id) then
  271. begin
  272. lastas:=ord(target_asm.id);
  273. { is an assembler passed ? }
  274. if utilsdirectory<>'' then
  275. asfound:=FindFile(UtilExe,utilsdirectory,false,LastASBin);
  276. if not AsFound then
  277. asfound:=FindExe(UtilExe,false,LastASBin);
  278. if (not asfound) and not(cs_asm_extern in current_settings.globalswitches) then
  279. begin
  280. Message1(exec_e_assembler_not_found,LastASBin);
  281. current_settings.globalswitches:=current_settings.globalswitches+[cs_asm_extern];
  282. end;
  283. if asfound then
  284. Message1(exec_t_using_assembler,LastASBin);
  285. end;
  286. FindAssembler:=LastASBin;
  287. end;
  288. Function TExternalAssembler.CallAssembler(const command:string; const para:TCmdStr):Boolean;
  289. var
  290. DosExitCode : Integer;
  291. begin
  292. result:=true;
  293. if (cs_asm_extern in current_settings.globalswitches) then
  294. begin
  295. AsmRes.AddAsmCommand(command,para,name);
  296. exit;
  297. end;
  298. try
  299. FlushOutput;
  300. DosExitCode := ExecuteProcess(command,para);
  301. if DosExitCode <>0
  302. then begin
  303. Message1(exec_e_error_while_assembling,tostr(dosexitcode));
  304. result:=false;
  305. end;
  306. except on E:EOSError do
  307. begin
  308. Message1(exec_e_cant_call_assembler,tostr(E.ErrorCode));
  309. current_settings.globalswitches:=current_settings.globalswitches+[cs_asm_extern];
  310. result:=false;
  311. end;
  312. end;
  313. end;
  314. procedure TExternalAssembler.RemoveAsm;
  315. var
  316. g : file;
  317. begin
  318. if cs_asm_leave in current_settings.globalswitches then
  319. exit;
  320. if cs_asm_extern in current_settings.globalswitches then
  321. AsmRes.AddDeleteCommand(AsmFileName)
  322. else
  323. begin
  324. assign(g,AsmFileName);
  325. {$I-}
  326. erase(g);
  327. {$I+}
  328. if ioresult<>0 then;
  329. end;
  330. end;
  331. Function TExternalAssembler.DoAssemble:boolean;
  332. begin
  333. DoAssemble:=true;
  334. if DoPipe then
  335. exit;
  336. if not(cs_asm_extern in current_settings.globalswitches) then
  337. begin
  338. if SmartAsm then
  339. begin
  340. if (SmartFilesCount<=1) then
  341. Message1(exec_i_assembling_smart,name);
  342. end
  343. else
  344. Message1(exec_i_assembling,name);
  345. end;
  346. if CallAssembler(FindAssembler,MakeCmdLine) then
  347. RemoveAsm
  348. else
  349. begin
  350. DoAssemble:=false;
  351. GenerateError;
  352. end;
  353. end;
  354. Procedure TExternalAssembler.AsmFlush;
  355. begin
  356. if outcnt>0 then
  357. begin
  358. { suppress i/o error }
  359. {$i-}
  360. BlockWrite(outfile,outbuf,outcnt);
  361. {$i+}
  362. ioerror:=ioerror or (ioresult<>0);
  363. outcnt:=0;
  364. end;
  365. end;
  366. Procedure TExternalAssembler.AsmClear;
  367. begin
  368. outcnt:=0;
  369. end;
  370. Procedure TExternalAssembler.AsmWrite(const s:string);
  371. begin
  372. if OutCnt+length(s)>=AsmOutSize then
  373. AsmFlush;
  374. Move(s[1],OutBuf[OutCnt],length(s));
  375. inc(OutCnt,length(s));
  376. inc(AsmSize,length(s));
  377. end;
  378. Procedure TExternalAssembler.AsmWriteLn(const s:string);
  379. begin
  380. AsmWrite(s);
  381. AsmLn;
  382. end;
  383. Procedure TExternalAssembler.AsmWritePChar(p:pchar);
  384. var
  385. i,j : longint;
  386. begin
  387. i:=StrLen(p);
  388. j:=i;
  389. while j>0 do
  390. begin
  391. i:=min(j,AsmOutSize);
  392. if OutCnt+i>=AsmOutSize then
  393. AsmFlush;
  394. Move(p[0],OutBuf[OutCnt],i);
  395. inc(OutCnt,i);
  396. inc(AsmSize,i);
  397. dec(j,i);
  398. p:=pchar(@p[i]);
  399. end;
  400. end;
  401. Procedure TExternalAssembler.AsmLn;
  402. begin
  403. if OutCnt>=AsmOutSize-2 then
  404. AsmFlush;
  405. if (cs_link_on_target in current_settings.globalswitches) then
  406. begin
  407. OutBuf[OutCnt]:=target_info.newline[1];
  408. inc(OutCnt);
  409. inc(AsmSize);
  410. if length(target_info.newline)>1 then
  411. begin
  412. OutBuf[OutCnt]:=target_info.newline[2];
  413. inc(OutCnt);
  414. inc(AsmSize);
  415. end;
  416. end
  417. else
  418. begin
  419. OutBuf[OutCnt]:=source_info.newline[1];
  420. inc(OutCnt);
  421. inc(AsmSize);
  422. if length(source_info.newline)>1 then
  423. begin
  424. OutBuf[OutCnt]:=source_info.newline[2];
  425. inc(OutCnt);
  426. inc(AsmSize);
  427. end;
  428. end;
  429. end;
  430. function TExternalAssembler.MakeCmdLine: TCmdStr;
  431. begin
  432. result:=target_asm.asmcmd;
  433. {$ifdef m68k}
  434. if current_settings.cputype = cpu_MC68020 then
  435. result:='-m68020 '+result
  436. else
  437. result:='-m68000 '+result;
  438. {$endif}
  439. if (cs_link_on_target in current_settings.globalswitches) then
  440. begin
  441. Replace(result,'$ASM',maybequoted(ScriptFixFileName(AsmFileName)));
  442. Replace(result,'$OBJ',maybequoted(ScriptFixFileName(ObjFileName)));
  443. end
  444. else
  445. begin
  446. {$ifdef hasunix}
  447. if DoPipe then
  448. Replace(result,'$ASM','')
  449. else
  450. {$endif}
  451. Replace(result,'$ASM',maybequoted(AsmFileName));
  452. Replace(result,'$OBJ',maybequoted(ObjFileName));
  453. end;
  454. end;
  455. procedure TExternalAssembler.AsmCreate(Aplace:tcutplace);
  456. begin
  457. if SmartAsm then
  458. NextSmartName(Aplace);
  459. {$ifdef hasunix}
  460. if DoPipe then
  461. begin
  462. if SmartAsm then
  463. begin
  464. if (SmartFilesCount<=1) then
  465. Message1(exec_i_assembling_smart,name);
  466. end
  467. else
  468. Message1(exec_i_assembling_pipe,AsmFileName);
  469. POpen(outfile,FindAssembler+' '+MakeCmdLine,'W');
  470. end
  471. else
  472. {$endif}
  473. begin
  474. Assign(outfile,AsmFileName);
  475. {$I-}
  476. Rewrite(outfile,1);
  477. {$I+}
  478. if ioresult<>0 then
  479. begin
  480. ioerror:=true;
  481. Message1(exec_d_cant_create_asmfile,AsmFileName);
  482. end;
  483. end;
  484. outcnt:=0;
  485. AsmSize:=0;
  486. AsmStartSize:=0;
  487. end;
  488. procedure TExternalAssembler.AsmClose;
  489. var
  490. f : file;
  491. FileAge : longint;
  492. begin
  493. AsmFlush;
  494. {$ifdef hasunix}
  495. if DoPipe then
  496. begin
  497. if PClose(outfile) <> 0 then
  498. GenerateError;
  499. end
  500. else
  501. {$endif}
  502. begin
  503. {Touch Assembler time to ppu time is there is a ppufilename}
  504. if ppufilename<>'' then
  505. begin
  506. Assign(f,ppufilename);
  507. {$I-}
  508. reset(f,1);
  509. {$I+}
  510. if ioresult=0 then
  511. begin
  512. FileAge := FileGetDate(GetFileHandle(f));
  513. close(f);
  514. reset(outfile,1);
  515. FileSetDate(GetFileHandle(outFile),FileAge);
  516. end;
  517. end;
  518. close(outfile);
  519. end;
  520. end;
  521. procedure TExternalAssembler.WriteTree(p:TAsmList);
  522. begin
  523. end;
  524. procedure TExternalAssembler.WriteAsmList;
  525. begin
  526. end;
  527. procedure TExternalAssembler.MakeObject;
  528. begin
  529. AsmCreate(cut_normal);
  530. WriteAsmList;
  531. AsmClose;
  532. if not(ioerror) then
  533. DoAssemble;
  534. end;
  535. {*****************************************************************************
  536. TInternalAssembler
  537. *****************************************************************************}
  538. constructor TInternalAssembler.create(smart:boolean);
  539. begin
  540. inherited create(smart);
  541. ObjOutput:=nil;
  542. ObjData:=nil;
  543. SmartAsm:=smart;
  544. end;
  545. destructor TInternalAssembler.destroy;
  546. begin
  547. if assigned(ObjData) then
  548. ObjData.free;
  549. if assigned(ObjOutput) then
  550. ObjOutput.free;
  551. end;
  552. procedure TInternalAssembler.WriteStab(p:pchar);
  553. function consumecomma(var p:pchar):boolean;
  554. begin
  555. while (p^=' ') do
  556. inc(p);
  557. result:=(p^=',');
  558. inc(p);
  559. end;
  560. function consumenumber(var p:pchar;out value:longint):boolean;
  561. var
  562. hs : string;
  563. len,
  564. code : integer;
  565. begin
  566. value:=0;
  567. while (p^=' ') do
  568. inc(p);
  569. len:=0;
  570. while (p^ in ['0'..'9']) do
  571. begin
  572. inc(len);
  573. hs[len]:=p^;
  574. inc(p);
  575. end;
  576. if len>0 then
  577. begin
  578. hs[0]:=chr(len);
  579. val(hs,value,code);
  580. end
  581. else
  582. code:=-1;
  583. result:=(code=0);
  584. end;
  585. function consumeoffset(var p:pchar;out relocsym:tobjsymbol;out value:longint):boolean;
  586. var
  587. hs : string;
  588. len,
  589. code : integer;
  590. pstart : pchar;
  591. sym : tobjsymbol;
  592. exprvalue : longint;
  593. gotmin,
  594. dosub : boolean;
  595. begin
  596. result:=false;
  597. value:=0;
  598. relocsym:=nil;
  599. gotmin:=false;
  600. repeat
  601. dosub:=false;
  602. exprvalue:=0;
  603. if gotmin then
  604. begin
  605. dosub:=true;
  606. gotmin:=false;
  607. end;
  608. while (p^=' ') do
  609. inc(p);
  610. case p^ of
  611. #0 :
  612. break;
  613. ' ' :
  614. inc(p);
  615. '0'..'9' :
  616. begin
  617. len:=0;
  618. while (p^ in ['0'..'9']) do
  619. begin
  620. inc(len);
  621. hs[len]:=p^;
  622. inc(p);
  623. end;
  624. hs[0]:=chr(len);
  625. val(hs,exprvalue,code);
  626. end;
  627. '.','_',
  628. 'A'..'Z',
  629. 'a'..'z' :
  630. begin
  631. pstart:=p;
  632. while not(p^ in [#0,' ','-','+']) do
  633. inc(p);
  634. len:=p-pstart;
  635. if len>255 then
  636. internalerror(200509187);
  637. move(pstart^,hs[1],len);
  638. hs[0]:=chr(len);
  639. sym:=objdata.symbolref(hs);
  640. { Second symbol? }
  641. if assigned(relocsym) then
  642. begin
  643. if (relocsym.objsection<>sym.objsection) then
  644. internalerror(2005091810);
  645. relocsym:=nil;
  646. end
  647. else
  648. relocsym:=sym;
  649. exprvalue:=sym.address;
  650. end;
  651. '+' :
  652. begin
  653. { nothing, by default addition is done }
  654. inc(p);
  655. end;
  656. '-' :
  657. begin
  658. gotmin:=true;
  659. inc(p);
  660. end;
  661. else
  662. internalerror(200509189);
  663. end;
  664. if dosub then
  665. dec(value,exprvalue)
  666. else
  667. inc(value,exprvalue);
  668. until false;
  669. result:=true;
  670. end;
  671. const
  672. N_Function = $24; { function or const }
  673. var
  674. stabstrlen,
  675. ofs,
  676. nline,
  677. nidx,
  678. nother,
  679. i : longint;
  680. stab : TObjStabEntry;
  681. relocsym : TObjSymbol;
  682. pstr,
  683. pcurr,
  684. pendquote : pchar;
  685. oldsec : TObjSection;
  686. reltype : TObjRelocationType;
  687. begin
  688. pcurr:=nil;
  689. pstr:=nil;
  690. pendquote:=nil;
  691. { Parse string part }
  692. if (p[0]='"') then
  693. begin
  694. pstr:=@p[1];
  695. { Ignore \" inside the string }
  696. i:=1;
  697. while not((p[i]='"') and (p[i-1]<>'\')) and
  698. (p[i]<>#0) do
  699. inc(i);
  700. pendquote:=@p[i];
  701. pendquote^:=#0;
  702. pcurr:=@p[i+1];
  703. if not consumecomma(pcurr) then
  704. internalerror(200509181);
  705. end
  706. else
  707. pcurr:=p;
  708. { When in pass 1 then only alloc and leave }
  709. if ObjData.currpass=1 then
  710. begin
  711. ObjData.StabsSec.Alloc(sizeof(TObjStabEntry));
  712. if assigned(pstr) and (pstr[0]<>#0) then
  713. ObjData.StabStrSec.Alloc(strlen(pstr)+1);
  714. end
  715. else
  716. begin
  717. { Stabs format: nidx,nother,nline[,offset] }
  718. if not consumenumber(pcurr,nidx) then
  719. internalerror(200509182);
  720. if not consumecomma(pcurr) then
  721. internalerror(200509183);
  722. if not consumenumber(pcurr,nother) then
  723. internalerror(200509184);
  724. if not consumecomma(pcurr) then
  725. internalerror(200509185);
  726. if not consumenumber(pcurr,nline) then
  727. internalerror(200509186);
  728. if consumecomma(pcurr) then
  729. consumeoffset(pcurr,relocsym,ofs)
  730. else
  731. begin
  732. ofs:=0;
  733. relocsym:=nil;
  734. end;
  735. if assigned(relocsym) and
  736. (relocsym.bind<>AB_LOCAL) then
  737. ofs:=0;
  738. { Generate stab entry }
  739. if assigned(pstr) and (pstr[0]<>#0) then
  740. begin
  741. stabstrlen:=strlen(pstr);
  742. {$ifdef optimizestabs}
  743. StabStrEntry:=nil;
  744. if (nidx=N_SourceFile) or (nidx=N_IncludeFile) then
  745. begin
  746. hs:=strpas(pstr);
  747. StabstrEntry:=StabStrDict.Find(hs);
  748. if not assigned(StabstrEntry) then
  749. begin
  750. StabstrEntry:=TStabStrEntry.Create(hs);
  751. StabstrEntry:=StabStrSec.Size;
  752. StabStrDict.Insert(StabstrEntry);
  753. { generate new stab }
  754. StabstrEntry:=nil;
  755. end;
  756. end;
  757. if assigned(StabstrEntry) then
  758. stab.strpos:=StabstrEntry.strpos
  759. else
  760. {$endif optimizestabs}
  761. begin
  762. stab.strpos:=ObjData.StabStrSec.Size;
  763. ObjData.StabStrSec.write(pstr^,stabstrlen+1);
  764. end;
  765. end
  766. else
  767. stab.strpos:=0;
  768. stab.ntype:=byte(nidx);
  769. stab.ndesc:=word(nline);
  770. stab.nother:=byte(nother);
  771. stab.nvalue:=ofs;
  772. { Write the stab first without the value field. Then
  773. write a the value field with relocation }
  774. oldsec:=ObjData.CurrObjSec;
  775. ObjData.SetSection(ObjData.StabsSec);
  776. ObjData.Writebytes(stab,sizeof(TObjStabEntry)-4);
  777. if DLLSource and RelocSection then
  778. reltype:=RELOC_RVA
  779. else
  780. reltype:=RELOC_ABSOLUTE;
  781. ObjData.Writereloc(stab.nvalue,4,relocsym,reltype);
  782. ObjData.setsection(oldsec);
  783. end;
  784. if assigned(pendquote) then
  785. pendquote^:='"';
  786. end;
  787. function TInternalAssembler.MaybeNextList(var hp:Tai):boolean;
  788. begin
  789. { maybe end of list }
  790. while not assigned(hp) do
  791. begin
  792. if currlistidx<lists then
  793. begin
  794. inc(currlistidx);
  795. currlist:=list[currlistidx];
  796. hp:=Tai(currList.first);
  797. end
  798. else
  799. begin
  800. MaybeNextList:=false;
  801. exit;
  802. end;
  803. end;
  804. MaybeNextList:=true;
  805. end;
  806. function TInternalAssembler.TreePass0(hp:Tai):Tai;
  807. begin
  808. while assigned(hp) do
  809. begin
  810. case hp.typ of
  811. ait_align :
  812. begin
  813. { always use the maximum fillsize in this pass to avoid possible
  814. short jumps to become out of range }
  815. Tai_align_abstract(hp).fillsize:=Tai_align_abstract(hp).aligntype;
  816. ObjData.alloc(Tai_align_abstract(hp).fillsize);
  817. end;
  818. ait_datablock :
  819. begin
  820. ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign));
  821. ObjData.SymbolDefine(Tai_datablock(hp).sym);
  822. ObjData.alloc(Tai_datablock(hp).size);
  823. end;
  824. ait_real_80bit :
  825. ObjData.alloc(10);
  826. ait_real_64bit :
  827. ObjData.alloc(8);
  828. ait_real_32bit :
  829. ObjData.alloc(4);
  830. ait_comp_64bit :
  831. ObjData.alloc(8);
  832. ait_const:
  833. ObjData.alloc(tai_const(hp).size);
  834. ait_section:
  835. begin
  836. ObjData.CreateSection(Tai_section(hp).sectype,Tai_section(hp).name^,Tai_section(hp).secorder);
  837. Tai_section(hp).sec:=ObjData.CurrObjSec;
  838. end;
  839. ait_symbol :
  840. ObjData.SymbolDefine(Tai_symbol(hp).sym);
  841. ait_label :
  842. ObjData.SymbolDefine(Tai_label(hp).labsym);
  843. ait_string :
  844. ObjData.alloc(Tai_string(hp).len);
  845. ait_instruction :
  846. begin
  847. { reset instructions which could change in pass 2 }
  848. Taicpu(hp).resetpass2;
  849. ObjData.alloc(Taicpu(hp).Pass1(ObjData));
  850. end;
  851. ait_cutobject :
  852. if SmartAsm then
  853. break;
  854. end;
  855. hp:=Tai(hp.next);
  856. end;
  857. TreePass0:=hp;
  858. end;
  859. function TInternalAssembler.TreePass1(hp:Tai):Tai;
  860. var
  861. InlineLevel : longint;
  862. objsym : TObjSymbol;
  863. begin
  864. inlinelevel:=0;
  865. while assigned(hp) do
  866. begin
  867. case hp.typ of
  868. ait_align :
  869. begin
  870. { here we must determine the fillsize which is used in pass2 }
  871. Tai_align_abstract(hp).fillsize:=align(ObjData.CurrObjSec.Size,Tai_align_abstract(hp).aligntype)-
  872. ObjData.CurrObjSec.Size;
  873. ObjData.alloc(Tai_align_abstract(hp).fillsize);
  874. end;
  875. ait_datablock :
  876. begin
  877. if (oso_data in ObjData.CurrObjSec.secoptions) then
  878. Message(asmw_e_alloc_data_only_in_bss);
  879. ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign));
  880. objsym:=ObjData.SymbolDefine(Tai_datablock(hp).sym);
  881. objsym.size:=Tai_datablock(hp).size;
  882. ObjData.alloc(Tai_datablock(hp).size);
  883. end;
  884. ait_real_80bit :
  885. ObjData.alloc(10);
  886. ait_real_64bit :
  887. ObjData.alloc(8);
  888. ait_real_32bit :
  889. ObjData.alloc(4);
  890. ait_comp_64bit :
  891. ObjData.alloc(8);
  892. ait_const:
  893. begin
  894. ObjData.alloc(tai_const(hp).size);
  895. if assigned(Tai_const(hp).sym) then
  896. ObjData.SymbolRef(Tai_const(hp).sym);
  897. if assigned(Tai_const(hp).endsym) then
  898. ObjData.SymbolRef(Tai_const(hp).endsym);
  899. end;
  900. ait_section:
  901. begin
  902. { use cached value }
  903. ObjData.setsection(Tai_section(hp).sec);
  904. end;
  905. ait_stab :
  906. begin
  907. if assigned(Tai_stab(hp).str) then
  908. WriteStab(Tai_stab(hp).str);
  909. end;
  910. ait_symbol :
  911. ObjData.SymbolDefine(Tai_symbol(hp).sym);
  912. ait_symbol_end :
  913. begin
  914. objsym:=ObjData.SymbolRef(Tai_symbol_end(hp).sym);
  915. objsym.size:=ObjData.CurrObjSec.Size-objsym.offset;
  916. end;
  917. ait_label :
  918. ObjData.SymbolDefine(Tai_label(hp).labsym);
  919. ait_string :
  920. ObjData.alloc(Tai_string(hp).len);
  921. ait_instruction :
  922. ObjData.alloc(Taicpu(hp).Pass1(ObjData));
  923. ait_cutobject :
  924. if SmartAsm then
  925. break;
  926. ait_marker :
  927. if tai_marker(hp).kind=mark_InlineStart then
  928. inc(InlineLevel)
  929. else if tai_marker(hp).kind=mark_InlineEnd then
  930. dec(InlineLevel);
  931. end;
  932. hp:=Tai(hp.next);
  933. end;
  934. TreePass1:=hp;
  935. end;
  936. function TInternalAssembler.TreePass2(hp:Tai):Tai;
  937. var
  938. fillbuffer : tfillbuffer;
  939. InlineLevel,
  940. v : int64;
  941. {$ifdef x86}
  942. co : comp;
  943. {$endif x86}
  944. objsym,
  945. objsymend : TObjSymbol;
  946. leblen : byte;
  947. lebbuf : array[0..63] of byte;
  948. begin
  949. inlinelevel:=0;
  950. { main loop }
  951. while assigned(hp) do
  952. begin
  953. case hp.typ of
  954. ait_align :
  955. begin
  956. if (oso_data in ObjData.CurrObjSec.secoptions) then
  957. ObjData.writebytes(Tai_align_abstract(hp).calculatefillbuf(fillbuffer)^,Tai_align_abstract(hp).fillsize)
  958. else
  959. ObjData.alloc(Tai_align_abstract(hp).fillsize);
  960. end;
  961. ait_section :
  962. begin
  963. { use cached value }
  964. ObjData.setsection(Tai_section(hp).sec);
  965. end;
  966. ait_symbol :
  967. begin
  968. ObjOutput.exportsymbol(ObjData.SymbolRef(Tai_symbol(hp).sym));
  969. end;
  970. ait_datablock :
  971. begin
  972. ObjData.allocalign(used_align(size_2_align(Tai_datablock(hp).size),0,ObjData.CurrObjSec.secalign));
  973. ObjOutput.exportsymbol(ObjData.SymbolRef(Tai_datablock(hp).sym));
  974. ObjData.alloc(Tai_datablock(hp).size);
  975. end;
  976. ait_real_80bit :
  977. ObjData.writebytes(Tai_real_80bit(hp).value,10);
  978. ait_real_64bit :
  979. ObjData.writebytes(Tai_real_64bit(hp).value,8);
  980. ait_real_32bit :
  981. ObjData.writebytes(Tai_real_32bit(hp).value,4);
  982. ait_comp_64bit :
  983. begin
  984. {$ifdef x86}
  985. co:=comp(Tai_comp_64bit(hp).value);
  986. ObjData.writebytes(co,8);
  987. {$endif x86}
  988. end;
  989. ait_string :
  990. ObjData.writebytes(Tai_string(hp).str^,Tai_string(hp).len);
  991. ait_const :
  992. begin
  993. case tai_const(hp).consttype of
  994. aitconst_64bit,
  995. aitconst_32bit,
  996. aitconst_16bit,
  997. aitconst_8bit :
  998. begin
  999. if assigned(tai_const(hp).sym) then
  1000. begin
  1001. objsym:=Objdata.SymbolRef(tai_const(hp).sym);
  1002. if assigned(tai_const(hp).endsym) then
  1003. begin
  1004. objsymend:=Objdata.SymbolRef(tai_const(hp).endsym);
  1005. if objsymend.objsection<>objsym.objsection then
  1006. internalerror(200404124);
  1007. v:=objsymend.address-objsym.address+Tai_const(hp).value;
  1008. ObjData.writebytes(v,tai_const(hp).size);
  1009. end
  1010. else
  1011. ObjData.writereloc(Tai_const(hp).value,Tai_const(hp).size,objsym,RELOC_ABSOLUTE);
  1012. end
  1013. else
  1014. ObjData.writebytes(Tai_const(hp).value,tai_const(hp).size);
  1015. end;
  1016. aitconst_rva_symbol :
  1017. { PE32+? }
  1018. if target_info.system=system_x86_64_win64 then
  1019. ObjData.writereloc(Tai_const(hp).value,sizeof(longint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_RVA)
  1020. else
  1021. ObjData.writereloc(Tai_const(hp).value,sizeof(aint),Objdata.SymbolRef(tai_const(hp).sym),RELOC_RVA);
  1022. aitconst_uleb128bit :
  1023. begin
  1024. leblen:=EncodeUleb128(Tai_const(hp).value,lebbuf);
  1025. ObjData.writebytes(lebbuf,leblen);
  1026. end;
  1027. aitconst_sleb128bit :
  1028. begin
  1029. leblen:=EncodeSleb128(Tai_const(hp).value,lebbuf);
  1030. ObjData.writebytes(lebbuf,leblen);
  1031. end;
  1032. else
  1033. internalerror(200603254);
  1034. end;
  1035. end;
  1036. ait_label :
  1037. begin
  1038. { exporting shouldn't be necessary as labels are local,
  1039. but it's better to be on the safe side (PFV) }
  1040. ObjOutput.exportsymbol(ObjData.SymbolRef(Tai_label(hp).labsym));
  1041. end;
  1042. ait_instruction :
  1043. Taicpu(hp).Pass2(ObjData);
  1044. ait_stab :
  1045. WriteStab(Tai_stab(hp).str);
  1046. ait_function_name,
  1047. ait_force_line : ;
  1048. ait_cutobject :
  1049. if SmartAsm then
  1050. break;
  1051. ait_marker :
  1052. if tai_marker(hp).kind=mark_InlineStart then
  1053. inc(InlineLevel)
  1054. else if tai_marker(hp).kind=mark_InlineEnd then
  1055. dec(InlineLevel);
  1056. end;
  1057. hp:=Tai(hp.next);
  1058. end;
  1059. TreePass2:=hp;
  1060. end;
  1061. procedure TInternalAssembler.writetree;
  1062. label
  1063. doexit;
  1064. var
  1065. hp : Tai;
  1066. ObjWriter : TObjectWriter;
  1067. begin
  1068. ObjWriter:=TObjectwriter.create;
  1069. ObjOutput:=CObjOutput.Create(ObjWriter);
  1070. ObjData:=ObjOutput.newObjData(ObjFileName);
  1071. { Pass 0 }
  1072. ObjData.currpass:=0;
  1073. ObjData.createsection(sec_code);
  1074. ObjData.beforealloc;
  1075. { start with list 1 }
  1076. currlistidx:=1;
  1077. currlist:=list[currlistidx];
  1078. hp:=Tai(currList.first);
  1079. while assigned(hp) do
  1080. begin
  1081. hp:=TreePass0(hp);
  1082. MaybeNextList(hp);
  1083. end;
  1084. ObjData.afteralloc;
  1085. { leave if errors have occured }
  1086. if errorcount>0 then
  1087. goto doexit;
  1088. { Pass 1 }
  1089. ObjData.currpass:=1;
  1090. ObjData.resetsections;
  1091. ObjData.beforealloc;
  1092. ObjData.createsection(sec_code);
  1093. { start with list 1 }
  1094. currlistidx:=1;
  1095. currlist:=list[currlistidx];
  1096. hp:=Tai(currList.first);
  1097. while assigned(hp) do
  1098. begin
  1099. hp:=TreePass1(hp);
  1100. MaybeNextList(hp);
  1101. end;
  1102. ObjData.createsection(sec_code);
  1103. ObjData.afteralloc;
  1104. { leave if errors have occured }
  1105. if errorcount>0 then
  1106. goto doexit;
  1107. { Pass 2 }
  1108. ObjData.currpass:=2;
  1109. ObjData.resetsections;
  1110. ObjData.beforewrite;
  1111. ObjData.createsection(sec_code);
  1112. { start with list 1 }
  1113. currlistidx:=1;
  1114. currlist:=list[currlistidx];
  1115. hp:=Tai(currList.first);
  1116. while assigned(hp) do
  1117. begin
  1118. hp:=TreePass2(hp);
  1119. MaybeNextList(hp);
  1120. end;
  1121. ObjData.createsection(sec_code);
  1122. ObjData.afterwrite;
  1123. { don't write the .o file if errors have occured }
  1124. if errorcount=0 then
  1125. begin
  1126. { write objectfile }
  1127. ObjOutput.startobjectfile(ObjFileName);
  1128. ObjOutput.writeobjectfile(ObjData);
  1129. end;
  1130. doexit:
  1131. { Cleanup }
  1132. ObjData.free;
  1133. ObjData:=nil;
  1134. ObjWriter.free;
  1135. end;
  1136. procedure TInternalAssembler.writetreesmart;
  1137. var
  1138. hp : Tai;
  1139. startsectype : TAsmSectiontype;
  1140. place: tcutplace;
  1141. ObjWriter : TObjectWriter;
  1142. begin
  1143. if not(cs_asm_leave in current_settings.globalswitches) then
  1144. ObjWriter:=TARObjectWriter.create(current_module.staticlibfilename^)
  1145. else
  1146. ObjWriter:=TObjectwriter.create;
  1147. NextSmartName(cut_normal);
  1148. ObjOutput:=CObjOutput.Create(ObjWriter);
  1149. startsectype:=sec_code;
  1150. { start with list 1 }
  1151. currlistidx:=1;
  1152. currlist:=list[currlistidx];
  1153. hp:=Tai(currList.first);
  1154. while assigned(hp) do
  1155. begin
  1156. ObjData:=ObjOutput.newObjData(ObjFileName);
  1157. { Pass 0 }
  1158. ObjData.currpass:=0;
  1159. ObjData.resetsections;
  1160. ObjData.beforealloc;
  1161. ObjData.createsection(startsectype);
  1162. TreePass0(hp);
  1163. ObjData.afteralloc;
  1164. { leave if errors have occured }
  1165. if errorcount>0 then
  1166. break;
  1167. { Pass 1 }
  1168. ObjData.currpass:=1;
  1169. ObjData.resetsections;
  1170. ObjData.beforealloc;
  1171. ObjData.createsection(startsectype);
  1172. TreePass1(hp);
  1173. ObjData.afteralloc;
  1174. { leave if errors have occured }
  1175. if errorcount>0 then
  1176. break;
  1177. { Pass 2 }
  1178. ObjData.currpass:=2;
  1179. ObjOutput.startobjectfile(ObjFileName);
  1180. ObjData.resetsections;
  1181. ObjData.beforewrite;
  1182. ObjData.createsection(startsectype);
  1183. hp:=TreePass2(hp);
  1184. ObjData.afterwrite;
  1185. { leave if errors have occured }
  1186. if errorcount>0 then
  1187. break;
  1188. { write the current objectfile }
  1189. ObjOutput.writeobjectfile(ObjData);
  1190. ObjData.free;
  1191. ObjData:=nil;
  1192. { end of lists? }
  1193. if not MaybeNextList(hp) then
  1194. break;
  1195. { we will start a new objectfile so reset everything }
  1196. { The place can still change in the next while loop, so don't init }
  1197. { the writer yet (JM) }
  1198. if (hp.typ=ait_cutobject) then
  1199. place := Tai_cutobject(hp).place
  1200. else
  1201. place := cut_normal;
  1202. { avoid empty files }
  1203. startsectype:=sec_code;
  1204. while assigned(hp) and
  1205. (Tai(hp).typ in [ait_marker,ait_comment,ait_section,ait_cutobject]) do
  1206. begin
  1207. if Tai(hp).typ=ait_section then
  1208. startsectype:=Tai_section(hp).sectype;
  1209. if (Tai(hp).typ=ait_cutobject) then
  1210. place:=Tai_cutobject(hp).place;
  1211. hp:=Tai(hp.next);
  1212. end;
  1213. if not MaybeNextList(hp) then
  1214. break;
  1215. { start next objectfile }
  1216. NextSmartName(place);
  1217. end;
  1218. ObjData.free;
  1219. ObjData:=nil;
  1220. ObjWriter.free;
  1221. end;
  1222. procedure TInternalAssembler.MakeObject;
  1223. var to_do:set of TasmlistType;
  1224. i:TasmlistType;
  1225. procedure addlist(p:TAsmList);
  1226. begin
  1227. inc(lists);
  1228. list[lists]:=p;
  1229. end;
  1230. begin
  1231. to_do:=[low(Tasmlisttype)..high(Tasmlisttype)];
  1232. if usedeffileforexports then
  1233. exclude(to_do,al_exports);
  1234. if not(tf_section_threadvars in target_info.flags) then
  1235. exclude(to_do,al_threadvars);
  1236. for i:=low(TasmlistType) to high(TasmlistType) do
  1237. if (i in to_do) and (current_asmdata.asmlists[i]<>nil) then
  1238. addlist(current_asmdata.asmlists[i]);
  1239. if SmartAsm then
  1240. writetreesmart
  1241. else
  1242. writetree;
  1243. end;
  1244. {*****************************************************************************
  1245. Generate Assembler Files Main Procedure
  1246. *****************************************************************************}
  1247. Procedure GenerateAsm(smart:boolean);
  1248. var
  1249. a : TAssembler;
  1250. begin
  1251. if not assigned(CAssembler[target_asm.id]) then
  1252. Message(asmw_f_assembler_output_not_supported);
  1253. a:=CAssembler[target_asm.id].Create(smart);
  1254. a.MakeObject;
  1255. a.Free;
  1256. end;
  1257. Procedure OnlyAsm;
  1258. var
  1259. a : TExternalAssembler;
  1260. begin
  1261. a:=TExternalAssembler.Create(false);
  1262. a.DoAssemble;
  1263. a.Free;
  1264. end;
  1265. {*****************************************************************************
  1266. Init/Done
  1267. *****************************************************************************}
  1268. procedure RegisterAssembler(const r:tasminfo;c:TAssemblerClass);
  1269. var
  1270. t : tasm;
  1271. begin
  1272. t:=r.id;
  1273. if assigned(asminfos[t]) then
  1274. writeln('Warning: Assembler is already registered!')
  1275. else
  1276. Getmem(asminfos[t],sizeof(tasminfo));
  1277. asminfos[t]^:=r;
  1278. CAssembler[t]:=c;
  1279. end;
  1280. procedure InitAssembler;
  1281. begin
  1282. end;
  1283. procedure DoneAssembler;
  1284. begin
  1285. end;
  1286. end.