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