ra386.pas 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Carl Eric Codere and Peter Vreman
  4. Handles the common i386 assembler reader routines
  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 Ra386;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. aasmbase,aasmtai,aasmcpu,
  23. cpubase,rautils,cclasses;
  24. { Parser helpers }
  25. function is_prefix(t:tasmop):boolean;
  26. function is_override(t:tasmop):boolean;
  27. Function CheckPrefix(prefixop,op:tasmop): Boolean;
  28. Function CheckOverride(overrideop,op:tasmop): Boolean;
  29. Procedure FWaitWarning;
  30. type
  31. T386Operand=class(TOperand)
  32. Procedure SetCorrectSize(opcode:tasmop);override;
  33. end;
  34. T386Instruction=class(TInstruction)
  35. OpOrder : TOperandOrder;
  36. { Operand sizes }
  37. procedure AddReferenceSizes;
  38. procedure SetInstructionOpsize;
  39. procedure CheckOperandSizes;
  40. procedure CheckNonCommutativeOpcodes;
  41. procedure SwapOperands;
  42. { opcode adding }
  43. procedure ConcatInstruction(p : taasmoutput);override;
  44. end;
  45. tstr2opentry = class(Tnamedindexitem)
  46. op: TAsmOp;
  47. end;
  48. const
  49. AsmPrefixes = 6;
  50. AsmPrefix : array[0..AsmPrefixes-1] of TasmOP =(
  51. A_LOCK,A_REP,A_REPE,A_REPNE,A_REPNZ,A_REPZ
  52. );
  53. AsmOverrides = 6;
  54. AsmOverride : array[0..AsmOverrides-1] of TasmOP =(
  55. A_SEGCS,A_SEGES,A_SEGDS,A_SEGFS,A_SEGGS,A_SEGSS
  56. );
  57. CondAsmOps=3;
  58. CondAsmOp:array[0..CondAsmOps-1] of TasmOp=(
  59. A_CMOVcc, A_Jcc, A_SETcc
  60. );
  61. CondAsmOpStr:array[0..CondAsmOps-1] of string[4]=(
  62. 'CMOV','J','SET'
  63. );
  64. implementation
  65. uses
  66. globtype,globals,systems,verbose,
  67. cpuinfo,ag386att;
  68. {$define ATTOP}
  69. {$define INTELOP}
  70. {$ifdef NORA386INT}
  71. {$ifdef NOAG386NSM}
  72. {$ifdef NOAG386INT}
  73. {$undef INTELOP}
  74. {$endif}
  75. {$endif}
  76. {$endif}
  77. {$ifdef NORA386ATT}
  78. {$ifdef NOAG386ATT}
  79. {$undef ATTOP}
  80. {$endif}
  81. {$endif}
  82. {*****************************************************************************
  83. Parser Helpers
  84. *****************************************************************************}
  85. function is_prefix(t:tasmop):boolean;
  86. var
  87. i : longint;
  88. Begin
  89. is_prefix:=false;
  90. for i:=1 to AsmPrefixes do
  91. if t=AsmPrefix[i-1] then
  92. begin
  93. is_prefix:=true;
  94. exit;
  95. end;
  96. end;
  97. function is_override(t:tasmop):boolean;
  98. var
  99. i : longint;
  100. Begin
  101. is_override:=false;
  102. for i:=1 to AsmOverrides do
  103. if t=AsmOverride[i-1] then
  104. begin
  105. is_override:=true;
  106. exit;
  107. end;
  108. end;
  109. Function CheckPrefix(prefixop,op:tasmop): Boolean;
  110. { Checks if the prefix is valid with the following opcode }
  111. { return false if not, otherwise true }
  112. Begin
  113. CheckPrefix := TRUE;
  114. (* Case prefix of
  115. A_REP,A_REPNE,A_REPE:
  116. Case opcode Of
  117. A_SCASB,A_SCASW,A_SCASD,
  118. A_INS,A_OUTS,A_MOVS,A_CMPS,A_LODS,A_STOS:;
  119. Else
  120. Begin
  121. CheckPrefix := FALSE;
  122. exit;
  123. end;
  124. end; { case }
  125. A_LOCK:
  126. Case opcode Of
  127. A_BT,A_BTS,A_BTR,A_BTC,A_XCHG,A_ADD,A_OR,A_ADC,A_SBB,A_AND,A_SUB,
  128. A_XOR,A_NOT,A_NEG,A_INC,A_DEC:;
  129. Else
  130. Begin
  131. CheckPrefix := FALSE;
  132. Exit;
  133. end;
  134. end; { case }
  135. A_NONE: exit; { no prefix here }
  136. else
  137. CheckPrefix := FALSE;
  138. end; { end case } *)
  139. end;
  140. Function CheckOverride(overrideop,op:tasmop): Boolean;
  141. { Check if the override is valid, and if so then }
  142. { update the instr variable accordingly. }
  143. Begin
  144. CheckOverride := true;
  145. { Case instr.getinstruction of
  146. A_MOVS,A_XLAT,A_CMPS:
  147. Begin
  148. CheckOverride := TRUE;
  149. Message(assem_e_segment_override_not_supported);
  150. end
  151. end }
  152. end;
  153. Procedure FWaitWarning;
  154. begin
  155. if (target_info.system=system_i386_GO32V2) and (cs_fp_emulation in aktmoduleswitches) then
  156. Message(asmr_w_fwait_emu_prob);
  157. end;
  158. {*****************************************************************************
  159. T386Operand
  160. *****************************************************************************}
  161. Procedure T386Operand.SetCorrectSize(opcode:tasmop);
  162. begin
  163. if gas_needsuffix[opcode]=attsufFPU then
  164. begin
  165. case size of
  166. S_L : size:=S_FS;
  167. S_IQ : size:=S_FL;
  168. end;
  169. end
  170. else if gas_needsuffix[opcode]=attsufFPUint then
  171. begin
  172. case size of
  173. S_W : size:=S_IS;
  174. S_L : size:=S_IL;
  175. end;
  176. end;
  177. end;
  178. {*****************************************************************************
  179. T386Instruction
  180. *****************************************************************************}
  181. procedure T386Instruction.SwapOperands;
  182. begin
  183. Inherited SwapOperands;
  184. { mark the correct order }
  185. if OpOrder=op_intel then
  186. OpOrder:=op_att
  187. else
  188. OpOrder:=op_intel;
  189. end;
  190. procedure T386Instruction.AddReferenceSizes;
  191. { this will add the sizes for references like [esi] which do not
  192. have the size set yet, it will take only the size if the other
  193. operand is a register }
  194. var
  195. operand2,i : longint;
  196. s : tasmsymbol;
  197. so : longint;
  198. begin
  199. for i:=1to ops do
  200. begin
  201. operands[i].SetCorrectSize(opcode);
  202. if (operands[i].size=S_NO) then
  203. begin
  204. case operands[i].Opr.Typ of
  205. OPR_REFERENCE :
  206. begin
  207. if i=2 then
  208. operand2:=1
  209. else
  210. operand2:=2;
  211. if operand2<ops then
  212. begin
  213. { Only allow register as operand to take the size from }
  214. if operands[operand2].opr.typ=OPR_REGISTER then
  215. begin
  216. if ((opcode<>A_MOVD) and
  217. (opcode<>A_CVTSI2SS)) then
  218. operands[i].size:=operands[operand2].size;
  219. end
  220. else
  221. begin
  222. { if no register then take the opsize (which is available with ATT),
  223. if not availble then give an error }
  224. if opsize<>S_NO then
  225. operands[i].size:=opsize
  226. else
  227. begin
  228. Message(asmr_e_unable_to_determine_reference_size);
  229. { recovery }
  230. operands[i].size:=S_L;
  231. end;
  232. end;
  233. end
  234. else
  235. begin
  236. if opsize<>S_NO then
  237. operands[i].size:=opsize
  238. end;
  239. end;
  240. OPR_SYMBOL :
  241. begin
  242. { Fix lea which need a reference }
  243. if opcode=A_LEA then
  244. begin
  245. s:=operands[i].opr.symbol;
  246. so:=operands[i].opr.symofs;
  247. operands[i].opr.typ:=OPR_REFERENCE;
  248. Fillchar(operands[i].opr.ref,sizeof(treference),0);
  249. operands[i].opr.ref.symbol:=s;
  250. operands[i].opr.ref.offset:=so;
  251. end;
  252. operands[i].size:=S_L;
  253. end;
  254. end;
  255. end;
  256. end;
  257. end;
  258. procedure T386Instruction.SetInstructionOpsize;
  259. begin
  260. if opsize<>S_NO then
  261. exit;
  262. if (OpOrder=op_intel) then
  263. SwapOperands;
  264. case ops of
  265. 0 : ;
  266. 1 :
  267. { "push es" must be stored as a long PM }
  268. if ((opcode=A_PUSH) or
  269. (opcode=A_POP)) and
  270. (operands[1].opr.typ=OPR_REGISTER) and
  271. ((operands[1].opr.reg.enum in [firstsreg..lastsreg]) or
  272. ((operands[1].opr.reg.enum=R_INTREGISTER) and
  273. (operands[1].opr.reg.number>=nfirstsreg) and
  274. (operands[1].opr.reg.number<=nlastsreg))) then
  275. opsize:=S_L
  276. else
  277. opsize:=operands[1].size;
  278. 2 :
  279. begin
  280. case opcode of
  281. A_MOVZX,A_MOVSX :
  282. begin
  283. case operands[1].size of
  284. S_W :
  285. case operands[2].size of
  286. S_L :
  287. opsize:=S_WL;
  288. end;
  289. S_B :
  290. case operands[2].size of
  291. S_W :
  292. opsize:=S_BW;
  293. S_L :
  294. opsize:=S_BL;
  295. end;
  296. end;
  297. end;
  298. A_MOVD : { movd is a move from a mmx register to a
  299. 32 bit register or memory, so no opsize is correct here PM }
  300. exit;
  301. A_OUT :
  302. opsize:=operands[1].size;
  303. else
  304. opsize:=operands[2].size;
  305. end;
  306. end;
  307. 3 :
  308. opsize:=operands[3].size;
  309. end;
  310. end;
  311. procedure T386Instruction.CheckOperandSizes;
  312. var
  313. sizeerr : boolean;
  314. i : longint;
  315. begin
  316. { Check only the most common opcodes here, the others are done in
  317. the assembler pass }
  318. case opcode of
  319. A_PUSH,A_POP,A_DEC,A_INC,A_NOT,A_NEG,
  320. A_CMP,A_MOV,
  321. A_ADD,A_SUB,A_ADC,A_SBB,
  322. A_AND,A_OR,A_TEST,A_XOR: ;
  323. else
  324. exit;
  325. end;
  326. { Handle the BW,BL,WL separatly }
  327. sizeerr:=false;
  328. { special push/pop selector case }
  329. if ((opcode=A_PUSH) or
  330. (opcode=A_POP)) and
  331. (operands[1].opr.typ=OPR_REGISTER) then
  332. begin
  333. if (operands[1].opr.reg.enum in [firstsreg..lastsreg]) or
  334. ((operands[1].opr.reg.enum=R_INTREGISTER) and
  335. (operands[1].opr.reg.number>=nfirstsreg) and
  336. (operands[1].opr.reg.number<=nlastsreg)) then
  337. exit;
  338. end;
  339. if opsize in [S_BW,S_BL,S_WL] then
  340. begin
  341. if ops<>2 then
  342. sizeerr:=true
  343. else
  344. begin
  345. case opsize of
  346. S_BW :
  347. sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_W);
  348. S_BL :
  349. sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_L);
  350. S_WL :
  351. sizeerr:=(operands[1].size<>S_W) or (operands[2].size<>S_L);
  352. end;
  353. end;
  354. end
  355. else
  356. begin
  357. for i:=1 to ops do
  358. begin
  359. if (operands[i].opr.typ<>OPR_CONSTANT) and
  360. (operands[i].size in [S_B,S_W,S_L]) and
  361. (operands[i].size<>opsize) then
  362. sizeerr:=true;
  363. end;
  364. end;
  365. if sizeerr then
  366. begin
  367. { if range checks are on then generate an error }
  368. if (cs_compilesystem in aktmoduleswitches) or
  369. not (cs_check_range in aktlocalswitches) then
  370. Message(asmr_w_size_suffix_and_dest_dont_match)
  371. else
  372. Message(asmr_e_size_suffix_and_dest_dont_match);
  373. end;
  374. end;
  375. { This check must be done with the operand in ATT order
  376. i.e.after swapping in the intel reader
  377. but before swapping in the NASM and TASM writers PM }
  378. procedure T386Instruction.CheckNonCommutativeOpcodes;
  379. begin
  380. if (OpOrder=op_intel) then
  381. SwapOperands;
  382. if ((ops=2) and
  383. (operands[1].opr.typ=OPR_REGISTER) and
  384. (operands[2].opr.typ=OPR_REGISTER) and
  385. { if the first is ST and the second is also a register
  386. it is necessarily ST1 .. ST7 }
  387. (operands[1].opr.reg.enum in [R_ST..R_ST0])) or
  388. (ops=0) then
  389. if opcode=A_FSUBR then
  390. opcode:=A_FSUB
  391. else if opcode=A_FSUB then
  392. opcode:=A_FSUBR
  393. else if opcode=A_FDIVR then
  394. opcode:=A_FDIV
  395. else if opcode=A_FDIV then
  396. opcode:=A_FDIVR
  397. else if opcode=A_FSUBRP then
  398. opcode:=A_FSUBP
  399. else if opcode=A_FSUBP then
  400. opcode:=A_FSUBRP
  401. else if opcode=A_FDIVRP then
  402. opcode:=A_FDIVP
  403. else if opcode=A_FDIVP then
  404. opcode:=A_FDIVRP;
  405. if ((ops=1) and
  406. (operands[1].opr.typ=OPR_REGISTER) and
  407. (operands[1].opr.reg.enum in [R_ST1..R_ST7])) then
  408. if opcode=A_FSUBRP then
  409. opcode:=A_FSUBP
  410. else if opcode=A_FSUBP then
  411. opcode:=A_FSUBRP
  412. else if opcode=A_FDIVRP then
  413. opcode:=A_FDIVP
  414. else if opcode=A_FDIVP then
  415. opcode:=A_FDIVRP;
  416. end;
  417. {*****************************************************************************
  418. opcode Adding
  419. *****************************************************************************}
  420. procedure T386Instruction.ConcatInstruction(p : taasmoutput);
  421. var
  422. siz : topsize;
  423. i,asize : longint;
  424. ai : taicpu;
  425. begin
  426. if (OpOrder=op_intel) then
  427. SwapOperands;
  428. { Get Opsize }
  429. if (opsize<>S_NO) or (Ops=0) then
  430. siz:=opsize
  431. else
  432. begin
  433. if (Ops=2) and (operands[1].opr.typ=OPR_REGISTER) then
  434. siz:=operands[1].size
  435. else
  436. siz:=operands[Ops].size;
  437. { MOVD should be of size S_LQ or S_QL, but these do not exist PM }
  438. if (ops=2) and (operands[1].size<>S_NO) and
  439. (operands[2].size<>S_NO) and (operands[1].size<>operands[2].size) then
  440. siz:=S_NO;
  441. end;
  442. if ((opcode=A_MOVD)or
  443. (opcode=A_CVTSI2SS)) and
  444. ((operands[1].size=S_NO) or
  445. (operands[2].size=S_NO)) then
  446. siz:=S_NO;
  447. { NASM does not support FADD without args
  448. as alias of FADDP
  449. and GNU AS interprets FADD without operand differently
  450. for version 2.9.1 and 2.9.5 !! }
  451. if (ops=0) and
  452. ((opcode=A_FADD) or
  453. (opcode=A_FMUL) or
  454. (opcode=A_FSUB) or
  455. (opcode=A_FSUBR) or
  456. (opcode=A_FDIV) or
  457. (opcode=A_FDIVR)) then
  458. begin
  459. if opcode=A_FADD then
  460. opcode:=A_FADDP
  461. else if opcode=A_FMUL then
  462. opcode:=A_FMULP
  463. else if opcode=A_FSUB then
  464. opcode:=A_FSUBP
  465. else if opcode=A_FSUBR then
  466. opcode:=A_FSUBRP
  467. else if opcode=A_FDIV then
  468. opcode:=A_FDIVP
  469. else if opcode=A_FDIVR then
  470. opcode:=A_FDIVRP;
  471. {$ifdef ATTOP}
  472. message1(asmr_w_fadd_to_faddp,gas_op2str[opcode]);
  473. {$else}
  474. {$ifdef INTELOP}
  475. message1(asmr_w_fadd_to_faddp,std_op2str[opcode]);
  476. {$else}
  477. message1(asmr_w_fadd_to_faddp,'fXX');
  478. {$endif INTELOP}
  479. {$endif ATTOP}
  480. end;
  481. { GNU AS interprets FDIV without operand differently
  482. for version 2.9.1 and 2.10
  483. we add explicit args to it !! }
  484. if (ops=0) and
  485. ((opcode=A_FSUBP) or
  486. (opcode=A_FSUBRP) or
  487. (opcode=A_FDIVP) or
  488. (opcode=A_FDIVRP) or
  489. (opcode=A_FSUB) or
  490. (opcode=A_FSUBR) or
  491. (opcode=A_FDIV) or
  492. (opcode=A_FDIVR)) then
  493. begin
  494. {$ifdef ATTOP}
  495. message1(asmr_w_adding_explicit_args_fXX,gas_op2str[opcode]);
  496. {$else}
  497. {$ifdef INTELOP}
  498. message1(asmr_w_adding_explicit_args_fXX,std_op2str[opcode]);
  499. {$else}
  500. message1(asmr_w_adding_explicit_args_fXX,'fXX');
  501. {$endif INTELOP}
  502. {$endif ATTOP}
  503. ops:=2;
  504. operands[1].opr.typ:=OPR_REGISTER;
  505. operands[2].opr.typ:=OPR_REGISTER;
  506. operands[1].opr.reg.enum:=R_ST;
  507. operands[2].opr.reg.enum:=R_ST1;
  508. end;
  509. if (ops=1) and
  510. ((operands[1].opr.typ=OPR_REGISTER) and
  511. (operands[1].opr.reg.enum in [R_ST1..R_ST7])) and
  512. ((opcode=A_FSUBP) or
  513. (opcode=A_FSUBRP) or
  514. (opcode=A_FDIVP) or
  515. (opcode=A_FDIVRP) or
  516. (opcode=A_FADDP) or
  517. (opcode=A_FMULP)) then
  518. begin
  519. {$ifdef ATTOP}
  520. message1(asmr_w_adding_explicit_first_arg_fXX,gas_op2str[opcode]);
  521. {$else}
  522. {$ifdef INTELOP}
  523. message1(asmr_w_adding_explicit_first_arg_fXX,std_op2str[opcode]);
  524. {$else}
  525. message1(asmr_w_adding_explicit_first_arg_fXX,'fXX');
  526. {$endif INTELOP}
  527. {$endif ATTOP}
  528. ops:=2;
  529. operands[2].opr.typ:=OPR_REGISTER;
  530. operands[2].opr.reg:=operands[1].opr.reg;
  531. operands[1].opr.reg.enum:=R_ST;
  532. end;
  533. if (ops=1) and
  534. ((operands[1].opr.typ=OPR_REGISTER) and
  535. (operands[1].opr.reg.enum in [R_ST1..R_ST7])) and
  536. ((opcode=A_FSUB) or
  537. (opcode=A_FSUBR) or
  538. (opcode=A_FDIV) or
  539. (opcode=A_FDIVR) or
  540. (opcode=A_FADD) or
  541. (opcode=A_FMUL)) then
  542. begin
  543. {$ifdef ATTOP}
  544. message1(asmr_w_adding_explicit_second_arg_fXX,gas_op2str[opcode]);
  545. {$else}
  546. {$ifdef INTELOP}
  547. message1(asmr_w_adding_explicit_second_arg_fXX,std_op2str[opcode]);
  548. {$else}
  549. message1(asmr_w_adding_explicit_second_arg_fXX,'fXX');
  550. {$endif INTELOP}
  551. {$endif ATTOP}
  552. ops:=2;
  553. operands[2].opr.typ:=OPR_REGISTER;
  554. operands[2].opr.reg.enum:=R_ST;
  555. end;
  556. { I tried to convince Linus Torvalds to add
  557. code to support ENTER instruction
  558. (when raising a stack page fault)
  559. but he replied that ENTER is a bad instruction and
  560. Linux does not need to support it
  561. So I think its at least a good idea to add a warning
  562. if someone uses this in assembler code
  563. FPC itself does not use it at all PM }
  564. if (opcode=A_ENTER) and ((target_info.system=system_i386_linux) or
  565. (target_info.system=system_i386_FreeBSD)) then
  566. message(asmr_w_enter_not_supported_by_linux);
  567. ai:=taicpu.op_none(opcode,siz);
  568. ai.SetOperandOrder(OpOrder);
  569. ai.Ops:=Ops;
  570. for i:=1to Ops do
  571. begin
  572. case operands[i].opr.typ of
  573. OPR_CONSTANT :
  574. ai.loadconst(i-1,aword(operands[i].opr.val));
  575. OPR_REGISTER:
  576. ai.loadreg(i-1,operands[i].opr.reg);
  577. OPR_SYMBOL:
  578. ai.loadsymbol(i-1,operands[i].opr.symbol,operands[i].opr.symofs);
  579. OPR_REFERENCE:
  580. begin
  581. ai.loadref(i-1,operands[i].opr.ref);
  582. if operands[i].size<>S_NO then
  583. begin
  584. asize:=0;
  585. case operands[i].size of
  586. S_B :
  587. asize:=OT_BITS8;
  588. S_W, S_IS :
  589. asize:=OT_BITS16;
  590. S_L, S_IL, S_FS:
  591. asize:=OT_BITS32;
  592. S_Q, S_D, S_FL, S_FV :
  593. asize:=OT_BITS64;
  594. S_FX :
  595. asize:=OT_BITS80;
  596. end;
  597. if asize<>0 then
  598. ai.oper[i-1].ot:=(ai.oper[i-1].ot and not OT_SIZE_MASK) or asize;
  599. end;
  600. end;
  601. end;
  602. end;
  603. if (opcode=A_CALL) and (opsize=S_FAR) then
  604. opcode:=A_LCALL;
  605. if (opcode=A_JMP) and (opsize=S_FAR) then
  606. opcode:=A_LJMP;
  607. if (opcode=A_LCALL) or (opcode=A_LJMP) then
  608. opsize:=S_FAR;
  609. { Condition ? }
  610. if condition<>C_None then
  611. ai.SetCondition(condition);
  612. { Concat the opcode or give an error }
  613. if assigned(ai) then
  614. begin
  615. { Check the instruction if it's valid }
  616. {$ifndef NOAG386BIN}
  617. ai.CheckIfValid;
  618. {$endif NOAG386BIN}
  619. p.concat(ai);
  620. end
  621. else
  622. Message(asmr_e_invalid_opcode_and_operand);
  623. end;
  624. end.
  625. {
  626. $Log$
  627. Revision 1.29 2003-02-19 22:00:16 daniel
  628. * Code generator converted to new register notation
  629. - Horribily outdated todo.txt removed
  630. Revision 1.28 2003/02/03 22:47:14 daniel
  631. - Removed reg_2_opsize array
  632. Revision 1.27 2003/01/08 18:43:57 daniel
  633. * Tregister changed into a record
  634. Revision 1.26 2002/11/15 01:58:58 peter
  635. * merged changes from 1.0.7 up to 04-11
  636. - -V option for generating bug report tracing
  637. - more tracing for option parsing
  638. - errors for cdecl and high()
  639. - win32 import stabs
  640. - win32 records<=8 are returned in eax:edx (turned off by default)
  641. - heaptrc update
  642. - more info for temp management in .s file with EXTDEBUG
  643. Revision 1.25 2002/10/31 13:28:32 pierre
  644. * correct last wrong fix for tw2158
  645. Revision 1.24 2002/10/30 17:10:00 pierre
  646. * merge of fix for tw2158 bug
  647. Revision 1.23 2002/07/26 21:15:44 florian
  648. * rewrote the system handling
  649. Revision 1.22 2002/07/01 18:46:34 peter
  650. * internal linker
  651. * reorganized aasm layer
  652. Revision 1.21 2002/05/18 13:34:25 peter
  653. * readded missing revisions
  654. Revision 1.20 2002/05/16 19:46:52 carl
  655. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  656. + try to fix temp allocation (still in ifdef)
  657. + generic constructor calls
  658. + start of tassembler / tmodulebase class cleanup
  659. Revision 1.18 2002/05/12 16:53:18 peter
  660. * moved entry and exitcode to ncgutil and cgobj
  661. * foreach gets extra argument for passing local data to the
  662. iterator function
  663. * -CR checks also class typecasts at runtime by changing them
  664. into as
  665. * fixed compiler to cycle with the -CR option
  666. * fixed stabs with elf writer, finally the global variables can
  667. be watched
  668. * removed a lot of routines from cga unit and replaced them by
  669. calls to cgobj
  670. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  671. u32bit then the other is typecasted also to u32bit without giving
  672. a rangecheck warning/error.
  673. * fixed pascal calling method with reversing also the high tree in
  674. the parast, detected by tcalcst3 test
  675. Revision 1.17 2002/04/15 19:12:09 carl
  676. + target_info.size_of_pointer -> pointer_size
  677. + some cleanup of unused types/variables
  678. * move several constants from cpubase to their specific units
  679. (where they are used)
  680. + att_Reg2str -> gas_reg2str
  681. + int_reg2str -> std_reg2str
  682. Revision 1.16 2002/04/04 19:06:13 peter
  683. * removed unused units
  684. * use tlocation.size in cg.a_*loc*() routines
  685. Revision 1.15 2002/04/02 17:11:39 peter
  686. * tlocation,treference update
  687. * LOC_CONSTANT added for better constant handling
  688. * secondadd splitted in multiple routines
  689. * location_force_reg added for loading a location to a register
  690. of a specified size
  691. * secondassignment parses now first the right and then the left node
  692. (this is compatible with Kylix). This saves a lot of push/pop especially
  693. with string operations
  694. * adapted some routines to use the new cg methods
  695. Revision 1.14 2002/01/24 18:25:53 peter
  696. * implicit result variable generation for assembler routines
  697. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  698. }