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. if (operands[1].opr.typ=OPR_REGISTER) and
  265. (operands[1].opr.reg.enum>lastreg) then
  266. internalerror(200301081);
  267. case ops of
  268. 0 : ;
  269. 1 :
  270. { "push es" must be stored as a long PM }
  271. if ((opcode=A_PUSH) or
  272. (opcode=A_POP)) and
  273. (operands[1].opr.typ=OPR_REGISTER) and
  274. (operands[1].opr.reg.enum in [firstsreg..lastsreg]) 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. if (operands[1].opr.typ=OPR_REGISTER) and
  329. (operands[1].opr.reg.enum>lastreg) then
  330. internalerror(200301081);
  331. { special push/pop selector case }
  332. if ((opcode=A_PUSH) or
  333. (opcode=A_POP)) and
  334. (operands[1].opr.typ=OPR_REGISTER) and
  335. (operands[1].opr.reg.enum in [firstsreg..lastsreg]) then
  336. exit;
  337. if opsize in [S_BW,S_BL,S_WL] then
  338. begin
  339. if ops<>2 then
  340. sizeerr:=true
  341. else
  342. begin
  343. case opsize of
  344. S_BW :
  345. sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_W);
  346. S_BL :
  347. sizeerr:=(operands[1].size<>S_B) or (operands[2].size<>S_L);
  348. S_WL :
  349. sizeerr:=(operands[1].size<>S_W) or (operands[2].size<>S_L);
  350. end;
  351. end;
  352. end
  353. else
  354. begin
  355. for i:=1 to ops do
  356. begin
  357. if (operands[i].opr.typ<>OPR_CONSTANT) and
  358. (operands[i].size in [S_B,S_W,S_L]) and
  359. (operands[i].size<>opsize) then
  360. sizeerr:=true;
  361. end;
  362. end;
  363. if sizeerr then
  364. begin
  365. { if range checks are on then generate an error }
  366. if (cs_compilesystem in aktmoduleswitches) or
  367. not (cs_check_range in aktlocalswitches) then
  368. Message(asmr_w_size_suffix_and_dest_dont_match)
  369. else
  370. Message(asmr_e_size_suffix_and_dest_dont_match);
  371. end;
  372. end;
  373. { This check must be done with the operand in ATT order
  374. i.e.after swapping in the intel reader
  375. but before swapping in the NASM and TASM writers PM }
  376. procedure T386Instruction.CheckNonCommutativeOpcodes;
  377. begin
  378. if (OpOrder=op_intel) then
  379. SwapOperands;
  380. if (operands[1].opr.typ=OPR_REGISTER) and
  381. (operands[1].opr.reg.enum>lastreg) then
  382. internalerror(200301081);
  383. if (operands[2].opr.typ=OPR_REGISTER) and
  384. (operands[2].opr.reg.enum>lastreg) then
  385. internalerror(200301081);
  386. if ((ops=2) and
  387. (operands[1].opr.typ=OPR_REGISTER) and
  388. (operands[2].opr.typ=OPR_REGISTER) and
  389. { if the first is ST and the second is also a register
  390. it is necessarily ST1 .. ST7 }
  391. (operands[1].opr.reg.enum in [R_ST..R_ST0])) or
  392. (ops=0) then
  393. if opcode=A_FSUBR then
  394. opcode:=A_FSUB
  395. else if opcode=A_FSUB then
  396. opcode:=A_FSUBR
  397. else if opcode=A_FDIVR then
  398. opcode:=A_FDIV
  399. else if opcode=A_FDIV then
  400. opcode:=A_FDIVR
  401. else if opcode=A_FSUBRP then
  402. opcode:=A_FSUBP
  403. else if opcode=A_FSUBP then
  404. opcode:=A_FSUBRP
  405. else if opcode=A_FDIVRP then
  406. opcode:=A_FDIVP
  407. else if opcode=A_FDIVP then
  408. opcode:=A_FDIVRP;
  409. if ((ops=1) and
  410. (operands[1].opr.typ=OPR_REGISTER) and
  411. (operands[1].opr.reg.enum in [R_ST1..R_ST7])) then
  412. if opcode=A_FSUBRP then
  413. opcode:=A_FSUBP
  414. else if opcode=A_FSUBP then
  415. opcode:=A_FSUBRP
  416. else if opcode=A_FDIVRP then
  417. opcode:=A_FDIVP
  418. else if opcode=A_FDIVP then
  419. opcode:=A_FDIVRP;
  420. end;
  421. {*****************************************************************************
  422. opcode Adding
  423. *****************************************************************************}
  424. procedure T386Instruction.ConcatInstruction(p : taasmoutput);
  425. var
  426. siz : topsize;
  427. i,asize : longint;
  428. ai : taicpu;
  429. begin
  430. if (OpOrder=op_intel) then
  431. SwapOperands;
  432. { Get Opsize }
  433. if (opsize<>S_NO) or (Ops=0) then
  434. siz:=opsize
  435. else
  436. begin
  437. if (Ops=2) and (operands[1].opr.typ=OPR_REGISTER) then
  438. siz:=operands[1].size
  439. else
  440. siz:=operands[Ops].size;
  441. { MOVD should be of size S_LQ or S_QL, but these do not exist PM }
  442. if (ops=2) and (operands[1].size<>S_NO) and
  443. (operands[2].size<>S_NO) and (operands[1].size<>operands[2].size) then
  444. siz:=S_NO;
  445. end;
  446. if ((opcode=A_MOVD)or
  447. (opcode=A_CVTSI2SS)) and
  448. ((operands[1].size=S_NO) or
  449. (operands[2].size=S_NO)) then
  450. siz:=S_NO;
  451. { NASM does not support FADD without args
  452. as alias of FADDP
  453. and GNU AS interprets FADD without operand differently
  454. for version 2.9.1 and 2.9.5 !! }
  455. if (ops=0) and
  456. ((opcode=A_FADD) or
  457. (opcode=A_FMUL) or
  458. (opcode=A_FSUB) or
  459. (opcode=A_FSUBR) or
  460. (opcode=A_FDIV) or
  461. (opcode=A_FDIVR)) then
  462. begin
  463. if opcode=A_FADD then
  464. opcode:=A_FADDP
  465. else if opcode=A_FMUL then
  466. opcode:=A_FMULP
  467. else if opcode=A_FSUB then
  468. opcode:=A_FSUBP
  469. else if opcode=A_FSUBR then
  470. opcode:=A_FSUBRP
  471. else if opcode=A_FDIV then
  472. opcode:=A_FDIVP
  473. else if opcode=A_FDIVR then
  474. opcode:=A_FDIVRP;
  475. {$ifdef ATTOP}
  476. message1(asmr_w_fadd_to_faddp,gas_op2str[opcode]);
  477. {$else}
  478. {$ifdef INTELOP}
  479. message1(asmr_w_fadd_to_faddp,std_op2str[opcode]);
  480. {$else}
  481. message1(asmr_w_fadd_to_faddp,'fXX');
  482. {$endif INTELOP}
  483. {$endif ATTOP}
  484. end;
  485. { GNU AS interprets FDIV without operand differently
  486. for version 2.9.1 and 2.10
  487. we add explicit args to it !! }
  488. if (ops=0) and
  489. ((opcode=A_FSUBP) or
  490. (opcode=A_FSUBRP) or
  491. (opcode=A_FDIVP) or
  492. (opcode=A_FDIVRP) or
  493. (opcode=A_FSUB) or
  494. (opcode=A_FSUBR) or
  495. (opcode=A_FDIV) or
  496. (opcode=A_FDIVR)) then
  497. begin
  498. {$ifdef ATTOP}
  499. message1(asmr_w_adding_explicit_args_fXX,gas_op2str[opcode]);
  500. {$else}
  501. {$ifdef INTELOP}
  502. message1(asmr_w_adding_explicit_args_fXX,std_op2str[opcode]);
  503. {$else}
  504. message1(asmr_w_adding_explicit_args_fXX,'fXX');
  505. {$endif INTELOP}
  506. {$endif ATTOP}
  507. ops:=2;
  508. operands[1].opr.typ:=OPR_REGISTER;
  509. operands[2].opr.typ:=OPR_REGISTER;
  510. operands[1].opr.reg.enum:=R_ST;
  511. operands[2].opr.reg.enum:=R_ST1;
  512. end;
  513. if (ops=1) and
  514. ((operands[1].opr.typ=OPR_REGISTER) and
  515. (operands[1].opr.reg.enum in [R_ST1..R_ST7])) and
  516. ((opcode=A_FSUBP) or
  517. (opcode=A_FSUBRP) or
  518. (opcode=A_FDIVP) or
  519. (opcode=A_FDIVRP) or
  520. (opcode=A_FADDP) or
  521. (opcode=A_FMULP)) then
  522. begin
  523. {$ifdef ATTOP}
  524. message1(asmr_w_adding_explicit_first_arg_fXX,gas_op2str[opcode]);
  525. {$else}
  526. {$ifdef INTELOP}
  527. message1(asmr_w_adding_explicit_first_arg_fXX,std_op2str[opcode]);
  528. {$else}
  529. message1(asmr_w_adding_explicit_first_arg_fXX,'fXX');
  530. {$endif INTELOP}
  531. {$endif ATTOP}
  532. ops:=2;
  533. operands[2].opr.typ:=OPR_REGISTER;
  534. operands[2].opr.reg:=operands[1].opr.reg;
  535. operands[1].opr.reg.enum:=R_ST;
  536. end;
  537. if (ops=1) and
  538. ((operands[1].opr.typ=OPR_REGISTER) and
  539. (operands[1].opr.reg.enum in [R_ST1..R_ST7])) and
  540. ((opcode=A_FSUB) or
  541. (opcode=A_FSUBR) or
  542. (opcode=A_FDIV) or
  543. (opcode=A_FDIVR) or
  544. (opcode=A_FADD) or
  545. (opcode=A_FMUL)) then
  546. begin
  547. {$ifdef ATTOP}
  548. message1(asmr_w_adding_explicit_second_arg_fXX,gas_op2str[opcode]);
  549. {$else}
  550. {$ifdef INTELOP}
  551. message1(asmr_w_adding_explicit_second_arg_fXX,std_op2str[opcode]);
  552. {$else}
  553. message1(asmr_w_adding_explicit_second_arg_fXX,'fXX');
  554. {$endif INTELOP}
  555. {$endif ATTOP}
  556. ops:=2;
  557. operands[2].opr.typ:=OPR_REGISTER;
  558. operands[2].opr.reg.enum:=R_ST;
  559. end;
  560. { I tried to convince Linus Torvalds to add
  561. code to support ENTER instruction
  562. (when raising a stack page fault)
  563. but he replied that ENTER is a bad instruction and
  564. Linux does not need to support it
  565. So I think its at least a good idea to add a warning
  566. if someone uses this in assembler code
  567. FPC itself does not use it at all PM }
  568. if (opcode=A_ENTER) and ((target_info.system=system_i386_linux) or
  569. (target_info.system=system_i386_FreeBSD)) then
  570. message(asmr_w_enter_not_supported_by_linux);
  571. ai:=taicpu.op_none(opcode,siz);
  572. ai.SetOperandOrder(OpOrder);
  573. ai.Ops:=Ops;
  574. for i:=1to Ops do
  575. begin
  576. case operands[i].opr.typ of
  577. OPR_CONSTANT :
  578. ai.loadconst(i-1,aword(operands[i].opr.val));
  579. OPR_REGISTER:
  580. ai.loadreg(i-1,operands[i].opr.reg);
  581. OPR_SYMBOL:
  582. ai.loadsymbol(i-1,operands[i].opr.symbol,operands[i].opr.symofs);
  583. OPR_REFERENCE:
  584. begin
  585. ai.loadref(i-1,operands[i].opr.ref);
  586. if operands[i].size<>S_NO then
  587. begin
  588. asize:=0;
  589. case operands[i].size of
  590. S_B :
  591. asize:=OT_BITS8;
  592. S_W, S_IS :
  593. asize:=OT_BITS16;
  594. S_L, S_IL, S_FS:
  595. asize:=OT_BITS32;
  596. S_Q, S_D, S_FL, S_FV :
  597. asize:=OT_BITS64;
  598. S_FX :
  599. asize:=OT_BITS80;
  600. end;
  601. if asize<>0 then
  602. ai.oper[i-1].ot:=(ai.oper[i-1].ot and not OT_SIZE_MASK) or asize;
  603. end;
  604. end;
  605. end;
  606. end;
  607. if (opcode=A_CALL) and (opsize=S_FAR) then
  608. opcode:=A_LCALL;
  609. if (opcode=A_JMP) and (opsize=S_FAR) then
  610. opcode:=A_LJMP;
  611. if (opcode=A_LCALL) or (opcode=A_LJMP) then
  612. opsize:=S_FAR;
  613. { Condition ? }
  614. if condition<>C_None then
  615. ai.SetCondition(condition);
  616. { Concat the opcode or give an error }
  617. if assigned(ai) then
  618. begin
  619. { Check the instruction if it's valid }
  620. {$ifndef NOAG386BIN}
  621. ai.CheckIfValid;
  622. {$endif NOAG386BIN}
  623. p.concat(ai);
  624. end
  625. else
  626. Message(asmr_e_invalid_opcode_and_operand);
  627. end;
  628. end.
  629. {
  630. $Log$
  631. Revision 1.28 2003-02-03 22:47:14 daniel
  632. - Removed reg_2_opsize array
  633. Revision 1.27 2003/01/08 18:43:57 daniel
  634. * Tregister changed into a record
  635. Revision 1.26 2002/11/15 01:58:58 peter
  636. * merged changes from 1.0.7 up to 04-11
  637. - -V option for generating bug report tracing
  638. - more tracing for option parsing
  639. - errors for cdecl and high()
  640. - win32 import stabs
  641. - win32 records<=8 are returned in eax:edx (turned off by default)
  642. - heaptrc update
  643. - more info for temp management in .s file with EXTDEBUG
  644. Revision 1.25 2002/10/31 13:28:32 pierre
  645. * correct last wrong fix for tw2158
  646. Revision 1.24 2002/10/30 17:10:00 pierre
  647. * merge of fix for tw2158 bug
  648. Revision 1.23 2002/07/26 21:15:44 florian
  649. * rewrote the system handling
  650. Revision 1.22 2002/07/01 18:46:34 peter
  651. * internal linker
  652. * reorganized aasm layer
  653. Revision 1.21 2002/05/18 13:34:25 peter
  654. * readded missing revisions
  655. Revision 1.20 2002/05/16 19:46:52 carl
  656. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  657. + try to fix temp allocation (still in ifdef)
  658. + generic constructor calls
  659. + start of tassembler / tmodulebase class cleanup
  660. Revision 1.18 2002/05/12 16:53:18 peter
  661. * moved entry and exitcode to ncgutil and cgobj
  662. * foreach gets extra argument for passing local data to the
  663. iterator function
  664. * -CR checks also class typecasts at runtime by changing them
  665. into as
  666. * fixed compiler to cycle with the -CR option
  667. * fixed stabs with elf writer, finally the global variables can
  668. be watched
  669. * removed a lot of routines from cga unit and replaced them by
  670. calls to cgobj
  671. * u32bit-s32bit updates for and,or,xor nodes. When one element is
  672. u32bit then the other is typecasted also to u32bit without giving
  673. a rangecheck warning/error.
  674. * fixed pascal calling method with reversing also the high tree in
  675. the parast, detected by tcalcst3 test
  676. Revision 1.17 2002/04/15 19:12:09 carl
  677. + target_info.size_of_pointer -> pointer_size
  678. + some cleanup of unused types/variables
  679. * move several constants from cpubase to their specific units
  680. (where they are used)
  681. + att_Reg2str -> gas_reg2str
  682. + int_reg2str -> std_reg2str
  683. Revision 1.16 2002/04/04 19:06:13 peter
  684. * removed unused units
  685. * use tlocation.size in cg.a_*loc*() routines
  686. Revision 1.15 2002/04/02 17:11:39 peter
  687. * tlocation,treference update
  688. * LOC_CONSTANT added for better constant handling
  689. * secondadd splitted in multiple routines
  690. * location_force_reg added for loading a location to a register
  691. of a specified size
  692. * secondassignment parses now first the right and then the left node
  693. (this is compatible with Kylix). This saves a lot of push/pop especially
  694. with string operations
  695. * adapted some routines to use the new cg methods
  696. Revision 1.14 2002/01/24 18:25:53 peter
  697. * implicit result variable generation for assembler routines
  698. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  699. }