rappcgas.pas 25 KB

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