agjasmin.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. {
  2. Copyright (c) 1998-2010 by the Free Pascal team
  3. This unit implements the Jasmin assembler writer
  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. { Unit for writing Jasmin assembler (JVM bytecode) output.
  18. }
  19. unit agjasmin;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. cclasses,
  24. globtype,globals,
  25. symbase,symdef,
  26. aasmbase,aasmtai,aasmdata,aasmcpu,
  27. assemble;
  28. type
  29. TJasminInstrWriter = class;
  30. {# This is a derived class which is used to write
  31. Jasmin-styled assembler.
  32. }
  33. { TJasminAssembler }
  34. TJasminAssembler=class(texternalassembler)
  35. protected
  36. jasminjar: tcmdstr;
  37. procedure WriteExtraHeader(obj: tobjectdef);
  38. procedure WriteInstruction(hp: tai);
  39. procedure NewAsmFileForObjectDef(obj: tobjectdef);
  40. procedure WriteProcDef(pd: tprocdef);
  41. procedure WriteSymtableProcdefs(st: TSymtable);
  42. procedure WriteSymtableObjectDefs(st: TSymtable);
  43. public
  44. constructor Create(smart: boolean); override;
  45. function MakeCmdLine: TCmdStr;override;
  46. procedure WriteTree(p:TAsmList);override;
  47. procedure WriteAsmList;override;
  48. destructor destroy; override;
  49. protected
  50. InstrWriter: TJasminInstrWriter;
  51. end;
  52. {# This is the base class for writing instructions.
  53. The WriteInstruction() method must be overridden
  54. to write a single instruction to the assembler
  55. file.
  56. }
  57. { TJasminInstrWriter }
  58. TJasminInstrWriter = class
  59. constructor create(_owner: TJasminAssembler);
  60. procedure WriteInstruction(hp : tai); virtual;
  61. protected
  62. owner: TJasminAssembler;
  63. end;
  64. implementation
  65. uses
  66. SysUtils,
  67. cutils,cfileutl,systems,script,
  68. fmodule,finput,verbose,
  69. symconst,symtype,
  70. itcpujas,cpubase,cgutils,
  71. widestr
  72. ;
  73. const
  74. line_length = 70;
  75. type
  76. t64bitarray = array[0..7] of byte;
  77. t32bitarray = array[0..3] of byte;
  78. {****************************************************************************}
  79. { Support routines }
  80. {****************************************************************************}
  81. function fixline(s:string):string;
  82. {
  83. return s with all leading and ending spaces and tabs removed
  84. }
  85. var
  86. i,j,k : integer;
  87. begin
  88. i:=length(s);
  89. while (i>0) and (s[i] in [#9,' ']) do
  90. dec(i);
  91. j:=1;
  92. while (j<i) and (s[j] in [#9,' ']) do
  93. inc(j);
  94. for k:=j to i do
  95. if s[k] in [#0..#31,#127..#255] then
  96. s[k]:='.';
  97. fixline:=Copy(s,j,i-j+1);
  98. end;
  99. {****************************************************************************}
  100. { Jasmin Assembler writer }
  101. {****************************************************************************}
  102. destructor TJasminAssembler.Destroy;
  103. begin
  104. InstrWriter.free;
  105. inherited destroy;
  106. end;
  107. procedure TJasminAssembler.WriteTree(p:TAsmList);
  108. var
  109. ch : char;
  110. hp : tai;
  111. hp1 : tailineinfo;
  112. constdef : taiconst_type;
  113. s,t : string;
  114. i,pos,l : longint;
  115. InlineLevel : longint;
  116. last_align : longint;
  117. co : comp;
  118. sin : single;
  119. d : double;
  120. do_line : boolean;
  121. sepChar : char;
  122. begin
  123. if not assigned(p) then
  124. exit;
  125. last_align := 2;
  126. InlineLevel:=0;
  127. { lineinfo is only needed for al_procedures (PFV) }
  128. do_line:=(cs_asm_source in current_settings.globalswitches) or
  129. ((cs_lineinfo in current_settings.moduleswitches)
  130. and (p=current_asmdata.asmlists[al_procedures]));
  131. hp:=tai(p.first);
  132. while assigned(hp) do
  133. begin
  134. prefetch(pointer(hp.next)^);
  135. if not(hp.typ in SkipLineInfo) then
  136. begin
  137. hp1 := hp as tailineinfo;
  138. current_filepos:=hp1.fileinfo;
  139. { no line info for inlined code }
  140. if do_line and (inlinelevel=0) then
  141. begin
  142. { load infile }
  143. if lastfileinfo.fileindex<>hp1.fileinfo.fileindex then
  144. begin
  145. infile:=current_module.sourcefiles.get_file(hp1.fileinfo.fileindex);
  146. if assigned(infile) then
  147. begin
  148. { open only if needed !! }
  149. if (cs_asm_source in current_settings.globalswitches) then
  150. infile.open;
  151. end;
  152. { avoid unnecessary reopens of the same file !! }
  153. lastfileinfo.fileindex:=hp1.fileinfo.fileindex;
  154. { be sure to change line !! }
  155. lastfileinfo.line:=-1;
  156. end;
  157. { write source }
  158. if (cs_asm_source in current_settings.globalswitches) and
  159. assigned(infile) then
  160. begin
  161. if (infile<>lastinfile) then
  162. begin
  163. AsmWriteLn(target_asm.comment+'['+infile.name^+']');
  164. if assigned(lastinfile) then
  165. lastinfile.close;
  166. end;
  167. if (hp1.fileinfo.line<>lastfileinfo.line) and
  168. ((hp1.fileinfo.line<infile.maxlinebuf) or (InlineLevel>0)) then
  169. begin
  170. if (hp1.fileinfo.line<>0) and
  171. ((infile.linebuf^[hp1.fileinfo.line]>=0) or (InlineLevel>0)) then
  172. AsmWriteLn(target_asm.comment+'['+tostr(hp1.fileinfo.line)+'] '+
  173. fixline(infile.GetLineStr(hp1.fileinfo.line)));
  174. { set it to a negative value !
  175. to make that is has been read already !! PM }
  176. if (infile.linebuf^[hp1.fileinfo.line]>=0) then
  177. infile.linebuf^[hp1.fileinfo.line]:=-infile.linebuf^[hp1.fileinfo.line]-1;
  178. end;
  179. end;
  180. lastfileinfo:=hp1.fileinfo;
  181. lastinfile:=infile;
  182. end;
  183. end;
  184. case hp.typ of
  185. ait_comment :
  186. Begin
  187. AsmWrite(target_asm.comment);
  188. AsmWritePChar(tai_comment(hp).str);
  189. AsmLn;
  190. End;
  191. ait_regalloc :
  192. begin
  193. if (cs_asm_regalloc in current_settings.globalswitches) then
  194. begin
  195. AsmWrite(#9+target_asm.comment+'Register ');
  196. repeat
  197. AsmWrite(std_regname(Tai_regalloc(hp).reg));
  198. if (hp.next=nil) or
  199. (tai(hp.next).typ<>ait_regalloc) or
  200. (tai_regalloc(hp.next).ratype<>tai_regalloc(hp).ratype) then
  201. break;
  202. hp:=tai(hp.next);
  203. AsmWrite(',');
  204. until false;
  205. AsmWrite(' ');
  206. AsmWriteLn(regallocstr[tai_regalloc(hp).ratype]);
  207. end;
  208. end;
  209. ait_tempalloc :
  210. begin
  211. if (cs_asm_tempalloc in current_settings.globalswitches) then
  212. begin
  213. {$ifdef EXTDEBUG}
  214. if assigned(tai_tempalloc(hp).problem) then
  215. AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+
  216. tostr(tai_tempalloc(hp).tempsize)+' '+tai_tempalloc(hp).problem^)
  217. else
  218. {$endif EXTDEBUG}
  219. AsmWriteLn(target_asm.comment+'Temp '+tostr(tai_tempalloc(hp).temppos)+','+
  220. tostr(tai_tempalloc(hp).tempsize)+' '+tempallocstr[tai_tempalloc(hp).allocation]);
  221. end;
  222. end;
  223. ait_align :
  224. begin
  225. end;
  226. ait_section :
  227. begin
  228. end;
  229. ait_datablock :
  230. begin
  231. internalerror(2010122701);
  232. end;
  233. ait_const:
  234. begin
  235. AsmWriteln('constant');
  236. // internalerror(2010122702);
  237. end;
  238. ait_real_64bit :
  239. begin
  240. internalerror(2010122703);
  241. end;
  242. ait_real_32bit :
  243. begin
  244. internalerror(2010122703);
  245. end;
  246. ait_comp_64bit :
  247. begin
  248. internalerror(2010122704);
  249. end;
  250. ait_string :
  251. begin
  252. pos:=0;
  253. for i:=1 to tai_string(hp).len do
  254. begin
  255. if pos=0 then
  256. begin
  257. AsmWrite(#9'strconst: '#9'"');
  258. pos:=20;
  259. end;
  260. ch:=tai_string(hp).str[i-1];
  261. case ch of
  262. #0, {This can't be done by range, because a bug in FPC}
  263. #1..#31,
  264. #128..#255 : s:='\'+tostr(ord(ch) shr 6)+tostr((ord(ch) and 63) shr 3)+tostr(ord(ch) and 7);
  265. '"' : s:='\"';
  266. '\' : s:='\\';
  267. else
  268. s:=ch;
  269. end;
  270. AsmWrite(s);
  271. inc(pos,length(s));
  272. if (pos>line_length) or (i=tai_string(hp).len) then
  273. begin
  274. AsmWriteLn('"');
  275. pos:=0;
  276. end;
  277. end;
  278. end;
  279. ait_label :
  280. begin
  281. if (tai_label(hp).labsym.is_used) then
  282. begin
  283. AsmWrite(tai_label(hp).labsym.name);
  284. AsmWriteLn(':');
  285. end;
  286. end;
  287. ait_symbol :
  288. begin
  289. if (tai_symbol(hp).sym.typ = AT_FUNCTION) then
  290. begin
  291. AsmWrite('.method ');
  292. AsmWriteLn(tai_symbol(hp).sym.name);
  293. end
  294. else
  295. begin
  296. AsmWrite('data symbol: ');
  297. AsmWriteln(tai_symbol(hp).sym.name);
  298. // internalerror(2010122706);
  299. end;
  300. end;
  301. ait_symbol_end :
  302. begin
  303. AsmWriteLn('.end method');
  304. AsmLn;
  305. end;
  306. ait_instruction :
  307. begin
  308. WriteInstruction(hp);
  309. end;
  310. ait_force_line,
  311. ait_function_name : ;
  312. ait_cutobject :
  313. begin
  314. end;
  315. ait_marker :
  316. if tai_marker(hp).kind=mark_NoLineInfoStart then
  317. inc(InlineLevel)
  318. else if tai_marker(hp).kind=mark_NoLineInfoEnd then
  319. dec(InlineLevel);
  320. ait_directive :
  321. begin
  322. AsmWrite('.'+directivestr[tai_directive(hp).directive]+' ');
  323. if assigned(tai_directive(hp).name) then
  324. AsmWrite(tai_directive(hp).name^);
  325. AsmLn;
  326. end;
  327. else
  328. internalerror(2010122707);
  329. end;
  330. hp:=tai(hp.next);
  331. end;
  332. end;
  333. procedure TJasminAssembler.WriteExtraHeader(obj: tobjectdef);
  334. var
  335. n: string;
  336. begin
  337. { JVM 1.5+ }
  338. AsmWriteLn('.bytecode 49.0');
  339. // include files are not support by Java, and the directory of the main
  340. // source file must not be specified
  341. if assigned(current_module.mainsource) then
  342. n:=ExtractFileName(current_module.mainsource^)
  343. else
  344. n:=InputFileName;
  345. AsmWriteLn('.source '+ExtractFileName(n));
  346. if not assigned(obj) then
  347. begin
  348. { fake class type for unit -> name=unitname and
  349. superclass=java.lang.object }
  350. AsmWriteLn('.class '+ChangeFileExt(ExtractFileName(n),''));
  351. AsmWriteLn('.super java/lang/Object');
  352. end
  353. else
  354. begin
  355. AsmWriteLn('.class '+obj.objextname^);
  356. if assigned(obj.childof) then
  357. begin
  358. AsmWrite('.super ');
  359. if assigned(obj.childof.import_lib) then
  360. AsmWrite(obj.childof.import_lib^+'/');
  361. AsmWriteln(obj.childof.objextname^);
  362. end;
  363. end;
  364. AsmLn;
  365. end;
  366. procedure TJasminAssembler.WriteInstruction(hp: tai);
  367. begin
  368. InstrWriter.WriteInstruction(hp);
  369. end;
  370. function TJasminAssembler.MakeCmdLine: TCmdStr;
  371. const
  372. jasminjarname = 'jasmin.jar';
  373. var
  374. jasminjarfound: boolean;
  375. begin
  376. if jasminjar='' then
  377. begin
  378. jasminjarfound:=false;
  379. if utilsdirectory<>'' then
  380. jasminjarfound:=FindFile(jasminjarname,utilsdirectory,false,jasminjar);
  381. if not jasminjarfound then
  382. jasminjarfound:=FindFileInExeLocations(jasminjarname,false,jasminjar);
  383. if (not jasminjarfound) and not(cs_asm_extern in current_settings.globalswitches) then
  384. begin
  385. Message1(exec_e_assembler_not_found,jasminjarname);
  386. current_settings.globalswitches:=current_settings.globalswitches+[cs_asm_extern];
  387. end;
  388. if jasminjarfound then
  389. Message1(exec_t_using_assembler,jasminjar);
  390. end;
  391. result:=target_asm.asmcmd;
  392. Replace(result,'$ASM',maybequoted(ScriptFixFileName(AsmFileName)));
  393. if (path<>'') then
  394. Replace(result,'$OBJDIR',maybequoted(ScriptFixFileName(path)))
  395. else
  396. Replace(result,'$OBJDIR','.');
  397. Replace(result,'$JASMINJAR',maybequoted(ScriptFixFileName(jasminjar)));
  398. end;
  399. procedure TJasminAssembler.NewAsmFileForObjectDef(obj: tobjectdef);
  400. var
  401. enclosingobj: tobjectdef;
  402. st: tsymtable;
  403. begin
  404. if AsmSize<>AsmStartSize then
  405. begin
  406. AsmClose;
  407. DoAssemble;
  408. end
  409. else
  410. AsmClear;
  411. AsmFileName:=obj.objextname^;
  412. st:=obj.owner;
  413. while assigned(st) and
  414. (st.symtabletype=objectsymtable) do
  415. begin
  416. { nested classes are named as "OuterClass$InnerClass" }
  417. enclosingobj:=tobjectdef(st.defowner);
  418. AsmFileName:=enclosingobj.objextname^+'$'+AsmFileName;
  419. st:=enclosingobj.owner;
  420. end;
  421. AsmFileName:=Path+FixFileName(AsmFileName)+target_info.asmext;
  422. AsmCreate(cut_normal);
  423. end;
  424. procedure TJasminAssembler.WriteProcDef(pd: tprocdef);
  425. begin
  426. WriteTree(pd.exprasmlist);
  427. end;
  428. procedure TJasminAssembler.WriteSymtableProcdefs(st: TSymtable);
  429. var
  430. i : longint;
  431. def : tdef;
  432. obj : tobjectdef;
  433. begin
  434. if not assigned(st) then
  435. exit;
  436. for i:=0 to st.DefList.Count-1 do
  437. begin
  438. def:=tdef(st.DefList[i]);
  439. case def.typ of
  440. procdef :
  441. begin
  442. { methods are also in the static/globalsymtable of the unit
  443. -> make sure they are only written for the objectdefs that
  444. own them }
  445. if not(st.symtabletype in [staticsymtable,globalsymtable]) or
  446. (def.owner=st) then
  447. begin
  448. WriteProcDef(tprocdef(def));
  449. if assigned(tprocdef(def).localst) then
  450. WriteSymtableProcdefs(tprocdef(def).localst);
  451. end;
  452. end;
  453. end;
  454. end;
  455. end;
  456. procedure TJasminAssembler.WriteSymtableObjectDefs(st: TSymtable);
  457. var
  458. i : longint;
  459. def : tdef;
  460. obj : tobjectdef;
  461. nestedclasses: tfpobjectlist;
  462. begin
  463. if not assigned(st) then
  464. exit;
  465. nestedclasses:=tfpobjectlist.create(false);
  466. for i:=0 to st.DefList.Count-1 do
  467. begin
  468. def:=tdef(st.DefList[i]);
  469. case def.typ of
  470. objectdef:
  471. if not(oo_is_external in tobjectdef(def).objectoptions) then
  472. nestedclasses.add(def);
  473. end;
  474. end;
  475. for i:=0 to nestedclasses.count-1 do
  476. begin
  477. obj:=tobjectdef(nestedclasses[i]);
  478. NewAsmFileForObjectDef(obj);
  479. WriteExtraHeader(obj);
  480. WriteSymtableProcDefs(obj.symtable);
  481. WriteSymtableObjectDefs(obj.symtable);
  482. end;
  483. nestedclasses.free;
  484. end;
  485. constructor TJasminAssembler.Create(smart: boolean);
  486. begin
  487. inherited create(smart);
  488. InstrWriter:=TJasminInstrWriter.Create(self);
  489. end;
  490. procedure TJasminAssembler.WriteAsmList;
  491. var
  492. hal : tasmlisttype;
  493. i: longint;
  494. begin
  495. {$ifdef EXTDEBUG}
  496. if assigned(current_module.mainsource) then
  497. Comment(V_Debug,'Start writing Jasmin-styled assembler output for '+current_module.mainsource^);
  498. {$endif}
  499. AsmStartSize:=AsmSize;
  500. WriteExtraHeader(nil);
  501. (*
  502. for hal:=low(TasmlistType) to high(TasmlistType) do
  503. begin
  504. AsmWriteLn(target_asm.comment+'Begin asmlist '+AsmlistTypeStr[hal]);
  505. writetree(current_asmdata.asmlists[hal]);
  506. AsmWriteLn(target_asm.comment+'End asmlist '+AsmlistTypeStr[hal]);
  507. end;
  508. *)
  509. { print all global procedures/functions }
  510. WriteSymtableProcdefs(current_module.globalsymtable);
  511. WriteSymtableProcdefs(current_module.localsymtable);
  512. WriteSymtableObjectDefs(current_module.globalsymtable);
  513. WriteSymtableObjectDefs(current_module.localsymtable);
  514. AsmLn;
  515. {$ifdef EXTDEBUG}
  516. if assigned(current_module.mainsource) then
  517. Comment(V_Debug,'Done writing gas-styled assembler output for '+current_module.mainsource^);
  518. {$endif EXTDEBUG}
  519. end;
  520. {****************************************************************************}
  521. { Jasmin Instruction Writer }
  522. {****************************************************************************}
  523. constructor TJasminInstrWriter.create(_owner: TJasminAssembler);
  524. begin
  525. inherited create;
  526. owner := _owner;
  527. end;
  528. function getreferencestring(var ref : treference) : string;
  529. begin
  530. if (ref.arrayreftype<>art_none) or
  531. (ref.index<>NR_NO) then
  532. internalerror(2010122809);
  533. if assigned(ref.symbol) then
  534. begin
  535. // global symbol -> full type/name
  536. if (ref.base<>NR_NO) or
  537. (ref.offset<>0) then
  538. internalerror(2010122811);
  539. result:=ref.symbol.name;
  540. end
  541. else
  542. begin
  543. // local symbol -> stack slot, stored in offset
  544. if ref.base<>NR_STACK_POINTER_REG then
  545. internalerror(2010122810);
  546. result:=tostr(ref.offset);
  547. end;
  548. end;
  549. function getopstr(const o:toper) : ansistring;
  550. var
  551. i,runstart,runlen: longint;
  552. num: string[4];
  553. begin
  554. case o.typ of
  555. top_reg:
  556. // should have been translated into a memory location by the
  557. // register allocator)
  558. if (cs_no_regalloc in current_settings.globalswitches) then
  559. getopstr:=std_regname(o.reg)
  560. else
  561. internalerror(2010122803);
  562. top_const:
  563. str(o.val,result);
  564. top_ref:
  565. getopstr:=getreferencestring(o.ref^);
  566. top_single:
  567. str(o.sval:0:20,result);
  568. top_double:
  569. begin
  570. str(o.dval:0:20,result);
  571. // force interpretation as double
  572. result:=result+'d';
  573. end;
  574. top_string:
  575. begin
  576. { escape control codes }
  577. runlen:=0;
  578. runstart:=0;
  579. for i:=1 to o.pcvallen do
  580. begin
  581. if o.pcval[i]<#32 then
  582. begin
  583. if runlen>0 then
  584. begin
  585. setlength(result,length(result)+runlen);
  586. move(result[length(result)-runlen],o.pcval[runstart],runlen);
  587. runlen:=0;
  588. end;
  589. result:=result+'\u'+hexstr(ord(o.pcval[i]),4);
  590. end
  591. else if o.pcval[i]<#127 then
  592. begin
  593. if runlen=0 then
  594. runstart:=i;
  595. inc(runlen);
  596. end
  597. else
  598. // since Jasmin expects an UTF-16 string, we can't safely
  599. // have high ASCII characters since they'll be
  600. // re-interpreted as utf-16 anyway
  601. internalerror(2010122808);
  602. end;
  603. if runlen>0 then
  604. begin
  605. setlength(result,length(result)+runlen);
  606. move(result[length(result)-runlen],o.pcval[runstart],runlen);
  607. end;
  608. end;
  609. top_wstring:
  610. begin
  611. { escape control codes }
  612. for i:=1 to getlengthwidestring(o.pwstrval) do
  613. begin
  614. if (o.pwstrval^.data[i]<32) or
  615. (o.pwstrval^.data[i]>127) then
  616. result:=result+'\u'+hexstr(o.pwstrval^.data[i],4)
  617. else
  618. result:=result+char(o.pwstrval^.data[i]);
  619. end;
  620. end
  621. else
  622. internalerror(2010122802);
  623. end;
  624. end;
  625. procedure TJasminInstrWriter.WriteInstruction(hp: tai);
  626. var
  627. s: ansistring;
  628. i: byte;
  629. sep: string[3];
  630. begin
  631. s:=#9+jas_op2str[taicpu(hp).opcode];
  632. if taicpu(hp).ops<>0 then
  633. begin
  634. sep:=#9;
  635. for i:=0 to taicpu(hp).ops-1 do
  636. begin
  637. s:=s+sep+getopstr(taicpu(hp).oper[i]^);
  638. sep:=',';
  639. end;
  640. end;
  641. owner.AsmWriteLn(s);
  642. end;
  643. {****************************************************************************}
  644. { Jasmin Instruction Writer }
  645. {****************************************************************************}
  646. const
  647. as_jvm_jasmin_info : tasminfo =
  648. (
  649. id : as_jvm_jasmin;
  650. idtxt : 'Jasmin';
  651. asmbin : 'java';
  652. asmcmd : '-jar $JASMINJAR $ASM -d $OBJDIR';
  653. supported_targets : [system_jvm_java32];
  654. flags : [];
  655. labelprefix : 'L';
  656. comment : ' ; ';
  657. );
  658. begin
  659. RegisterAssembler(as_jvm_jasmin_info,TJasminAssembler);
  660. end.