rappcgas.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Carl Eric Codere and Peter Vreman
  4. Does the parsing for the PowerPC GNU AS styled inline assembler.
  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. Unit rappcgas;
  19. {$i fpcdefs.inc}
  20. Interface
  21. uses
  22. raatt,rappc;
  23. type
  24. tppcattreader = class(tattreader)
  25. function is_asmopcode(const s: string):boolean;override;
  26. procedure handleopcode;override;
  27. procedure BuildReference(oper : tppcoperand);
  28. procedure BuildOperand(oper : tppcoperand);
  29. procedure BuildOpCode(instr : tppcinstruction);
  30. procedure ReadAt(oper : tppcoperand);
  31. procedure ReadSym(oper : tppcoperand);
  32. { procedure ConvertCalljmp(instr : tppcinstruction); }
  33. end;
  34. Implementation
  35. uses
  36. { helpers }
  37. cutils,
  38. { global }
  39. globtype,globals,verbose,
  40. systems,
  41. { aasm }
  42. cpubase,cpuinfo,aasmbase,aasmtai,aasmcpu,
  43. { symtable }
  44. symconst,symbase,symtype,symsym,symtable,
  45. { parser }
  46. scanner,
  47. procinfo,
  48. itcpugas,
  49. rabase,rautils,
  50. cgbase,cgobj
  51. ;
  52. procedure tppcattreader.ReadSym(oper : tppcoperand);
  53. var
  54. tempstr : string;
  55. typesize,l,k : longint;
  56. begin
  57. tempstr:=actasmpattern;
  58. Consume(AS_ID);
  59. { typecasting? }
  60. if (actasmtoken=AS_LPAREN) and
  61. SearchType(tempstr,typesize) then
  62. begin
  63. oper.hastype:=true;
  64. Consume(AS_LPAREN);
  65. BuildOperand(oper);
  66. Consume(AS_RPAREN);
  67. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  68. oper.SetSize(typesize,true);
  69. end
  70. else
  71. if not oper.SetupVar(tempstr,false) then
  72. Message1(sym_e_unknown_id,tempstr);
  73. { record.field ? }
  74. if actasmtoken=AS_DOT then
  75. begin
  76. BuildRecordOffsetSize(tempstr,l,k);
  77. inc(oper.opr.ref.offset,l);
  78. end;
  79. end;
  80. procedure tppcattreader.ReadAt(oper : tppcoperand);
  81. begin
  82. { check for ...@ }
  83. if actasmtoken=AS_AT then
  84. begin
  85. if (oper.opr.ref.symbol=nil) and
  86. (oper.opr.ref.offset = 0) then
  87. Message(asmr_e_invalid_reference_syntax);
  88. Consume(AS_AT);
  89. if actasmtoken=AS_ID then
  90. begin
  91. if upper(actasmpattern)='L' then
  92. oper.opr.ref.refaddr:=addr_lo
  93. else if upper(actasmpattern)='HA' then
  94. oper.opr.ref.refaddr:=addr_hi
  95. else
  96. Message(asmr_e_invalid_reference_syntax);
  97. Consume(AS_ID);
  98. end
  99. else
  100. Message(asmr_e_invalid_reference_syntax);
  101. end;
  102. end;
  103. Procedure tppcattreader.BuildReference(oper : tppcoperand);
  104. procedure Consume_RParen;
  105. begin
  106. if actasmtoken <> AS_RPAREN then
  107. Begin
  108. Message(asmr_e_invalid_reference_syntax);
  109. RecoverConsume(true);
  110. end
  111. else
  112. begin
  113. Consume(AS_RPAREN);
  114. if not (actasmtoken in [AS_COMMA,AS_SEPARATOR,AS_END]) then
  115. Begin
  116. Message(asmr_e_invalid_reference_syntax);
  117. RecoverConsume(true);
  118. end;
  119. end;
  120. end;
  121. var
  122. l : longint;
  123. begin
  124. Consume(AS_LPAREN);
  125. Case actasmtoken of
  126. AS_INTNUM,
  127. AS_MINUS,
  128. AS_PLUS:
  129. Begin
  130. { offset(offset) is invalid }
  131. If oper.opr.Ref.Offset <> 0 Then
  132. Begin
  133. Message(asmr_e_invalid_reference_syntax);
  134. RecoverConsume(true);
  135. End
  136. Else
  137. Begin
  138. oper.opr.Ref.Offset:=BuildConstExpression(false,true);
  139. Consume(AS_RPAREN);
  140. if actasmtoken=AS_AT then
  141. ReadAt(oper);
  142. end;
  143. exit;
  144. End;
  145. AS_REGISTER: { (reg ... }
  146. Begin
  147. if ((oper.opr.typ=OPR_REFERENCE) and (oper.opr.ref.base<>NR_NO)) or
  148. ((oper.opr.typ=OPR_LOCAL) and (oper.opr.localsym.localloc.loc<>LOC_REGISTER)) then
  149. message(asmr_e_cannot_index_relative_var);
  150. oper.opr.ref.base:=actasmregister;
  151. Consume(AS_REGISTER);
  152. { can either be a register or a right parenthesis }
  153. { (reg) }
  154. if actasmtoken=AS_RPAREN then
  155. Begin
  156. Consume_RParen;
  157. exit;
  158. end;
  159. { (reg,reg .. }
  160. Consume(AS_COMMA);
  161. if (actasmtoken=AS_REGISTER) and
  162. (oper.opr.Ref.Offset = 0) then
  163. Begin
  164. oper.opr.ref.index:=actasmregister;
  165. Consume(AS_REGISTER);
  166. Consume_RParen;
  167. end
  168. else
  169. Begin
  170. Message(asmr_e_invalid_reference_syntax);
  171. RecoverConsume(false);
  172. end;
  173. end; {end case }
  174. AS_ID:
  175. Begin
  176. ReadSym(oper);
  177. { add a constant expression? }
  178. if (actasmtoken=AS_PLUS) then
  179. begin
  180. l:=BuildConstExpression(true,true);
  181. case oper.opr.typ of
  182. OPR_CONSTANT :
  183. inc(oper.opr.val,l);
  184. OPR_LOCAL :
  185. inc(oper.opr.localsymofs,l);
  186. OPR_REFERENCE :
  187. inc(oper.opr.ref.offset,l);
  188. else
  189. internalerror(200309202);
  190. end;
  191. end;
  192. Consume(AS_RPAREN);
  193. if actasmtoken=AS_AT then
  194. ReadAt(oper);
  195. End;
  196. AS_COMMA: { (, ... can either be scaling, or index }
  197. Begin
  198. Consume(AS_COMMA);
  199. { Index }
  200. if (actasmtoken=AS_REGISTER) then
  201. Begin
  202. oper.opr.ref.index:=actasmregister;
  203. Consume(AS_REGISTER);
  204. { check for scaling ... }
  205. Consume_RParen;
  206. end
  207. else
  208. begin
  209. Message(asmr_e_invalid_reference_syntax);
  210. RecoverConsume(false);
  211. end;
  212. end;
  213. else
  214. Begin
  215. Message(asmr_e_invalid_reference_syntax);
  216. RecoverConsume(false);
  217. end;
  218. end;
  219. end;
  220. Procedure tppcattreader.BuildOperand(oper : tppcoperand);
  221. var
  222. expr : string;
  223. typesize,l : longint;
  224. procedure AddLabelOperand(hl:tasmlabel);
  225. begin
  226. if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and
  227. is_calljmp(actopcode) then
  228. begin
  229. oper.opr.typ:=OPR_SYMBOL;
  230. oper.opr.symbol:=hl;
  231. end
  232. else
  233. begin
  234. oper.InitRef;
  235. oper.opr.ref.symbol:=hl;
  236. end;
  237. end;
  238. procedure MaybeRecordOffset;
  239. var
  240. hasdot : boolean;
  241. l,
  242. toffset,
  243. tsize : longint;
  244. begin
  245. if not(actasmtoken in [AS_DOT,AS_PLUS,AS_MINUS]) then
  246. exit;
  247. l:=0;
  248. hasdot:=(actasmtoken=AS_DOT);
  249. if hasdot then
  250. begin
  251. if expr<>'' then
  252. begin
  253. BuildRecordOffsetSize(expr,toffset,tsize);
  254. inc(l,toffset);
  255. oper.SetSize(tsize,true);
  256. end;
  257. end;
  258. if actasmtoken in [AS_PLUS,AS_MINUS] then
  259. inc(l,BuildConstExpression(true,false));
  260. case oper.opr.typ of
  261. OPR_LOCAL :
  262. begin
  263. { don't allow direct access to fields of parameters, because that
  264. will generate buggy code. Allow it only for explicit typecasting }
  265. if hasdot and
  266. (not oper.hastype) and
  267. (tvarsym(oper.opr.localsym).owner.symtabletype=parasymtable) and
  268. (current_procinfo.procdef.proccalloption<>pocall_register) then
  269. Message(asmr_e_cannot_access_field_directly_for_parameters);
  270. inc(oper.opr.localsymofs,l)
  271. end;
  272. OPR_CONSTANT :
  273. inc(oper.opr.val,l);
  274. OPR_REFERENCE :
  275. inc(oper.opr.ref.offset,l);
  276. else
  277. internalerror(200309221);
  278. end;
  279. end;
  280. function MaybeBuildReference:boolean;
  281. { Try to create a reference, if not a reference is found then false
  282. is returned }
  283. begin
  284. MaybeBuildReference:=true;
  285. case actasmtoken of
  286. AS_INTNUM,
  287. AS_MINUS,
  288. AS_PLUS:
  289. Begin
  290. oper.opr.ref.offset:=BuildConstExpression(True,False);
  291. if actasmtoken<>AS_LPAREN then
  292. Message(asmr_e_invalid_reference_syntax)
  293. else
  294. BuildReference(oper);
  295. end;
  296. AS_LPAREN:
  297. BuildReference(oper);
  298. AS_ID: { only a variable is allowed ... }
  299. Begin
  300. ReadSym(oper);
  301. case actasmtoken of
  302. AS_END,
  303. AS_SEPARATOR,
  304. AS_COMMA: ;
  305. AS_LPAREN:
  306. BuildReference(oper);
  307. else
  308. Begin
  309. Message(asmr_e_invalid_reference_syntax);
  310. Consume(actasmtoken);
  311. end;
  312. end; {end case }
  313. end;
  314. else
  315. MaybeBuildReference:=false;
  316. end; { end case }
  317. end;
  318. var
  319. tempreg : tregister;
  320. hl : tasmlabel;
  321. ofs : longint;
  322. Begin
  323. expr:='';
  324. case actasmtoken of
  325. AS_LPAREN: { Memory reference or constant expression }
  326. Begin
  327. oper.InitRef;
  328. BuildReference(oper);
  329. end;
  330. AS_INTNUM,
  331. AS_MINUS,
  332. AS_PLUS:
  333. Begin
  334. { Constant memory offset }
  335. { This must absolutely be followed by ( }
  336. oper.InitRef;
  337. oper.opr.ref.offset:=BuildConstExpression(True,False);
  338. if actasmtoken<>AS_LPAREN then
  339. begin
  340. ofs:=oper.opr.ref.offset;
  341. BuildConstantOperand(oper);
  342. inc(oper.opr.val,ofs);
  343. end
  344. else
  345. BuildReference(oper);
  346. end;
  347. AS_ID: { A constant expression, or a Variable ref. }
  348. Begin
  349. { Local Label ? }
  350. if is_locallabel(actasmpattern) then
  351. begin
  352. CreateLocalLabel(actasmpattern,hl,false);
  353. Consume(AS_ID);
  354. AddLabelOperand(hl);
  355. end
  356. else
  357. { Check for label }
  358. if SearchLabel(actasmpattern,hl,false) then
  359. begin
  360. Consume(AS_ID);
  361. AddLabelOperand(hl);
  362. end
  363. else
  364. { probably a variable or normal expression }
  365. { or a procedure (such as in CALL ID) }
  366. Begin
  367. { is it a constant ? }
  368. if SearchIConstant(actasmpattern,l) then
  369. Begin
  370. if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
  371. Message(asmr_e_invalid_operand_type);
  372. BuildConstantOperand(oper);
  373. end
  374. else
  375. begin
  376. expr:=actasmpattern;
  377. Consume(AS_ID);
  378. { typecasting? }
  379. if (actasmtoken=AS_LPAREN) and
  380. SearchType(expr,typesize) then
  381. begin
  382. oper.hastype:=true;
  383. Consume(AS_LPAREN);
  384. BuildOperand(oper);
  385. Consume(AS_RPAREN);
  386. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  387. oper.SetSize(typesize,true);
  388. end
  389. else
  390. begin
  391. if oper.SetupVar(expr,false) then
  392. ReadAt(oper)
  393. else
  394. Begin
  395. { look for special symbols ... }
  396. if expr= '__HIGH' then
  397. begin
  398. consume(AS_LPAREN);
  399. if not oper.setupvar('high'+actasmpattern,false) then
  400. Message1(sym_e_unknown_id,'high'+actasmpattern);
  401. consume(AS_ID);
  402. consume(AS_RPAREN);
  403. end
  404. else
  405. if expr = '__RESULT' then
  406. oper.SetUpResult
  407. else
  408. if expr = '__SELF' then
  409. oper.SetupSelf
  410. else
  411. if expr = '__OLDEBP' then
  412. oper.SetupOldEBP
  413. else
  414. { check for direct symbolic names }
  415. { only if compiling the system unit }
  416. if (cs_compilesystem in aktmoduleswitches) then
  417. begin
  418. if not oper.SetupDirectVar(expr) then
  419. Begin
  420. { not found, finally ... add it anyways ... }
  421. Message1(asmr_w_id_supposed_external,expr);
  422. oper.InitRef;
  423. oper.opr.ref.symbol:=objectlibrary.newasmsymbol(expr);
  424. end;
  425. end
  426. else
  427. Message1(sym_e_unknown_id,expr);
  428. end;
  429. end;
  430. end;
  431. if actasmtoken=AS_DOT then
  432. MaybeRecordOffset;
  433. { add a constant expression? }
  434. if (actasmtoken=AS_PLUS) then
  435. begin
  436. l:=BuildConstExpression(true,false);
  437. case oper.opr.typ of
  438. OPR_CONSTANT :
  439. inc(oper.opr.val,l);
  440. OPR_LOCAL :
  441. inc(oper.opr.localsymofs,l);
  442. OPR_REFERENCE :
  443. inc(oper.opr.ref.offset,l);
  444. else
  445. internalerror(200309202);
  446. end;
  447. end
  448. end;
  449. { Do we have a indexing reference, then parse it also }
  450. if actasmtoken=AS_LPAREN then
  451. BuildReference(oper);
  452. end;
  453. AS_REGISTER: { Register, a variable reference or a constant reference }
  454. Begin
  455. { save the type of register used. }
  456. tempreg:=actasmregister;
  457. Consume(AS_REGISTER);
  458. if (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then
  459. if is_condreg(tempreg) and
  460. ((actopcode = A_BC) or
  461. (actopcode = A_BCCTR) or
  462. (actopcode = A_BCLR) or
  463. (actopcode = A_TW) or
  464. (actopcode = A_TWI)) then
  465. begin
  466. { it isn't a real operand, everything is stored in the condition }
  467. oper.opr.typ:=OPR_NONE;
  468. actcondition.cr := getsupreg(tempreg);
  469. end
  470. else
  471. begin
  472. if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then
  473. Message(asmr_e_invalid_operand_type);
  474. oper.opr.typ:=OPR_REGISTER;
  475. oper.opr.reg:=tempreg;
  476. end
  477. else if is_condreg(tempreg) then
  478. begin
  479. if not(actcondition.cond in [C_T..C_DZF]) then
  480. Message(asmr_e_syn_operand);
  481. if actasmtoken=AS_STAR then
  482. begin
  483. consume(AS_STAR);
  484. if (actasmtoken=AS_INTNUM) then
  485. begin
  486. consume(AS_INTNUM);
  487. if actasmtoken=AS_PLUS then
  488. begin
  489. consume(AS_PLUS);
  490. if (actasmtoken=AS_ID) then
  491. begin
  492. oper.opr.typ:=OPR_NONE;
  493. if actasmpattern='LT' then
  494. actcondition.crbit:=(getsupreg(tempreg)-(RS_CR0))*4
  495. else if actasmpattern='GT' then
  496. actcondition.crbit:=(getsupreg(tempreg)-(RS_CR0))*4+1
  497. else if actasmpattern='EQ' then
  498. actcondition.crbit:=(getsupreg(tempreg)-(RS_CR0))*4+2
  499. else if actasmpattern='SO' then
  500. actcondition.crbit:=(getsupreg(tempreg)-(RS_CR0))*4+3
  501. else
  502. Message(asmr_e_syn_operand);
  503. consume(AS_ID);
  504. end
  505. else
  506. Message(asmr_e_syn_operand);
  507. end
  508. else
  509. Message(asmr_e_syn_operand);
  510. end
  511. else
  512. Message(asmr_e_syn_operand);
  513. end
  514. else
  515. Message(asmr_e_syn_operand);
  516. end
  517. else
  518. Message(asmr_e_syn_operand);
  519. end;
  520. AS_END,
  521. AS_SEPARATOR,
  522. AS_COMMA: ;
  523. else
  524. Begin
  525. Message(asmr_e_syn_operand);
  526. Consume(actasmtoken);
  527. end;
  528. end; { end case }
  529. end;
  530. {*****************************************************************************
  531. tppcattreader
  532. *****************************************************************************}
  533. procedure tppcattreader.BuildOpCode(instr : tppcinstruction);
  534. var
  535. operandnum : longint;
  536. Begin
  537. { opcode }
  538. if (actasmtoken<>AS_OPCODE) then
  539. Begin
  540. Message(asmr_e_invalid_or_missing_opcode);
  541. RecoverConsume(true);
  542. exit;
  543. end;
  544. { Fill the instr object with the current state }
  545. with instr do
  546. begin
  547. Opcode:=ActOpcode;
  548. condition:=ActCondition;
  549. end;
  550. { We are reading operands, so opcode will be an AS_ID }
  551. operandnum:=1;
  552. Consume(AS_OPCODE);
  553. { Zero operand opcode ? }
  554. if actasmtoken in [AS_SEPARATOR,AS_END] then
  555. begin
  556. operandnum:=0;
  557. exit;
  558. end;
  559. { Read the operands }
  560. repeat
  561. case actasmtoken of
  562. AS_COMMA: { Operand delimiter }
  563. Begin
  564. if operandnum>Max_Operands then
  565. Message(asmr_e_too_many_operands)
  566. else
  567. begin
  568. { condition operands doesn't set the operand but write to the
  569. condition field of the instruction
  570. }
  571. if instr.Operands[operandnum].opr.typ<>OPR_NONE then
  572. Inc(operandnum);
  573. end;
  574. Consume(AS_COMMA);
  575. end;
  576. AS_SEPARATOR,
  577. AS_END : { End of asm operands for this opcode }
  578. begin
  579. break;
  580. end;
  581. else
  582. BuildOperand(instr.Operands[operandnum] as tppcoperand);
  583. end; { end case }
  584. until false;
  585. if (operandnum=1) and (instr.Operands[operandnum].opr.typ=OPR_NONE) then
  586. dec(operandnum);
  587. instr.Ops:=operandnum;
  588. end;
  589. function tppcattreader.is_asmopcode(const s: string):boolean;
  590. var
  591. str2opentry: tstr2opentry;
  592. cond : tasmcondflag;
  593. j,
  594. sufidx : longint;
  595. hs : string;
  596. Begin
  597. { making s a value parameter would break other assembler readers }
  598. hs:=s;
  599. is_asmopcode:=false;
  600. { clear op code }
  601. actopcode:=A_None;
  602. { clear condition }
  603. fillchar(actcondition,sizeof(actcondition),0);
  604. { check for direction hint }
  605. if hs[length(s)]='-' then
  606. begin
  607. dec(ord(hs[0]));
  608. actcondition.dirhint:=DH_Minus;
  609. end
  610. else if hs[length(s)]='+' then
  611. begin
  612. dec(ord(hs[0]));
  613. actcondition.dirhint:=DH_Plus;
  614. end;
  615. str2opentry:=tstr2opentry(iasmops.search(hs));
  616. if assigned(str2opentry) then
  617. begin
  618. if actcondition.dirhint<>DH_None then
  619. message1(asmr_e_unknown_opcode,actasmpattern);
  620. actopcode:=str2opentry.op;
  621. actasmtoken:=AS_OPCODE;
  622. is_asmopcode:=true;
  623. exit;
  624. end;
  625. { not found, check branch instructions }
  626. if hs[1]='B' then
  627. begin
  628. { we can search here without an extra table which is sorted by string length
  629. because we take the whole remaining string without the leading B }
  630. if copy(hs,length(s)-1,2)='LR' then
  631. begin
  632. actopcode := A_BCLR;
  633. setlength(hs,length(hs)-2)
  634. end
  635. else if copy(hs,length(s)-2,3)='CTR' then
  636. begin
  637. actopcode := A_BCCTR;
  638. setlength(hs,length(hs)-3)
  639. end
  640. else
  641. actopcode := A_BC;
  642. for cond:=low(TAsmCondFlag) to high(TAsmCondFlag) do
  643. if copy(hs,2,length(s)-1)=UpperAsmCondFlag2Str[cond] then
  644. begin
  645. actcondition.simple:=true;
  646. actcondition.cond:=cond;
  647. if (cond in [C_LT,C_LE,C_EQ,C_GE,C_GT,C_NL,C_NE,C_NG,C_SO,C_NS,C_UN,C_NU]) then
  648. actcondition.cr := RS_CR0;
  649. actasmtoken:=AS_OPCODE;
  650. is_asmopcode:=true;
  651. exit;
  652. end;
  653. end;
  654. end;
  655. {
  656. procedure tppcattreader.ConvertCalljmp(instr : tppcinstruction);
  657. var
  658. newopr : toprrec;
  659. begin
  660. if instr.Operands[1].opr.typ=OPR_REFERENCE then
  661. begin
  662. newopr.typ:=OPR_SYMBOL;
  663. newopr.symbol:=instr.Operands[1].opr.ref.symbol;
  664. newopr.symofs:=instr.Operands[1].opr.ref.offset;
  665. if (instr.Operands[1].opr.ref.base<>NR_NO) or
  666. (instr.Operands[1].opr.ref.index<>NR_NO) or
  667. (instr.Operands[1].opr.ref.symaddr<>refs_full) then
  668. Message(asmr_e_syn_operand);
  669. instr.Operands[1].opr:=newopr;
  670. end;
  671. end;
  672. }
  673. procedure tppcattreader.handleopcode;
  674. var
  675. instr : tppcinstruction;
  676. begin
  677. instr:=TPPCInstruction.Create(TPPCOperand);
  678. BuildOpcode(instr);
  679. instr.condition := actcondition;
  680. {
  681. if is_calljmp(instr.opcode) then
  682. ConvertCalljmp(instr);
  683. }
  684. {
  685. instr.AddReferenceSizes;
  686. instr.SetInstructionOpsize;
  687. instr.CheckOperandSizes;
  688. }
  689. instr.ConcatInstruction(curlist);
  690. instr.Free;
  691. end;
  692. {*****************************************************************************
  693. Initialize
  694. *****************************************************************************}
  695. const
  696. asmmode_ppc_att_info : tasmmodeinfo =
  697. (
  698. id : asmmode_ppc_gas;
  699. idtxt : 'GAS';
  700. casmreader : tppcattreader;
  701. );
  702. asmmode_ppc_standard_info : tasmmodeinfo =
  703. (
  704. id : asmmode_standard;
  705. idtxt : 'STANDARD';
  706. casmreader : tppcattreader;
  707. );
  708. initialization
  709. RegisterAsmMode(asmmode_ppc_att_info);
  710. RegisterAsmMode(asmmode_ppc_standard_info);
  711. end.
  712. {
  713. $Log$
  714. Revision 1.10 2004-02-27 10:21:05 florian
  715. * top_symbol killed
  716. + refaddr to treference added
  717. + refsymbol to treference added
  718. * top_local stuff moved to an extra record to save memory
  719. + aint introduced
  720. * tppufile.get/putint64/aint implemented
  721. Revision 1.9 2004/02/04 15:23:28 olle
  722. * uodated header comment
  723. Revision 1.8 2003/11/29 22:54:32 jonas
  724. * more ppc fixes, hello world works again under linuxppc
  725. Revision 1.7 2003/11/29 16:27:19 jonas
  726. * fixed several ppc assembler reader related problems
  727. * local vars in assembler procedures now start at offset 4
  728. * fixed second_int_to_bool (apparently an integer can be in LOC_JUMP??)
  729. Revision 1.6 2003/11/23 20:00:39 jonas
  730. * fixed is_condreg
  731. * fixed branch condition parsing in assembler reader
  732. Revision 1.5 2003/11/23 18:32:42 florian
  733. + skeleton for bXX crX,<label>
  734. Revision 1.4 2003/11/23 17:33:24 jonas
  735. * fixed uninitialised var
  736. Revision 1.3 2003/11/15 19:00:10 florian
  737. * fixed ppc assembler reader
  738. Revision 1.2 2003/11/12 16:05:40 florian
  739. * assembler readers OOPed
  740. + typed currency constants
  741. + typed 128 bit float constants if the CPU supports it
  742. Revision 1.1 2003/11/06 20:48:02 florian
  743. * initial revision
  744. }