cpubase.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl and Peter Vreman
  3. Contains the base types for the i8086, i386 and x86-64 architecture
  4. * This code was inspired by the NASM sources
  5. The Netwide Assembler is Copyright (c) 1996 Simon Tatham and
  6. Julian Hall. All rights reserved.
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. ****************************************************************************
  19. }
  20. {# Base unit for processor information. This unit contains
  21. enumerations of registers, opcodes, sizes, and other
  22. such things which are processor specific.
  23. }
  24. unit cpubase;
  25. {$i fpcdefs.inc}
  26. interface
  27. uses
  28. cutils,cclasses,
  29. globtype,globals,
  30. cgbase
  31. ;
  32. {*****************************************************************************
  33. Assembler Opcodes
  34. *****************************************************************************}
  35. type
  36. {$if defined(x86_64)}
  37. TAsmOp={$i x8664op.inc}
  38. {$elseif defined(i386)}
  39. TAsmOp={$i i386op.inc}
  40. {$elseif defined(i8086)}
  41. TAsmOp={$i i8086op.inc}
  42. {$endif}
  43. { This should define the array of instructions as string }
  44. op2strtable=array[tasmop] of string[16];
  45. {$ifdef i8086}
  46. ImmInt = SmallInt;
  47. {$else i8086}
  48. ImmInt = Longint;
  49. {$endif i8086}
  50. const
  51. { First value of opcode enumeration }
  52. firstop = low(tasmop);
  53. { Last value of opcode enumeration }
  54. lastop = high(tasmop);
  55. {*****************************************************************************
  56. Registers
  57. *****************************************************************************}
  58. const
  59. { Integer Super registers }
  60. RS_NO = $ffffffff;
  61. RS_RAX = $00; {EAX}
  62. RS_RCX = $01; {ECX}
  63. RS_RDX = $02; {EDX}
  64. RS_RBX = $03; {EBX}
  65. RS_RSI = $04; {ESI}
  66. RS_RDI = $05; {EDI}
  67. RS_RBP = $06; {EBP}
  68. RS_RSP = $07; {ESP}
  69. RS_R8 = $08; {R8}
  70. RS_R9 = $09; {R9}
  71. RS_R10 = $0a; {R10}
  72. RS_R11 = $0b; {R11}
  73. RS_R12 = $0c; {R12}
  74. RS_R13 = $0d; {R13}
  75. RS_R14 = $0e; {R14}
  76. RS_R15 = $0f; {R15}
  77. { create aliases to allow code sharing between x86-64 and i386 }
  78. RS_EAX = RS_RAX;
  79. RS_EBX = RS_RBX;
  80. RS_ECX = RS_RCX;
  81. RS_EDX = RS_RDX;
  82. RS_ESI = RS_RSI;
  83. RS_EDI = RS_RDI;
  84. RS_EBP = RS_RBP;
  85. RS_ESP = RS_RSP;
  86. { create aliases to allow code sharing between i386 and i8086 }
  87. RS_AX = RS_RAX;
  88. RS_BX = RS_RBX;
  89. RS_CX = RS_RCX;
  90. RS_DX = RS_RDX;
  91. RS_SI = RS_RSI;
  92. RS_DI = RS_RDI;
  93. RS_BP = RS_RBP;
  94. RS_SP = RS_RSP;
  95. { Number of first imaginary register }
  96. first_int_imreg = $10;
  97. { Float Super registers }
  98. RS_ST0 = $00;
  99. RS_ST1 = $01;
  100. RS_ST2 = $02;
  101. RS_ST3 = $03;
  102. RS_ST4 = $04;
  103. RS_ST5 = $05;
  104. RS_ST6 = $06;
  105. RS_ST7 = $07;
  106. RS_ST = $08;
  107. { Number of first imaginary register }
  108. first_fpu_imreg = $09;
  109. { MM Super registers }
  110. RS_XMM0 = $00;
  111. RS_XMM1 = $01;
  112. RS_XMM2 = $02;
  113. RS_XMM3 = $03;
  114. RS_XMM4 = $04;
  115. RS_XMM5 = $05;
  116. RS_XMM6 = $06;
  117. RS_XMM7 = $07;
  118. RS_XMM8 = $08;
  119. RS_XMM9 = $09;
  120. RS_XMM10 = $0a;
  121. RS_XMM11 = $0b;
  122. RS_XMM12 = $0c;
  123. RS_XMM13 = $0d;
  124. RS_XMM14 = $0e;
  125. RS_XMM15 = $0f;
  126. {$if defined(x86_64)}
  127. RS_RFLAGS = $06;
  128. {$elseif defined(i386)}
  129. RS_EFLAGS = $06;
  130. {$elseif defined(i8086)}
  131. RS_FLAGS = $06;
  132. {$endif}
  133. { Number of first imaginary register }
  134. {$ifdef x86_64}
  135. first_mm_imreg = $10;
  136. {$else x86_64}
  137. first_mm_imreg = $08;
  138. {$endif x86_64}
  139. { The subregister that specifies the entire register and an address }
  140. {$if defined(x86_64)}
  141. { Hammer }
  142. R_SUBWHOLE = R_SUBQ;
  143. R_SUBADDR = R_SUBQ;
  144. {$elseif defined(i386)}
  145. { i386 }
  146. R_SUBWHOLE = R_SUBD;
  147. R_SUBADDR = R_SUBD;
  148. {$elseif defined(i8086)}
  149. { i8086 }
  150. R_SUBWHOLE = R_SUBW;
  151. R_SUBADDR = R_SUBW;
  152. {$endif}
  153. { Available Registers }
  154. {$if defined(x86_64)}
  155. {$i r8664con.inc}
  156. {$elseif defined(i386)}
  157. {$i r386con.inc}
  158. {$elseif defined(i8086)}
  159. {$i r8086con.inc}
  160. {$endif}
  161. type
  162. { Number of registers used for indexing in tables }
  163. {$if defined(x86_64)}
  164. tregisterindex=0..{$i r8664nor.inc}-1;
  165. {$elseif defined(i386)}
  166. tregisterindex=0..{$i r386nor.inc}-1;
  167. {$elseif defined(i8086)}
  168. tregisterindex=0..{$i r8086nor.inc}-1;
  169. {$endif}
  170. const
  171. regnumber_table : array[tregisterindex] of tregister = (
  172. {$if defined(x86_64)}
  173. {$i r8664num.inc}
  174. {$elseif defined(i386)}
  175. {$i r386num.inc}
  176. {$elseif defined(i8086)}
  177. {$i r8086num.inc}
  178. {$endif}
  179. );
  180. regstabs_table : array[tregisterindex] of shortint = (
  181. {$if defined(x86_64)}
  182. {$i r8664stab.inc}
  183. {$elseif defined(i386)}
  184. {$i r386stab.inc}
  185. {$elseif defined(i8086)}
  186. {$i r8086stab.inc}
  187. {$endif}
  188. );
  189. regdwarf_table : array[tregisterindex] of shortint = (
  190. {$if defined(x86_64)}
  191. {$i r8664dwrf.inc}
  192. {$elseif defined(i386)}
  193. {$i r386dwrf.inc}
  194. {$elseif defined(i8086)}
  195. {$i r8086dwrf.inc}
  196. {$endif}
  197. );
  198. {$if defined(x86_64)}
  199. RS_DEFAULTFLAGS = RS_RFLAGS;
  200. NR_DEFAULTFLAGS = NR_RFLAGS;
  201. {$elseif defined(i386)}
  202. RS_DEFAULTFLAGS = RS_EFLAGS;
  203. NR_DEFAULTFLAGS = NR_EFLAGS;
  204. {$elseif defined(i8086)}
  205. RS_DEFAULTFLAGS = RS_FLAGS;
  206. NR_DEFAULTFLAGS = NR_FLAGS;
  207. {$endif}
  208. type
  209. totherregisterset = set of tregisterindex;
  210. {*****************************************************************************
  211. Conditions
  212. *****************************************************************************}
  213. type
  214. TAsmCond=(C_None,
  215. C_A,C_AE,C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_NA,C_NAE,
  216. C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_NO,C_NP,
  217. C_NS,C_NZ,C_O,C_P,C_PE,C_PO,C_S,C_Z
  218. );
  219. const
  220. cond2str:array[TAsmCond] of string[3]=('',
  221. 'a','ae','b','be','c','e','g','ge','l','le','na','nae',
  222. 'nb','nbe','nc','ne','ng','nge','nl','nle','no','np',
  223. 'ns','nz','o','p','pe','po','s','z'
  224. );
  225. {*****************************************************************************
  226. Flags
  227. *****************************************************************************}
  228. type
  229. TResFlags = (F_E,F_NE,F_G,F_L,F_GE,F_LE,F_C,F_NC,
  230. F_A,F_AE,F_B,F_BE,
  231. F_S,F_NS,F_O,F_NO,
  232. { For IEEE-compliant floating-point compares,
  233. same as normal counterparts but additionally check PF }
  234. F_FE,F_FNE,F_FA,F_FAE,F_FB,F_FBE);
  235. const
  236. FPUFlags = [F_FE,F_FNE,F_FA,F_FAE,F_FB,F_FBE];
  237. FPUFlags2Flags: array[F_FE..F_FBE] of TResFlags = (
  238. F_E,F_NE,F_A,F_AE,F_B,F_BE
  239. );
  240. {*****************************************************************************
  241. Constants
  242. *****************************************************************************}
  243. const
  244. { declare aliases }
  245. LOC_SSEREGISTER = LOC_MMREGISTER;
  246. LOC_CSSEREGISTER = LOC_CMMREGISTER;
  247. max_operands = 4;
  248. maxfpuregs = 8;
  249. {*****************************************************************************
  250. CPU Dependent Constants
  251. *****************************************************************************}
  252. {$i cpubase.inc}
  253. {*****************************************************************************
  254. Helpers
  255. *****************************************************************************}
  256. function cgsize2subreg(regtype: tregistertype; s:Tcgsize):Tsubregister;
  257. function reg2opsize(r:Tregister):topsize;
  258. function reg_cgsize(const reg: tregister): tcgsize;
  259. function is_calljmp(o:tasmop):boolean;
  260. procedure inverse_flags(var f: TResFlags);
  261. function flags_to_cond(const f: TResFlags) : TAsmCond;
  262. function is_segment_reg(r:tregister):boolean;
  263. function findreg_by_number(r:Tregister):tregisterindex;
  264. function std_regnum_search(const s:string):Tregister;
  265. function std_regname(r:Tregister):string;
  266. function dwarf_reg(r:tregister):shortint;
  267. function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  268. function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  269. { checks whether two segment registers are normally equal in the current memory model }
  270. function segment_regs_equal(r1,r2:tregister):boolean;
  271. {$ifdef i8086}
  272. { returns the next virtual register }
  273. function GetNextReg(const r : TRegister) : TRegister;
  274. { return whether we need to add an extra FWAIT instruction before the given
  275. instruction, when we're targeting the i8087. This includes almost all x87
  276. instructions, but certain ones, which always have or have not a built in
  277. FWAIT prefix are excluded (e.g. FINIT,FNINIT,etc.). }
  278. function requires_fwait_on_8087(op: TAsmOp): boolean;
  279. {$endif i8086}
  280. implementation
  281. uses
  282. rgbase,verbose;
  283. const
  284. {$if defined(x86_64)}
  285. std_regname_table : TRegNameTable = (
  286. {$i r8664std.inc}
  287. );
  288. regnumber_index : array[tregisterindex] of tregisterindex = (
  289. {$i r8664rni.inc}
  290. );
  291. std_regname_index : array[tregisterindex] of tregisterindex = (
  292. {$i r8664sri.inc}
  293. );
  294. {$elseif defined(i386)}
  295. std_regname_table : TRegNameTable = (
  296. {$i r386std.inc}
  297. );
  298. regnumber_index : array[tregisterindex] of tregisterindex = (
  299. {$i r386rni.inc}
  300. );
  301. std_regname_index : array[tregisterindex] of tregisterindex = (
  302. {$i r386sri.inc}
  303. );
  304. {$elseif defined(i8086)}
  305. std_regname_table : TRegNameTable = (
  306. {$i r8086std.inc}
  307. );
  308. regnumber_index : array[tregisterindex] of tregisterindex = (
  309. {$i r8086rni.inc}
  310. );
  311. std_regname_index : array[tregisterindex] of tregisterindex = (
  312. {$i r8086sri.inc}
  313. );
  314. {$endif}
  315. {*****************************************************************************
  316. Helpers
  317. *****************************************************************************}
  318. function cgsize2subreg(regtype: tregistertype; s:Tcgsize):Tsubregister;
  319. begin
  320. case s of
  321. OS_8,OS_S8:
  322. cgsize2subreg:=R_SUBL;
  323. OS_16,OS_S16:
  324. cgsize2subreg:=R_SUBW;
  325. OS_32,OS_S32:
  326. cgsize2subreg:=R_SUBD;
  327. OS_64,OS_S64:
  328. cgsize2subreg:=R_SUBQ;
  329. OS_M64:
  330. cgsize2subreg:=R_SUBNONE;
  331. OS_F32,OS_F64,OS_C64:
  332. case regtype of
  333. R_FPUREGISTER:
  334. cgsize2subreg:=R_SUBWHOLE;
  335. R_MMREGISTER:
  336. case s of
  337. OS_F32:
  338. cgsize2subreg:=R_SUBMMS;
  339. OS_F64:
  340. cgsize2subreg:=R_SUBMMD;
  341. else
  342. internalerror(2009071901);
  343. end;
  344. else
  345. internalerror(2009071902);
  346. end;
  347. OS_M128,OS_MS128:
  348. cgsize2subreg:=R_SUBMMX;
  349. OS_M256,OS_MS256:
  350. cgsize2subreg:=R_SUBMMY;
  351. OS_NO:
  352. { error message should have been thrown already before, so avoid only
  353. an internal error }
  354. cgsize2subreg:=R_SUBNONE;
  355. else
  356. internalerror(200301231);
  357. end;
  358. end;
  359. function reg_cgsize(const reg: tregister): tcgsize;
  360. const subreg2cgsize:array[Tsubregister] of Tcgsize =
  361. (OS_NO,OS_8,OS_8,OS_16,OS_32,OS_64,OS_NO,OS_NO,OS_NO,OS_F32,OS_F64,OS_NO,OS_M128,OS_M256,OS_NO,OS_NO,OS_NO,OS_NO,OS_NO,OS_NO,OS_NO,OS_NO);
  362. begin
  363. case getregtype(reg) of
  364. R_INTREGISTER :
  365. reg_cgsize:=subreg2cgsize[getsubreg(reg)];
  366. R_FPUREGISTER :
  367. reg_cgsize:=OS_F80;
  368. R_MMXREGISTER:
  369. reg_cgsize:=OS_M64;
  370. R_MMREGISTER:
  371. reg_cgsize:=subreg2cgsize[getsubreg(reg)];
  372. R_SPECIALREGISTER :
  373. case reg of
  374. NR_CS,NR_DS,NR_ES,NR_SS,NR_FS,NR_GS:
  375. reg_cgsize:=OS_16;
  376. {$ifdef x86_64}
  377. NR_DR0..NR_TR7:
  378. reg_cgsize:=OS_64;
  379. {$endif x86_64}
  380. else
  381. reg_cgsize:=OS_32
  382. end
  383. else
  384. internalerror(2003031801);
  385. end;
  386. end;
  387. function reg2opsize(r:Tregister):topsize;
  388. const
  389. subreg2opsize : array[tsubregister] of topsize =
  390. (S_NO,S_B,S_B,S_W,S_L,S_Q,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
  391. begin
  392. reg2opsize:=S_L;
  393. case getregtype(r) of
  394. R_INTREGISTER :
  395. reg2opsize:=subreg2opsize[getsubreg(r)];
  396. R_FPUREGISTER :
  397. reg2opsize:=S_FL;
  398. R_MMXREGISTER,
  399. R_MMREGISTER :
  400. reg2opsize:=S_MD;
  401. R_SPECIALREGISTER :
  402. begin
  403. case r of
  404. NR_CS,NR_DS,NR_ES,
  405. NR_SS,NR_FS,NR_GS :
  406. reg2opsize:=S_W;
  407. end;
  408. end;
  409. else
  410. internalerror(200303181);
  411. end;
  412. end;
  413. function is_calljmp(o:tasmop):boolean;
  414. begin
  415. case o of
  416. A_CALL,
  417. {$if defined(i386) or defined(i8086)}
  418. A_JCXZ,
  419. {$endif defined(i386) or defined(i8086)}
  420. A_JECXZ,
  421. {$ifdef x86_64}
  422. A_JRCXZ,
  423. {$endif x86_64}
  424. A_JMP,
  425. A_LOOP,
  426. A_LOOPE,
  427. A_LOOPNE,
  428. A_LOOPNZ,
  429. A_LOOPZ,
  430. A_LCALL,
  431. A_LJMP,
  432. A_Jcc :
  433. is_calljmp:=true;
  434. else
  435. is_calljmp:=false;
  436. end;
  437. end;
  438. procedure inverse_flags(var f: TResFlags);
  439. const
  440. inv_flags: array[TResFlags] of TResFlags =
  441. (F_NE,F_E,F_LE,F_GE,F_L,F_G,F_NC,F_C,
  442. F_BE,F_B,F_AE,F_A,
  443. F_NS,F_S,F_NO,F_O,
  444. F_FNE,F_FE,F_FBE,F_FB,F_FAE,F_FA);
  445. begin
  446. f:=inv_flags[f];
  447. end;
  448. function flags_to_cond(const f: TResFlags) : TAsmCond;
  449. const
  450. flags_2_cond : array[TResFlags] of TAsmCond =
  451. (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE,C_S,C_NS,C_O,C_NO,
  452. C_None,C_None,C_None,C_None,C_None,C_None);
  453. begin
  454. result := flags_2_cond[f];
  455. if (result=C_None) then
  456. InternalError(2014041301);
  457. end;
  458. function is_segment_reg(r:tregister):boolean;
  459. begin
  460. result:=false;
  461. case r of
  462. NR_CS,NR_DS,NR_ES,
  463. NR_SS,NR_FS,NR_GS :
  464. result:=true;
  465. end;
  466. end;
  467. function findreg_by_number(r:Tregister):tregisterindex;
  468. var
  469. hr : tregister;
  470. begin
  471. { for the name the sub reg doesn't matter }
  472. hr:=r;
  473. if (getregtype(hr)=R_MMREGISTER) and
  474. (getsubreg(hr)<>R_SUBMMY) then
  475. setsubreg(hr,R_SUBMMX);
  476. result:=findreg_by_number_table(hr,regnumber_index);
  477. end;
  478. function std_regnum_search(const s:string):Tregister;
  479. begin
  480. result:=regnumber_table[findreg_by_name_table(s,std_regname_table,std_regname_index)];
  481. end;
  482. function std_regname(r:Tregister):string;
  483. var
  484. p : tregisterindex;
  485. begin
  486. if (getregtype(r)=R_MMXREGISTER) or
  487. ((getregtype(r)=R_MMREGISTER) and not(getsubreg(r) in [R_SUBMMX,R_SUBMMY])) then
  488. r:=newreg(getregtype(r),getsupreg(r),R_SUBNONE);
  489. p:=findreg_by_number(r);
  490. if p<>0 then
  491. result:=std_regname_table[p]
  492. else
  493. result:=generic_regname(r);
  494. end;
  495. function inverse_cond(const c: TAsmCond): TAsmCond; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  496. const
  497. inverse: array[TAsmCond] of TAsmCond=(C_None,
  498. C_NA,C_NAE,C_NB,C_NBE,C_NC,C_NE,C_NG,C_NGE,C_NL,C_NLE,C_A,C_AE,
  499. C_B,C_BE,C_C,C_E,C_G,C_GE,C_L,C_LE,C_O,C_P,
  500. C_S,C_Z,C_NO,C_NP,C_NP,C_P,C_NS,C_NZ
  501. );
  502. begin
  503. result := inverse[c];
  504. end;
  505. function conditions_equal(const c1, c2: TAsmCond): boolean; {$ifdef USEINLINE}inline;{$endif USEINLINE}
  506. begin
  507. result := c1 = c2;
  508. end;
  509. function dwarf_reg(r:tregister):shortint;
  510. begin
  511. result:=regdwarf_table[findreg_by_number(r)];
  512. if result=-1 then
  513. internalerror(200603251);
  514. end;
  515. function segment_regs_equal(r1, r2: tregister): boolean;
  516. begin
  517. if not is_segment_reg(r1) or not is_segment_reg(r2) then
  518. internalerror(2013062301);
  519. { every segment register is equal to itself }
  520. if r1=r2 then
  521. exit(true);
  522. {$if defined(i8086)}
  523. case current_settings.x86memorymodel of
  524. mm_tiny:
  525. begin
  526. { CS=DS=SS }
  527. if ((r1=NR_CS) or (r1=NR_DS) or (r1=NR_SS)) and
  528. ((r2=NR_CS) or (r2=NR_DS) or (r2=NR_SS)) then
  529. exit(true);
  530. { the remaining are distinct from each other }
  531. exit(false);
  532. end;
  533. mm_small,mm_medium:
  534. begin
  535. { DS=SS }
  536. if ((r1=NR_DS) or (r1=NR_SS)) and
  537. ((r2=NR_DS) or (r2=NR_SS)) then
  538. exit(true);
  539. { the remaining are distinct from each other }
  540. exit(false);
  541. end;
  542. mm_compact,mm_large,mm_huge:
  543. { all segment registers are different in these models }
  544. exit(false);
  545. else
  546. internalerror(2013062302);
  547. end;
  548. {$elseif defined(i386) or defined(x86_64)}
  549. { DS=SS=ES }
  550. if ((r1=NR_DS) or (r1=NR_SS) or (r1=NR_ES)) and
  551. ((r2=NR_DS) or (r2=NR_SS) or (r2=NR_ES)) then
  552. exit(true);
  553. { the remaining are distinct from each other }
  554. exit(false);
  555. {$endif}
  556. end;
  557. {$ifdef i8086}
  558. function GetNextReg(const r: TRegister): TRegister;
  559. begin
  560. if getsupreg(r)<first_int_imreg then
  561. internalerror(2013051401);
  562. result:=TRegister(longint(r)+1);
  563. end;
  564. function requires_fwait_on_8087(op: TAsmOp): boolean;
  565. begin
  566. case op of
  567. A_F2XM1,A_FABS,A_FADD,A_FADDP,A_FBLD,A_FBSTP,A_FCHS,A_FCOM,A_FCOMP,
  568. A_FCOMPP,A_FDECSTP,A_FDIV,A_FDIVP,A_FDIVR,A_FDIVRP,
  569. A_FFREE,A_FIADD,A_FICOM,A_FICOMP,A_FIDIV,A_FIDIVR,A_FILD,
  570. A_FIMUL,A_FINCSTP,A_FIST,A_FISTP,A_FISUB,A_FISUBR,A_FLD,A_FLD1,
  571. A_FLDCW,A_FLDENV,A_FLDL2E,A_FLDL2T,A_FLDLG2,A_FLDLN2,A_FLDPI,A_FLDZ,
  572. A_FMUL,A_FMULP,A_FNOP,A_FPATAN,A_FPREM,A_FPTAN,A_FRNDINT,
  573. A_FRSTOR,A_FSCALE,A_FSQRT,A_FST,
  574. A_FSTP,A_FSUB,A_FSUBP,A_FSUBR,A_FSUBRP,A_FTST,
  575. A_FXAM,A_FXCH,A_FXTRACT,A_FYL2X,A_FYL2XP1:
  576. result:=true;
  577. else
  578. result:=false;
  579. end;
  580. end;
  581. {$endif i8086}
  582. end.