aasmcpu.pas 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl and Peter Vreman
  4. Contains the abstract assembler implementation for the i386
  5. * Portions of this code was inspired by the NASM sources
  6. The Netwide Assembler is Copyright (c) 1996 Simon Tatham and
  7. Julian Hall. All rights reserved.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ****************************************************************************
  20. }
  21. unit aasmcpu;
  22. {$i fpcdefs.inc}
  23. interface
  24. uses
  25. cclasses,globals,verbose,
  26. cpuinfo,cpubase,
  27. symppu,
  28. aasmbase,aasmtai;
  29. const
  30. { Operand types }
  31. OT_NONE = $00000000;
  32. OT_BITS8 = $00000001; { size, and other attributes, of the operand }
  33. OT_BITS16 = $00000002;
  34. OT_BITS32 = $00000004;
  35. OT_BITS64 = $00000008; { FPU only }
  36. OT_BITS80 = $00000010;
  37. OT_FAR = $00000020; { this means 16:16 or 16:32, like in CALL/JMP }
  38. OT_NEAR = $00000040;
  39. OT_SHORT = $00000080;
  40. OT_SIZE_MASK = $000000FF; { all the size attributes }
  41. OT_NON_SIZE = longint(not OT_SIZE_MASK);
  42. OT_SIGNED = $00000100; { the operand need to be signed -128-127 }
  43. OT_TO = $00000200; { operand is followed by a colon }
  44. { reverse effect in FADD, FSUB &c }
  45. OT_COLON = $00000400;
  46. OT_REGISTER = $00001000;
  47. OT_IMMEDIATE = $00002000;
  48. OT_IMM8 = $00002001;
  49. OT_IMM16 = $00002002;
  50. OT_IMM32 = $00002004;
  51. OT_IMM64 = $00002008;
  52. OT_IMM80 = $00002010;
  53. OT_REGMEM = $00200000; { for r/m, ie EA, operands }
  54. OT_REGNORM = $00201000; { 'normal' reg, qualifies as EA }
  55. OT_REG8 = $00201001;
  56. OT_REG16 = $00201002;
  57. OT_REG32 = $00201004;
  58. OT_MMXREG = $00201008; { MMX registers }
  59. OT_XMMREG = $00201010; { Katmai registers }
  60. OT_MEMORY = $00204000; { register number in 'basereg' }
  61. OT_MEM8 = $00204001;
  62. OT_MEM16 = $00204002;
  63. OT_MEM32 = $00204004;
  64. OT_MEM64 = $00204008;
  65. OT_MEM80 = $00204010;
  66. OT_FPUREG = $01000000; { floating point stack registers }
  67. OT_FPU0 = $01000800; { FPU stack register zero }
  68. OT_REG_SMASK = $00070000; { special register operands: these may be treated differently }
  69. { a mask for the following }
  70. OT_REG_ACCUM = $00211000; { accumulator: AL, AX or EAX }
  71. OT_REG_AL = $00211001; { REG_ACCUM | BITSxx }
  72. OT_REG_AX = $00211002; { ditto }
  73. OT_REG_EAX = $00211004; { and again }
  74. OT_REG_COUNT = $00221000; { counter: CL, CX or ECX }
  75. OT_REG_CL = $00221001; { REG_COUNT | BITSxx }
  76. OT_REG_CX = $00221002; { ditto }
  77. OT_REG_ECX = $00221004; { another one }
  78. OT_REG_DX = $00241002;
  79. OT_REG_SREG = $00081002; { any segment register }
  80. OT_REG_CS = $01081002; { CS }
  81. OT_REG_DESS = $02081002; { DS, ES, SS (non-CS 86 registers) }
  82. OT_REG_FSGS = $04081002; { FS, GS (386 extended registers) }
  83. OT_REG_CDT = $00101004; { CRn, DRn and TRn }
  84. OT_REG_CREG = $08101004; { CRn }
  85. OT_REG_CR4 = $08101404; { CR4 (Pentium only) }
  86. OT_REG_DREG = $10101004; { DRn }
  87. OT_REG_TREG = $20101004; { TRn }
  88. OT_MEM_OFFS = $00604000; { special type of EA }
  89. { simple [address] offset }
  90. OT_ONENESS = $00800000; { special type of immediate operand }
  91. { so UNITY == IMMEDIATE | ONENESS }
  92. OT_UNITY = $00802000; { for shift/rotate instructions }
  93. { Size of the instruction table converted by nasmconv.pas }
  94. instabentries = {$i i386nop.inc}
  95. maxinfolen = 8;
  96. type
  97. TOperandOrder = (op_intel,op_att);
  98. tinsentry=packed record
  99. opcode : tasmop;
  100. ops : byte;
  101. optypes : array[0..2] of longint;
  102. code : array[0..maxinfolen] of char;
  103. flags : longint;
  104. end;
  105. pinsentry=^tinsentry;
  106. { alignment for operator }
  107. tai_align = class(tai_align_abstract)
  108. reg : tregister;
  109. constructor create(b:byte);
  110. constructor create_op(b: byte; _op: byte);
  111. function getfillbuf:pchar;override;
  112. end;
  113. taicpu = class(taicpu_abstract)
  114. opsize : topsize;
  115. constructor op_none(op : tasmop;_size : topsize);
  116. constructor op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  117. constructor op_const(op : tasmop;_size : topsize;_op1 : aword);
  118. constructor op_ref(op : tasmop;_size : topsize;const _op1 : treference);
  119. constructor op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  120. constructor op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;const _op2 : treference);
  121. constructor op_reg_const(op:tasmop; _size: topsize; _op1: tregister; _op2: aword);
  122. constructor op_const_reg(op : tasmop;_size : topsize;_op1 : aword;_op2 : tregister);
  123. constructor op_const_const(op : tasmop;_size : topsize;_op1,_op2 : aword);
  124. constructor op_const_ref(op : tasmop;_size : topsize;_op1 : aword;const _op2 : treference);
  125. constructor op_ref_reg(op : tasmop;_size : topsize;const _op1 : treference;_op2 : tregister);
  126. constructor op_reg_reg_reg(op : tasmop;_size : topsize;_op1,_op2,_op3 : tregister);
  127. constructor op_const_reg_reg(op : tasmop;_size : topsize;_op1 : aword;_op2 : tregister;_op3 : tregister);
  128. constructor op_const_ref_reg(op : tasmop;_size : topsize;_op1 : aword;const _op2 : treference;_op3 : tregister);
  129. constructor op_reg_reg_ref(op : tasmop;_size : topsize;_op1,_op2 : tregister; const _op3 : treference);
  130. constructor op_const_reg_ref(op : tasmop;_size : topsize;_op1 : aword;_op2 : tregister;const _op3 : treference);
  131. { this is for Jmp instructions }
  132. constructor op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
  133. constructor op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
  134. constructor op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
  135. constructor op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
  136. constructor op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  137. procedure changeopsize(siz:topsize);
  138. function GetString:string;
  139. procedure CheckNonCommutativeOpcodes;
  140. private
  141. FOperandOrder : TOperandOrder;
  142. procedure init(_size : topsize); { this need to be called by all constructor }
  143. {$ifndef NOAG386BIN}
  144. public
  145. { the next will reset all instructions that can change in pass 2 }
  146. procedure ResetPass1;
  147. procedure ResetPass2;
  148. function CheckIfValid:boolean;
  149. function Pass1(offset:longint):longint;virtual;
  150. procedure Pass2(sec:TAsmObjectdata);virtual;
  151. procedure SetOperandOrder(order:TOperandOrder);
  152. protected
  153. procedure ppuloadoper(ppufile:tcompilerppufile;var o:toper);override;
  154. procedure ppuwriteoper(ppufile:tcompilerppufile;const o:toper);override;
  155. procedure ppuderefoper(var o:toper);override;
  156. private
  157. { next fields are filled in pass1, so pass2 is faster }
  158. insentry : PInsEntry;
  159. insoffset,
  160. inssize : longint;
  161. LastInsOffset : longint; { need to be public to be reset }
  162. function InsEnd:longint;
  163. procedure create_ot;
  164. function Matches(p:PInsEntry):longint;
  165. function calcsize(p:PInsEntry):longint;
  166. procedure gencode(sec:TAsmObjectData);
  167. function NeedAddrPrefix(opidx:byte):boolean;
  168. procedure Swapoperands;
  169. {$endif NOAG386BIN}
  170. end;
  171. procedure InitAsm;
  172. procedure DoneAsm;
  173. implementation
  174. uses
  175. cutils,
  176. ag386att;
  177. {*****************************************************************************
  178. Instruction table
  179. *****************************************************************************}
  180. const
  181. {Instruction flags }
  182. IF_NONE = $00000000;
  183. IF_SM = $00000001; { size match first two operands }
  184. IF_SM2 = $00000002;
  185. IF_SB = $00000004; { unsized operands can't be non-byte }
  186. IF_SW = $00000008; { unsized operands can't be non-word }
  187. IF_SD = $00000010; { unsized operands can't be nondword }
  188. IF_AR0 = $00000020; { SB, SW, SD applies to argument 0 }
  189. IF_AR1 = $00000040; { SB, SW, SD applies to argument 1 }
  190. IF_AR2 = $00000060; { SB, SW, SD applies to argument 2 }
  191. IF_ARMASK = $00000060; { mask for unsized argument spec }
  192. IF_PRIV = $00000100; { it's a privileged instruction }
  193. IF_SMM = $00000200; { it's only valid in SMM }
  194. IF_PROT = $00000400; { it's protected mode only }
  195. IF_UNDOC = $00001000; { it's an undocumented instruction }
  196. IF_FPU = $00002000; { it's an FPU instruction }
  197. IF_MMX = $00004000; { it's an MMX instruction }
  198. { it's a 3DNow! instruction }
  199. IF_3DNOW = $00008000;
  200. { it's a SSE (KNI, MMX2) instruction }
  201. IF_SSE = $00010000;
  202. { SSE2 instructions }
  203. IF_SSE2 = $00020000;
  204. { the mask for processor types }
  205. IF_PMASK = longint($FF000000);
  206. { the mask for disassembly "prefer" }
  207. IF_PFMASK = longint($F001FF00);
  208. IF_8086 = $00000000; { 8086 instruction }
  209. IF_186 = $01000000; { 186+ instruction }
  210. IF_286 = $02000000; { 286+ instruction }
  211. IF_386 = $03000000; { 386+ instruction }
  212. IF_486 = $04000000; { 486+ instruction }
  213. IF_PENT = $05000000; { Pentium instruction }
  214. IF_P6 = $06000000; { P6 instruction }
  215. IF_KATMAI = $07000000; { Katmai instructions }
  216. { Willamette instructions }
  217. IF_WILLAMETTE = $08000000;
  218. IF_CYRIX = $10000000; { Cyrix-specific instruction }
  219. IF_AMD = $20000000; { AMD-specific instruction }
  220. { added flags }
  221. IF_PRE = $40000000; { it's a prefix instruction }
  222. IF_PASS2 = longint($80000000); { if the instruction can change in a second pass }
  223. type
  224. TInsTabCache=array[TasmOp] of longint;
  225. PInsTabCache=^TInsTabCache;
  226. const
  227. InsTab:array[0..instabentries-1] of TInsEntry={$i i386tab.inc}
  228. var
  229. InsTabCache : PInsTabCache;
  230. const
  231. { Intel style operands ! }
  232. opsize_2_type:array[0..2,topsize] of longint=(
  233. (OT_NONE,
  234. OT_BITS8,OT_BITS16,OT_BITS32,OT_BITS16,OT_BITS32,OT_BITS32,
  235. OT_BITS16,OT_BITS32,OT_BITS64,
  236. OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64,
  237. OT_NEAR,OT_FAR,OT_SHORT
  238. ),
  239. (OT_NONE,
  240. OT_BITS8,OT_BITS16,OT_BITS32,OT_BITS8,OT_BITS8,OT_BITS16,
  241. OT_BITS16,OT_BITS32,OT_BITS64,
  242. OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64,
  243. OT_NEAR,OT_FAR,OT_SHORT
  244. ),
  245. (OT_NONE,
  246. OT_BITS8,OT_BITS16,OT_BITS32,OT_NONE,OT_NONE,OT_NONE,
  247. OT_BITS16,OT_BITS32,OT_BITS64,
  248. OT_BITS32,OT_BITS64,OT_BITS80,OT_BITS64,OT_BITS64,OT_BITS64,
  249. OT_NEAR,OT_FAR,OT_SHORT
  250. )
  251. );
  252. { Convert reg to operand type }
  253. reg2type : array[firstreg..lastreg] of longint = (OT_NONE,
  254. OT_REG_EAX,OT_REG_ECX,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,OT_REG32,
  255. OT_REG_AX,OT_REG_CX,OT_REG_DX,OT_REG16,OT_REG16,OT_REG16,OT_REG16,OT_REG16,
  256. OT_REG_AL,OT_REG_CL,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,OT_REG8,
  257. OT_REG_CS,OT_REG_DESS,OT_REG_DESS,OT_REG_DESS,OT_REG_FSGS,OT_REG_FSGS,
  258. OT_FPU0,OT_FPU0,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,OT_FPUREG,
  259. OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,OT_REG_DREG,
  260. OT_REG_CREG,OT_REG_CREG,OT_REG_CREG,OT_REG_CR4,
  261. OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,OT_REG_TREG,
  262. OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,OT_MMXREG,
  263. OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG,OT_XMMREG
  264. );
  265. {****************************************************************************
  266. TAI_ALIGN
  267. ****************************************************************************}
  268. constructor tai_align.create(b: byte);
  269. begin
  270. inherited create(b);
  271. reg := R_ECX;
  272. end;
  273. constructor tai_align.create_op(b: byte; _op: byte);
  274. begin
  275. inherited create_op(b,_op);
  276. reg := R_NO;
  277. end;
  278. function tai_align.getfillbuf:pchar;
  279. const
  280. alignarray:array[0..5] of string[8]=(
  281. #$8D#$B4#$26#$00#$00#$00#$00,
  282. #$8D#$B6#$00#$00#$00#$00,
  283. #$8D#$74#$26#$00,
  284. #$8D#$76#$00,
  285. #$89#$F6,
  286. #$90
  287. );
  288. var
  289. bufptr : pchar;
  290. j : longint;
  291. begin
  292. if not use_op then
  293. begin
  294. bufptr:=@buf;
  295. while (fillsize>0) do
  296. begin
  297. for j:=0 to 5 do
  298. if (fillsize>=length(alignarray[j])) then
  299. break;
  300. move(alignarray[j][1],bufptr^,length(alignarray[j]));
  301. inc(bufptr,length(alignarray[j]));
  302. dec(fillsize,length(alignarray[j]));
  303. end;
  304. end;
  305. getfillbuf:=pchar(@buf);
  306. end;
  307. {*****************************************************************************
  308. Taicpu Constructors
  309. *****************************************************************************}
  310. procedure taicpu.changeopsize(siz:topsize);
  311. begin
  312. opsize:=siz;
  313. end;
  314. procedure taicpu.init(_size : topsize);
  315. begin
  316. { default order is att }
  317. FOperandOrder:=op_att;
  318. segprefix:=R_NO;
  319. opsize:=_size;
  320. {$ifndef NOAG386BIN}
  321. insentry:=nil;
  322. LastInsOffset:=-1;
  323. InsOffset:=0;
  324. InsSize:=0;
  325. {$endif}
  326. end;
  327. constructor taicpu.op_none(op : tasmop;_size : topsize);
  328. begin
  329. inherited create(op);
  330. init(_size);
  331. end;
  332. constructor taicpu.op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  333. begin
  334. inherited create(op);
  335. init(_size);
  336. ops:=1;
  337. loadreg(0,_op1);
  338. end;
  339. constructor taicpu.op_const(op : tasmop;_size : topsize;_op1 : aword);
  340. begin
  341. inherited create(op);
  342. init(_size);
  343. ops:=1;
  344. loadconst(0,_op1);
  345. end;
  346. constructor taicpu.op_ref(op : tasmop;_size : topsize;const _op1 : treference);
  347. begin
  348. inherited create(op);
  349. init(_size);
  350. ops:=1;
  351. loadref(0,_op1);
  352. end;
  353. constructor taicpu.op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  354. begin
  355. inherited create(op);
  356. init(_size);
  357. ops:=2;
  358. loadreg(0,_op1);
  359. loadreg(1,_op2);
  360. end;
  361. constructor taicpu.op_reg_const(op:tasmop; _size: topsize; _op1: tregister; _op2: aword);
  362. begin
  363. inherited create(op);
  364. init(_size);
  365. ops:=2;
  366. loadreg(0,_op1);
  367. loadconst(1,_op2);
  368. end;
  369. constructor taicpu.op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;const _op2 : treference);
  370. begin
  371. inherited create(op);
  372. init(_size);
  373. ops:=2;
  374. loadreg(0,_op1);
  375. loadref(1,_op2);
  376. end;
  377. constructor taicpu.op_const_reg(op : tasmop;_size : topsize;_op1 : aword;_op2 : tregister);
  378. begin
  379. inherited create(op);
  380. init(_size);
  381. ops:=2;
  382. loadconst(0,_op1);
  383. loadreg(1,_op2);
  384. end;
  385. constructor taicpu.op_const_const(op : tasmop;_size : topsize;_op1,_op2 : aword);
  386. begin
  387. inherited create(op);
  388. init(_size);
  389. ops:=2;
  390. loadconst(0,_op1);
  391. loadconst(1,_op2);
  392. end;
  393. constructor taicpu.op_const_ref(op : tasmop;_size : topsize;_op1 : aword;const _op2 : treference);
  394. begin
  395. inherited create(op);
  396. init(_size);
  397. ops:=2;
  398. loadconst(0,_op1);
  399. loadref(1,_op2);
  400. end;
  401. constructor taicpu.op_ref_reg(op : tasmop;_size : topsize;const _op1 : treference;_op2 : tregister);
  402. begin
  403. inherited create(op);
  404. init(_size);
  405. ops:=2;
  406. loadref(0,_op1);
  407. loadreg(1,_op2);
  408. end;
  409. constructor taicpu.op_reg_reg_reg(op : tasmop;_size : topsize;_op1,_op2,_op3 : tregister);
  410. begin
  411. inherited create(op);
  412. init(_size);
  413. ops:=3;
  414. loadreg(0,_op1);
  415. loadreg(1,_op2);
  416. loadreg(2,_op3);
  417. end;
  418. constructor taicpu.op_const_reg_reg(op : tasmop;_size : topsize;_op1 : aword;_op2 : tregister;_op3 : tregister);
  419. begin
  420. inherited create(op);
  421. init(_size);
  422. ops:=3;
  423. loadconst(0,_op1);
  424. loadreg(1,_op2);
  425. loadreg(2,_op3);
  426. end;
  427. constructor taicpu.op_reg_reg_ref(op : tasmop;_size : topsize;_op1,_op2 : tregister;const _op3 : treference);
  428. begin
  429. inherited create(op);
  430. init(_size);
  431. ops:=3;
  432. loadreg(0,_op1);
  433. loadreg(1,_op2);
  434. loadref(2,_op3);
  435. end;
  436. constructor taicpu.op_const_ref_reg(op : tasmop;_size : topsize;_op1 : aword;const _op2 : treference;_op3 : tregister);
  437. begin
  438. inherited create(op);
  439. init(_size);
  440. ops:=3;
  441. loadconst(0,_op1);
  442. loadref(1,_op2);
  443. loadreg(2,_op3);
  444. end;
  445. constructor taicpu.op_const_reg_ref(op : tasmop;_size : topsize;_op1 : aword;_op2 : tregister;const _op3 : treference);
  446. begin
  447. inherited create(op);
  448. init(_size);
  449. ops:=3;
  450. loadconst(0,_op1);
  451. loadreg(1,_op2);
  452. loadref(2,_op3);
  453. end;
  454. constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
  455. begin
  456. inherited create(op);
  457. init(_size);
  458. condition:=cond;
  459. ops:=1;
  460. loadsymbol(0,_op1,0);
  461. end;
  462. constructor taicpu.op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
  463. begin
  464. inherited create(op);
  465. init(_size);
  466. ops:=1;
  467. loadsymbol(0,_op1,0);
  468. end;
  469. constructor taicpu.op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
  470. begin
  471. inherited create(op);
  472. init(_size);
  473. ops:=1;
  474. loadsymbol(0,_op1,_op1ofs);
  475. end;
  476. constructor taicpu.op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
  477. begin
  478. inherited create(op);
  479. init(_size);
  480. ops:=2;
  481. loadsymbol(0,_op1,_op1ofs);
  482. loadreg(1,_op2);
  483. end;
  484. constructor taicpu.op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  485. begin
  486. inherited create(op);
  487. init(_size);
  488. ops:=2;
  489. loadsymbol(0,_op1,_op1ofs);
  490. loadref(1,_op2);
  491. end;
  492. function taicpu.GetString:string;
  493. var
  494. i : longint;
  495. s : string;
  496. addsize : boolean;
  497. begin
  498. s:='['+std_op2str[opcode];
  499. for i:=1to ops do
  500. begin
  501. if i=1 then
  502. s:=s+' '
  503. else
  504. s:=s+',';
  505. { type }
  506. addsize:=false;
  507. if (oper[i-1].ot and OT_XMMREG)=OT_XMMREG then
  508. s:=s+'xmmreg'
  509. else
  510. if (oper[i-1].ot and OT_MMXREG)=OT_MMXREG then
  511. s:=s+'mmxreg'
  512. else
  513. if (oper[i-1].ot and OT_FPUREG)=OT_FPUREG then
  514. s:=s+'fpureg'
  515. else
  516. if (oper[i-1].ot and OT_REGISTER)=OT_REGISTER then
  517. begin
  518. s:=s+'reg';
  519. addsize:=true;
  520. end
  521. else
  522. if (oper[i-1].ot and OT_IMMEDIATE)=OT_IMMEDIATE then
  523. begin
  524. s:=s+'imm';
  525. addsize:=true;
  526. end
  527. else
  528. if (oper[i-1].ot and OT_MEMORY)=OT_MEMORY then
  529. begin
  530. s:=s+'mem';
  531. addsize:=true;
  532. end
  533. else
  534. s:=s+'???';
  535. { size }
  536. if addsize then
  537. begin
  538. if (oper[i-1].ot and OT_BITS8)<>0 then
  539. s:=s+'8'
  540. else
  541. if (oper[i-1].ot and OT_BITS16)<>0 then
  542. s:=s+'16'
  543. else
  544. if (oper[i-1].ot and OT_BITS32)<>0 then
  545. s:=s+'32'
  546. else
  547. s:=s+'??';
  548. { signed }
  549. if (oper[i-1].ot and OT_SIGNED)<>0 then
  550. s:=s+'s';
  551. end;
  552. end;
  553. GetString:=s+']';
  554. end;
  555. procedure taicpu.Swapoperands;
  556. var
  557. p : TOper;
  558. begin
  559. { Fix the operands which are in AT&T style and we need them in Intel style }
  560. case ops of
  561. 2 : begin
  562. { 0,1 -> 1,0 }
  563. p:=oper[0];
  564. oper[0]:=oper[1];
  565. oper[1]:=p;
  566. end;
  567. 3 : begin
  568. { 0,1,2 -> 2,1,0 }
  569. p:=oper[0];
  570. oper[0]:=oper[2];
  571. oper[2]:=p;
  572. end;
  573. end;
  574. end;
  575. procedure taicpu.SetOperandOrder(order:TOperandOrder);
  576. begin
  577. if FOperandOrder<>order then
  578. begin
  579. Swapoperands;
  580. FOperandOrder:=order;
  581. end;
  582. end;
  583. procedure taicpu.ppuloadoper(ppufile:tcompilerppufile;var o:toper);
  584. begin
  585. o.typ:=toptype(ppufile.getbyte);
  586. o.ot:=ppufile.getlongint;
  587. case o.typ of
  588. top_reg :
  589. o.reg:=tregister(ppufile.getbyte);
  590. top_ref :
  591. begin
  592. new(o.ref);
  593. o.ref^.segment:=tregister(ppufile.getbyte);
  594. o.ref^.base:=tregister(ppufile.getbyte);
  595. o.ref^.index:=tregister(ppufile.getbyte);
  596. o.ref^.scalefactor:=ppufile.getbyte;
  597. o.ref^.offset:=ppufile.getlongint;
  598. o.ref^.symbol:=ppufile.getasmsymbol;
  599. o.ref^.offsetfixup:=ppufile.getlongint;
  600. o.ref^.options:=trefoptions(ppufile.getbyte);
  601. end;
  602. top_const :
  603. o.val:=aword(ppufile.getlongint);
  604. top_symbol :
  605. begin
  606. o.sym:=ppufile.getasmsymbol;
  607. o.symofs:=ppufile.getlongint;
  608. end;
  609. end;
  610. end;
  611. procedure taicpu.ppuwriteoper(ppufile:tcompilerppufile;const o:toper);
  612. begin
  613. ppufile.putbyte(byte(o.typ));
  614. ppufile.putlongint(o.ot);
  615. case o.typ of
  616. top_reg :
  617. ppufile.putbyte(byte(o.reg));
  618. top_ref :
  619. begin
  620. ppufile.putbyte(byte(o.ref^.segment));
  621. ppufile.putbyte(byte(o.ref^.base));
  622. ppufile.putbyte(byte(o.ref^.index));
  623. ppufile.putbyte(o.ref^.scalefactor);
  624. ppufile.putlongint(o.ref^.offset);
  625. ppufile.putasmsymbol(o.ref^.symbol);
  626. ppufile.putlongint(o.ref^.offsetfixup);
  627. ppufile.putbyte(byte(o.ref^.options));
  628. end;
  629. top_const :
  630. ppufile.putlongint(longint(o.val));
  631. top_symbol :
  632. begin
  633. ppufile.putasmsymbol(o.sym);
  634. ppufile.putlongint(longint(o.symofs));
  635. end;
  636. end;
  637. end;
  638. procedure taicpu.ppuderefoper(var o:toper);
  639. begin
  640. case o.typ of
  641. top_ref :
  642. begin
  643. if assigned(o.ref^.symbol) then
  644. objectlibrary.derefasmsymbol(o.ref^.symbol);
  645. end;
  646. top_symbol :
  647. objectlibrary.derefasmsymbol(o.sym);
  648. end;
  649. end;
  650. procedure taicpu.CheckNonCommutativeOpcodes;
  651. begin
  652. { we need ATT order }
  653. SetOperandOrder(op_att);
  654. if ((ops=2) and
  655. (oper[0].typ=top_reg) and
  656. (oper[1].typ=top_reg) and
  657. { if the first is ST and the second is also a register
  658. it is necessarily ST1 .. ST7 }
  659. (oper[0].reg in [R_ST..R_ST0])) or
  660. { ((ops=1) and
  661. (oper[0].typ=top_reg) and
  662. (oper[0].reg in [R_ST1..R_ST7])) or}
  663. (ops=0) then
  664. if opcode=A_FSUBR then
  665. opcode:=A_FSUB
  666. else if opcode=A_FSUB then
  667. opcode:=A_FSUBR
  668. else if opcode=A_FDIVR then
  669. opcode:=A_FDIV
  670. else if opcode=A_FDIV then
  671. opcode:=A_FDIVR
  672. else if opcode=A_FSUBRP then
  673. opcode:=A_FSUBP
  674. else if opcode=A_FSUBP then
  675. opcode:=A_FSUBRP
  676. else if opcode=A_FDIVRP then
  677. opcode:=A_FDIVP
  678. else if opcode=A_FDIVP then
  679. opcode:=A_FDIVRP;
  680. if ((ops=1) and
  681. (oper[0].typ=top_reg) and
  682. (oper[0].reg in [R_ST1..R_ST7])) then
  683. if opcode=A_FSUBRP then
  684. opcode:=A_FSUBP
  685. else if opcode=A_FSUBP then
  686. opcode:=A_FSUBRP
  687. else if opcode=A_FDIVRP then
  688. opcode:=A_FDIVP
  689. else if opcode=A_FDIVP then
  690. opcode:=A_FDIVRP;
  691. end;
  692. {*****************************************************************************
  693. Assembler
  694. *****************************************************************************}
  695. {$ifndef NOAG386BIN}
  696. type
  697. ea=packed record
  698. sib_present : boolean;
  699. bytes : byte;
  700. size : byte;
  701. modrm : byte;
  702. sib : byte;
  703. end;
  704. procedure taicpu.create_ot;
  705. {
  706. this function will also fix some other fields which only needs to be once
  707. }
  708. var
  709. i,l,relsize : longint;
  710. begin
  711. if ops=0 then
  712. exit;
  713. { update oper[].ot field }
  714. for i:=0 to ops-1 do
  715. with oper[i] do
  716. begin
  717. case typ of
  718. top_reg :
  719. ot:=reg2type[reg];
  720. top_ref :
  721. begin
  722. { create ot field }
  723. if (ot and OT_SIZE_MASK)=0 then
  724. ot:=OT_MEMORY or opsize_2_type[i,opsize]
  725. else
  726. ot:=OT_MEMORY or (ot and OT_SIZE_MASK);
  727. if (ref^.base=R_NO) and (ref^.index=R_NO) then
  728. ot:=ot or OT_MEM_OFFS;
  729. { fix scalefactor }
  730. if (ref^.index=R_NO) then
  731. ref^.scalefactor:=0
  732. else
  733. if (ref^.scalefactor=0) then
  734. ref^.scalefactor:=1;
  735. end;
  736. top_const :
  737. begin
  738. if (opsize<>S_W) and (longint(val)>=-128) and (val<=127) then
  739. ot:=OT_IMM8 or OT_SIGNED
  740. else
  741. ot:=OT_IMMEDIATE or opsize_2_type[i,opsize];
  742. end;
  743. top_symbol :
  744. begin
  745. if LastInsOffset=-1 then
  746. l:=0
  747. else
  748. l:=InsOffset-LastInsOffset;
  749. inc(l,symofs);
  750. if assigned(sym) then
  751. inc(l,sym.address);
  752. { instruction size will then always become 2 (PFV) }
  753. relsize:=(InsOffset+2)-l;
  754. if (not assigned(sym) or
  755. ((sym.currbind<>AB_EXTERNAL) and (sym.address<>0))) and
  756. (relsize>=-128) and (relsize<=127) then
  757. ot:=OT_IMM32 or OT_SHORT
  758. else
  759. ot:=OT_IMM32 or OT_NEAR;
  760. end;
  761. end;
  762. end;
  763. end;
  764. function taicpu.InsEnd:longint;
  765. begin
  766. InsEnd:=InsOffset+InsSize;
  767. end;
  768. function taicpu.Matches(p:PInsEntry):longint;
  769. { * IF_SM stands for Size Match: any operand whose size is not
  770. * explicitly specified by the template is `really' intended to be
  771. * the same size as the first size-specified operand.
  772. * Non-specification is tolerated in the input instruction, but
  773. * _wrong_ specification is not.
  774. *
  775. * IF_SM2 invokes Size Match on only the first _two_ operands, for
  776. * three-operand instructions such as SHLD: it implies that the
  777. * first two operands must match in size, but that the third is
  778. * required to be _unspecified_.
  779. *
  780. * IF_SB invokes Size Byte: operands with unspecified size in the
  781. * template are really bytes, and so no non-byte specification in
  782. * the input instruction will be tolerated. IF_SW similarly invokes
  783. * Size Word, and IF_SD invokes Size Doubleword.
  784. *
  785. * (The default state if neither IF_SM nor IF_SM2 is specified is
  786. * that any operand with unspecified size in the template is
  787. * required to have unspecified size in the instruction too...)
  788. }
  789. var
  790. i,j,asize,oprs : longint;
  791. siz : array[0..2] of longint;
  792. begin
  793. Matches:=100;
  794. { Check the opcode and operands }
  795. if (p^.opcode<>opcode) or (p^.ops<>ops) then
  796. begin
  797. Matches:=0;
  798. exit;
  799. end;
  800. { Check that no spurious colons or TOs are present }
  801. for i:=0 to p^.ops-1 do
  802. if (oper[i].ot and (not p^.optypes[i]) and (OT_COLON or OT_TO))<>0 then
  803. begin
  804. Matches:=0;
  805. exit;
  806. end;
  807. { Check that the operand flags all match up }
  808. for i:=0 to p^.ops-1 do
  809. begin
  810. if ((p^.optypes[i] and (not oper[i].ot)) or
  811. ((p^.optypes[i] and OT_SIZE_MASK) and
  812. ((p^.optypes[i] xor oper[i].ot) and OT_SIZE_MASK)))<>0 then
  813. begin
  814. if ((p^.optypes[i] and (not oper[i].ot) and OT_NON_SIZE) or
  815. (oper[i].ot and OT_SIZE_MASK))<>0 then
  816. begin
  817. Matches:=0;
  818. exit;
  819. end
  820. else
  821. Matches:=1;
  822. end;
  823. end;
  824. { Check operand sizes }
  825. { as default an untyped size can get all the sizes, this is different
  826. from nasm, but else we need to do a lot checking which opcodes want
  827. size or not with the automatic size generation }
  828. asize:=longint($ffffffff);
  829. if (p^.flags and IF_SB)<>0 then
  830. asize:=OT_BITS8
  831. else if (p^.flags and IF_SW)<>0 then
  832. asize:=OT_BITS16
  833. else if (p^.flags and IF_SD)<>0 then
  834. asize:=OT_BITS32;
  835. if (p^.flags and IF_ARMASK)<>0 then
  836. begin
  837. siz[0]:=0;
  838. siz[1]:=0;
  839. siz[2]:=0;
  840. if (p^.flags and IF_AR0)<>0 then
  841. siz[0]:=asize
  842. else if (p^.flags and IF_AR1)<>0 then
  843. siz[1]:=asize
  844. else if (p^.flags and IF_AR2)<>0 then
  845. siz[2]:=asize;
  846. end
  847. else
  848. begin
  849. { we can leave because the size for all operands is forced to be
  850. the same
  851. but not if IF_SB IF_SW or IF_SD is set PM }
  852. if asize=-1 then
  853. exit;
  854. siz[0]:=asize;
  855. siz[1]:=asize;
  856. siz[2]:=asize;
  857. end;
  858. if (p^.flags and (IF_SM or IF_SM2))<>0 then
  859. begin
  860. if (p^.flags and IF_SM2)<>0 then
  861. oprs:=2
  862. else
  863. oprs:=p^.ops;
  864. for i:=0 to oprs-1 do
  865. if ((p^.optypes[i] and OT_SIZE_MASK) <> 0) then
  866. begin
  867. for j:=0 to oprs-1 do
  868. siz[j]:=p^.optypes[i] and OT_SIZE_MASK;
  869. break;
  870. end;
  871. end
  872. else
  873. oprs:=2;
  874. { Check operand sizes }
  875. for i:=0 to p^.ops-1 do
  876. begin
  877. if ((p^.optypes[i] and OT_SIZE_MASK)=0) and
  878. ((oper[i].ot and OT_SIZE_MASK and (not siz[i]))<>0) and
  879. { Immediates can always include smaller size }
  880. ((oper[i].ot and OT_IMMEDIATE)=0) and
  881. (((p^.optypes[i] and OT_SIZE_MASK) or siz[i])<(oper[i].ot and OT_SIZE_MASK)) then
  882. Matches:=2;
  883. end;
  884. end;
  885. procedure taicpu.ResetPass1;
  886. begin
  887. { we need to reset everything here, because the choosen insentry
  888. can be invalid for a new situation where the previously optimized
  889. insentry is not correct }
  890. InsEntry:=nil;
  891. InsSize:=0;
  892. LastInsOffset:=-1;
  893. end;
  894. procedure taicpu.ResetPass2;
  895. begin
  896. { we are here in a second pass, check if the instruction can be optimized }
  897. if assigned(InsEntry) and
  898. ((InsEntry^.flags and IF_PASS2)<>0) then
  899. begin
  900. InsEntry:=nil;
  901. InsSize:=0;
  902. end;
  903. LastInsOffset:=-1;
  904. end;
  905. function taicpu.CheckIfValid:boolean;
  906. var
  907. m,i : longint;
  908. begin
  909. CheckIfValid:=false;
  910. { Things which may only be done once, not when a second pass is done to
  911. optimize }
  912. if (Insentry=nil) or ((InsEntry^.flags and IF_PASS2)<>0) then
  913. begin
  914. { We need intel style operands }
  915. SetOperandOrder(op_intel);
  916. { create the .ot fields }
  917. create_ot;
  918. { set the file postion }
  919. aktfilepos:=fileinfo;
  920. end
  921. else
  922. begin
  923. { we've already an insentry so it's valid }
  924. CheckIfValid:=true;
  925. exit;
  926. end;
  927. { Lookup opcode in the table }
  928. InsSize:=-1;
  929. i:=instabcache^[opcode];
  930. if i=-1 then
  931. begin
  932. Message1(asmw_e_opcode_not_in_table,gas_op2str[opcode]);
  933. exit;
  934. end;
  935. insentry:=@instab[i];
  936. while (insentry^.opcode=opcode) do
  937. begin
  938. m:=matches(insentry);
  939. if m=100 then
  940. begin
  941. InsSize:=calcsize(insentry);
  942. if (segprefix<>R_NO) then
  943. inc(InsSize);
  944. { For opsize if size if forced }
  945. if (insentry^.flags and (IF_SB or IF_SW or IF_SD))<>0 then
  946. begin
  947. if (insentry^.flags and IF_ARMASK)=0 then
  948. begin
  949. if (insentry^.flags and IF_SB)<>0 then
  950. begin
  951. if opsize=S_NO then
  952. opsize:=S_B;
  953. end
  954. else if (insentry^.flags and IF_SW)<>0 then
  955. begin
  956. if opsize=S_NO then
  957. opsize:=S_W;
  958. end
  959. else if (insentry^.flags and IF_SD)<>0 then
  960. begin
  961. if opsize=S_NO then
  962. opsize:=S_L;
  963. end;
  964. end;
  965. end;
  966. CheckIfValid:=true;
  967. exit;
  968. end;
  969. inc(i);
  970. insentry:=@instab[i];
  971. end;
  972. if insentry^.opcode<>opcode then
  973. Message1(asmw_e_invalid_opcode_and_operands,GetString);
  974. { No instruction found, set insentry to nil and inssize to -1 }
  975. insentry:=nil;
  976. inssize:=-1;
  977. end;
  978. function taicpu.Pass1(offset:longint):longint;
  979. begin
  980. Pass1:=0;
  981. { Save the old offset and set the new offset }
  982. InsOffset:=Offset;
  983. { Things which may only be done once, not when a second pass is done to
  984. optimize }
  985. if Insentry=nil then
  986. begin
  987. { Check if error last time then InsSize=-1 }
  988. if InsSize=-1 then
  989. exit;
  990. { set the file postion }
  991. aktfilepos:=fileinfo;
  992. end
  993. else
  994. begin
  995. {$ifdef PASS2FLAG}
  996. { we are here in a second pass, check if the instruction can be optimized }
  997. if (InsEntry^.flags and IF_PASS2)=0 then
  998. begin
  999. Pass1:=InsSize;
  1000. exit;
  1001. end;
  1002. { update the .ot fields, some top_const can be updated }
  1003. create_ot;
  1004. {$endif PASS2FLAG}
  1005. end;
  1006. { Check if it's a valid instruction }
  1007. if CheckIfValid then
  1008. begin
  1009. LastInsOffset:=InsOffset;
  1010. Pass1:=InsSize;
  1011. exit;
  1012. end;
  1013. LastInsOffset:=-1;
  1014. end;
  1015. procedure taicpu.Pass2(sec:TAsmObjectData);
  1016. var
  1017. c : longint;
  1018. begin
  1019. { error in pass1 ? }
  1020. if insentry=nil then
  1021. exit;
  1022. aktfilepos:=fileinfo;
  1023. { Segment override }
  1024. if (segprefix<>R_NO) then
  1025. begin
  1026. case segprefix of
  1027. R_CS : c:=$2e;
  1028. R_DS : c:=$3e;
  1029. R_ES : c:=$26;
  1030. R_FS : c:=$64;
  1031. R_GS : c:=$65;
  1032. R_SS : c:=$36;
  1033. end;
  1034. sec.writebytes(c,1);
  1035. { fix the offset for GenNode }
  1036. inc(InsOffset);
  1037. end;
  1038. { Generate the instruction }
  1039. GenCode(sec);
  1040. end;
  1041. function taicpu.NeedAddrPrefix(opidx:byte):boolean;
  1042. var
  1043. i,b : tregister;
  1044. begin
  1045. if (OT_MEMORY and (not oper[opidx].ot))=0 then
  1046. begin
  1047. i:=oper[opidx].ref^.index;
  1048. b:=oper[opidx].ref^.base;
  1049. if not(i in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) or
  1050. not(b in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) then
  1051. begin
  1052. NeedAddrPrefix:=true;
  1053. exit;
  1054. end;
  1055. end;
  1056. NeedAddrPrefix:=false;
  1057. end;
  1058. function regval(r:tregister):byte;
  1059. begin
  1060. case r of
  1061. R_EAX,R_AX,R_AL,R_ES,R_CR0,R_DR0,R_ST,R_ST0,R_MM0,R_XMM0 :
  1062. regval:=0;
  1063. R_ECX,R_CX,R_CL,R_CS,R_DR1,R_ST1,R_MM1,R_XMM1 :
  1064. regval:=1;
  1065. R_EDX,R_DX,R_DL,R_SS,R_CR2,R_DR2,R_ST2,R_MM2,R_XMM2 :
  1066. regval:=2;
  1067. R_EBX,R_BX,R_BL,R_DS,R_CR3,R_DR3,R_TR3,R_ST3,R_MM3,R_XMM3 :
  1068. regval:=3;
  1069. R_ESP,R_SP,R_AH,R_FS,R_CR4,R_TR4,R_ST4,R_MM4,R_XMM4 :
  1070. regval:=4;
  1071. R_EBP,R_BP,R_CH,R_GS,R_TR5,R_ST5,R_MM5,R_XMM5 :
  1072. regval:=5;
  1073. R_ESI,R_SI,R_DH,R_DR6,R_TR6,R_ST6,R_MM6,R_XMM6 :
  1074. regval:=6;
  1075. R_EDI,R_DI,R_BH,R_DR7,R_TR7,R_ST7,R_MM7,R_XMM7 :
  1076. regval:=7;
  1077. else
  1078. begin
  1079. internalerror(777001);
  1080. regval:=0;
  1081. end;
  1082. end;
  1083. end;
  1084. function process_ea(const input:toper;var output:ea;rfield:longint):boolean;
  1085. const
  1086. regs : array[0..63] of tregister=(
  1087. R_MM0, R_EAX, R_AX, R_AL, R_XMM0, R_NO, R_NO, R_NO,
  1088. R_MM1, R_ECX, R_CX, R_CL, R_XMM1, R_NO, R_NO, R_NO,
  1089. R_MM2, R_EDX, R_DX, R_DL, R_XMM2, R_NO, R_NO, R_NO,
  1090. R_MM3, R_EBX, R_BX, R_BL, R_XMM3, R_NO, R_NO, R_NO,
  1091. R_MM4, R_ESP, R_SP, R_AH, R_XMM4, R_NO, R_NO, R_NO,
  1092. R_MM5, R_EBP, R_BP, R_CH, R_XMM5, R_NO, R_NO, R_NO,
  1093. R_MM6, R_ESI, R_SI, R_DH, R_XMM6, R_NO, R_NO, R_NO,
  1094. R_MM7, R_EDI, R_DI, R_BH, R_XMM7, R_NO, R_NO, R_NO
  1095. );
  1096. var
  1097. j : longint;
  1098. i,b : tregister;
  1099. sym : tasmsymbol;
  1100. md,s : byte;
  1101. base,index,scalefactor,
  1102. o : longint;
  1103. begin
  1104. process_ea:=false;
  1105. { register ? }
  1106. if (input.typ=top_reg) then
  1107. begin
  1108. j:=0;
  1109. while (j<=high(regs)) do
  1110. begin
  1111. if input.reg=regs[j] then
  1112. break;
  1113. inc(j);
  1114. end;
  1115. if j<=high(regs) then
  1116. begin
  1117. output.sib_present:=false;
  1118. output.bytes:=0;
  1119. output.modrm:=$c0 or (rfield shl 3) or (j shr 3);
  1120. output.size:=1;
  1121. process_ea:=true;
  1122. end;
  1123. exit;
  1124. end;
  1125. { memory reference }
  1126. i:=input.ref^.index;
  1127. b:=input.ref^.base;
  1128. s:=input.ref^.scalefactor;
  1129. o:=input.ref^.offset+input.ref^.offsetfixup;
  1130. sym:=input.ref^.symbol;
  1131. { it's direct address }
  1132. if (b=R_NO) and (i=R_NO) then
  1133. begin
  1134. { it's a pure offset }
  1135. output.sib_present:=false;
  1136. output.bytes:=4;
  1137. output.modrm:=5 or (rfield shl 3);
  1138. end
  1139. else
  1140. { it's an indirection }
  1141. begin
  1142. { 16 bit address? }
  1143. if not((i in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI]) and
  1144. (b in [R_NO,R_EAX,R_EBX,R_ECX,R_EDX,R_EBP,R_ESP,R_ESI,R_EDI])) then
  1145. Message(asmw_e_16bit_not_supported);
  1146. {$ifdef OPTEA}
  1147. { make single reg base }
  1148. if (b=R_NO) and (s=1) then
  1149. begin
  1150. b:=i;
  1151. i:=R_NO;
  1152. end;
  1153. { convert [3,5,9]*EAX to EAX+[2,4,8]*EAX }
  1154. if (b=R_NO) and
  1155. (((s=2) and (i<>R_ESP)) or
  1156. (s=3) or (s=5) or (s=9)) then
  1157. begin
  1158. b:=i;
  1159. dec(s);
  1160. end;
  1161. { swap ESP into base if scalefactor is 1 }
  1162. if (s=1) and (i=R_ESP) then
  1163. begin
  1164. i:=b;
  1165. b:=R_ESP;
  1166. end;
  1167. {$endif OPTEA}
  1168. { wrong, for various reasons }
  1169. if (i=R_ESP) or ((s<>1) and (s<>2) and (s<>4) and (s<>8) and (i<>R_NO)) then
  1170. exit;
  1171. { base }
  1172. case b of
  1173. R_EAX : base:=0;
  1174. R_ECX : base:=1;
  1175. R_EDX : base:=2;
  1176. R_EBX : base:=3;
  1177. R_ESP : base:=4;
  1178. R_NO,
  1179. R_EBP : base:=5;
  1180. R_ESI : base:=6;
  1181. R_EDI : base:=7;
  1182. else
  1183. exit;
  1184. end;
  1185. { index }
  1186. case i of
  1187. R_EAX : index:=0;
  1188. R_ECX : index:=1;
  1189. R_EDX : index:=2;
  1190. R_EBX : index:=3;
  1191. R_NO : index:=4;
  1192. R_EBP : index:=5;
  1193. R_ESI : index:=6;
  1194. R_EDI : index:=7;
  1195. else
  1196. exit;
  1197. end;
  1198. case s of
  1199. 0,
  1200. 1 : scalefactor:=0;
  1201. 2 : scalefactor:=1;
  1202. 4 : scalefactor:=2;
  1203. 8 : scalefactor:=3;
  1204. else
  1205. exit;
  1206. end;
  1207. if (b=R_NO) or
  1208. ((b<>R_EBP) and (o=0) and (sym=nil)) then
  1209. md:=0
  1210. else
  1211. if ((o>=-128) and (o<=127) and (sym=nil)) then
  1212. md:=1
  1213. else
  1214. md:=2;
  1215. if (b=R_NO) or (md=2) then
  1216. output.bytes:=4
  1217. else
  1218. output.bytes:=md;
  1219. { SIB needed ? }
  1220. if (i=R_NO) and (b<>R_ESP) then
  1221. begin
  1222. output.sib_present:=false;
  1223. output.modrm:=(md shl 6) or (rfield shl 3) or base;
  1224. end
  1225. else
  1226. begin
  1227. output.sib_present:=true;
  1228. output.modrm:=(md shl 6) or (rfield shl 3) or 4;
  1229. output.sib:=(scalefactor shl 6) or (index shl 3) or base;
  1230. end;
  1231. end;
  1232. if output.sib_present then
  1233. output.size:=2+output.bytes
  1234. else
  1235. output.size:=1+output.bytes;
  1236. process_ea:=true;
  1237. end;
  1238. function taicpu.calcsize(p:PInsEntry):longint;
  1239. var
  1240. codes : pchar;
  1241. c : byte;
  1242. len : longint;
  1243. ea_data : ea;
  1244. begin
  1245. len:=0;
  1246. codes:=@p^.code;
  1247. repeat
  1248. c:=ord(codes^);
  1249. inc(codes);
  1250. case c of
  1251. 0 :
  1252. break;
  1253. 1,2,3 :
  1254. begin
  1255. inc(codes,c);
  1256. inc(len,c);
  1257. end;
  1258. 8,9,10 :
  1259. begin
  1260. inc(codes);
  1261. inc(len);
  1262. end;
  1263. 4,5,6,7 :
  1264. begin
  1265. if opsize=S_W then
  1266. inc(len,2)
  1267. else
  1268. inc(len);
  1269. end;
  1270. 15,
  1271. 12,13,14,
  1272. 16,17,18,
  1273. 20,21,22,
  1274. 40,41,42 :
  1275. inc(len);
  1276. 24,25,26,
  1277. 31,
  1278. 48,49,50 :
  1279. inc(len,2);
  1280. 28,29,30, { we don't have 16 bit immediates code }
  1281. 32,33,34,
  1282. 52,53,54,
  1283. 56,57,58 :
  1284. inc(len,4);
  1285. 192,193,194 :
  1286. if NeedAddrPrefix(c-192) then
  1287. inc(len);
  1288. 208 :
  1289. inc(len);
  1290. 200,
  1291. 201,
  1292. 202,
  1293. 209,
  1294. 210,
  1295. 217,218,219 : ;
  1296. 216 :
  1297. begin
  1298. inc(codes);
  1299. inc(len);
  1300. end;
  1301. 224,225,226 :
  1302. begin
  1303. InternalError(777002);
  1304. end;
  1305. else
  1306. begin
  1307. if (c>=64) and (c<=191) then
  1308. begin
  1309. if not process_ea(oper[(c shr 3) and 7], ea_data, 0) then
  1310. Message(asmw_e_invalid_effective_address)
  1311. else
  1312. inc(len,ea_data.size);
  1313. end
  1314. else
  1315. InternalError(777003);
  1316. end;
  1317. end;
  1318. until false;
  1319. calcsize:=len;
  1320. end;
  1321. procedure taicpu.GenCode(sec:TAsmObjectData);
  1322. {
  1323. * the actual codes (C syntax, i.e. octal):
  1324. * \0 - terminates the code. (Unless it's a literal of course.)
  1325. * \1, \2, \3 - that many literal bytes follow in the code stream
  1326. * \4, \6 - the POP/PUSH (respectively) codes for CS, DS, ES, SS
  1327. * (POP is never used for CS) depending on operand 0
  1328. * \5, \7 - the second byte of POP/PUSH codes for FS, GS, depending
  1329. * on operand 0
  1330. * \10, \11, \12 - a literal byte follows in the code stream, to be added
  1331. * to the register value of operand 0, 1 or 2
  1332. * \17 - encodes the literal byte 0. (Some compilers don't take
  1333. * kindly to a zero byte in the _middle_ of a compile time
  1334. * string constant, so I had to put this hack in.)
  1335. * \14, \15, \16 - a signed byte immediate operand, from operand 0, 1 or 2
  1336. * \20, \21, \22 - a byte immediate operand, from operand 0, 1 or 2
  1337. * \24, \25, \26 - an unsigned byte immediate operand, from operand 0, 1 or 2
  1338. * \30, \31, \32 - a word immediate operand, from operand 0, 1 or 2
  1339. * \34, \35, \36 - select between \3[012] and \4[012] depending on 16/32 bit
  1340. * assembly mode or the address-size override on the operand
  1341. * \37 - a word constant, from the _segment_ part of operand 0
  1342. * \40, \41, \42 - a long immediate operand, from operand 0, 1 or 2
  1343. * \50, \51, \52 - a byte relative operand, from operand 0, 1 or 2
  1344. * \60, \61, \62 - a word relative operand, from operand 0, 1 or 2
  1345. * \64, \65, \66 - select between \6[012] and \7[012] depending on 16/32 bit
  1346. * assembly mode or the address-size override on the operand
  1347. * \70, \71, \72 - a long relative operand, from operand 0, 1 or 2
  1348. * \1ab - a ModRM, calculated on EA in operand a, with the spare
  1349. * field the register value of operand b.
  1350. * \2ab - a ModRM, calculated on EA in operand a, with the spare
  1351. * field equal to digit b.
  1352. * \30x - might be an 0x67 byte, depending on the address size of
  1353. * the memory reference in operand x.
  1354. * \310 - indicates fixed 16-bit address size, i.e. optional 0x67.
  1355. * \311 - indicates fixed 32-bit address size, i.e. optional 0x67.
  1356. * \320 - indicates fixed 16-bit operand size, i.e. optional 0x66.
  1357. * \321 - indicates fixed 32-bit operand size, i.e. optional 0x66.
  1358. * \322 - indicates that this instruction is only valid when the
  1359. * operand size is the default (instruction to disassembler,
  1360. * generates no code in the assembler)
  1361. * \330 - a literal byte follows in the code stream, to be added
  1362. * to the condition code value of the instruction.
  1363. * \340 - reserve <operand 0> bytes of uninitialised storage.
  1364. * Operand 0 had better be a segmentless constant.
  1365. }
  1366. var
  1367. currval : longint;
  1368. currsym : tasmsymbol;
  1369. procedure getvalsym(opidx:longint);
  1370. begin
  1371. case oper[opidx].typ of
  1372. top_ref :
  1373. begin
  1374. currval:=oper[opidx].ref^.offset+oper[opidx].ref^.offsetfixup;
  1375. currsym:=oper[opidx].ref^.symbol;
  1376. end;
  1377. top_const :
  1378. begin
  1379. currval:=longint(oper[opidx].val);
  1380. currsym:=nil;
  1381. end;
  1382. top_symbol :
  1383. begin
  1384. currval:=oper[opidx].symofs;
  1385. currsym:=oper[opidx].sym;
  1386. end;
  1387. else
  1388. Message(asmw_e_immediate_or_reference_expected);
  1389. end;
  1390. end;
  1391. const
  1392. CondVal:array[TAsmCond] of byte=($0,
  1393. $7, $3, $2, $6, $2, $4, $F, $D, $C, $E, $6, $2,
  1394. $3, $7, $3, $5, $E, $C, $D, $F, $1, $B, $9, $5,
  1395. $0, $A, $A, $B, $8, $4);
  1396. var
  1397. c : byte;
  1398. pb,
  1399. codes : pchar;
  1400. bytes : array[0..3] of byte;
  1401. rfield,
  1402. data,s,opidx : longint;
  1403. ea_data : ea;
  1404. begin
  1405. {$ifdef EXTDEBUG}
  1406. { safety check }
  1407. if sec.sects[sec.currsec].datasize<>insoffset then
  1408. internalerror(200130121);
  1409. {$endif EXTDEBUG}
  1410. { load data to write }
  1411. codes:=insentry^.code;
  1412. { Force word push/pop for registers }
  1413. if (opsize=S_W) and ((codes[0]=#4) or (codes[0]=#6) or
  1414. ((codes[0]=#1) and ((codes[2]=#5) or (codes[2]=#7)))) then
  1415. begin
  1416. bytes[0]:=$66;
  1417. sec.writebytes(bytes,1);
  1418. end;
  1419. repeat
  1420. c:=ord(codes^);
  1421. inc(codes);
  1422. case c of
  1423. 0 :
  1424. break;
  1425. 1,2,3 :
  1426. begin
  1427. sec.writebytes(codes^,c);
  1428. inc(codes,c);
  1429. end;
  1430. 4,6 :
  1431. begin
  1432. case oper[0].reg of
  1433. R_CS :
  1434. begin
  1435. if c=4 then
  1436. bytes[0]:=$f
  1437. else
  1438. bytes[0]:=$e;
  1439. end;
  1440. R_NO,
  1441. R_DS :
  1442. begin
  1443. if c=4 then
  1444. bytes[0]:=$1f
  1445. else
  1446. bytes[0]:=$1e;
  1447. end;
  1448. R_ES :
  1449. begin
  1450. if c=4 then
  1451. bytes[0]:=$7
  1452. else
  1453. bytes[0]:=$6;
  1454. end;
  1455. R_SS :
  1456. begin
  1457. if c=4 then
  1458. bytes[0]:=$17
  1459. else
  1460. bytes[0]:=$16;
  1461. end;
  1462. else
  1463. InternalError(777004);
  1464. end;
  1465. sec.writebytes(bytes,1);
  1466. end;
  1467. 5,7 :
  1468. begin
  1469. case oper[0].reg of
  1470. R_FS :
  1471. begin
  1472. if c=5 then
  1473. bytes[0]:=$a1
  1474. else
  1475. bytes[0]:=$a0;
  1476. end;
  1477. R_GS :
  1478. begin
  1479. if c=5 then
  1480. bytes[0]:=$a9
  1481. else
  1482. bytes[0]:=$a8;
  1483. end;
  1484. else
  1485. InternalError(777005);
  1486. end;
  1487. sec.writebytes(bytes,1);
  1488. end;
  1489. 8,9,10 :
  1490. begin
  1491. bytes[0]:=ord(codes^)+regval(oper[c-8].reg);
  1492. inc(codes);
  1493. sec.writebytes(bytes,1);
  1494. end;
  1495. 15 :
  1496. begin
  1497. bytes[0]:=0;
  1498. sec.writebytes(bytes,1);
  1499. end;
  1500. 12,13,14 :
  1501. begin
  1502. getvalsym(c-12);
  1503. if (currval<-128) or (currval>127) then
  1504. Message2(asmw_e_value_exceeds_bounds,'signed byte',tostr(currval));
  1505. if assigned(currsym) then
  1506. sec.writereloc(currval,1,currsym,RELOC_ABSOLUTE)
  1507. else
  1508. sec.writebytes(currval,1);
  1509. end;
  1510. 16,17,18 :
  1511. begin
  1512. getvalsym(c-16);
  1513. if (currval<-256) or (currval>255) then
  1514. Message2(asmw_e_value_exceeds_bounds,'byte',tostr(currval));
  1515. if assigned(currsym) then
  1516. sec.writereloc(currval,1,currsym,RELOC_ABSOLUTE)
  1517. else
  1518. sec.writebytes(currval,1);
  1519. end;
  1520. 20,21,22 :
  1521. begin
  1522. getvalsym(c-20);
  1523. if (currval<0) or (currval>255) then
  1524. Message2(asmw_e_value_exceeds_bounds,'unsigned byte',tostr(currval));
  1525. if assigned(currsym) then
  1526. sec.writereloc(currval,1,currsym,RELOC_ABSOLUTE)
  1527. else
  1528. sec.writebytes(currval,1);
  1529. end;
  1530. 24,25,26 :
  1531. begin
  1532. getvalsym(c-24);
  1533. if (currval<-65536) or (currval>65535) then
  1534. Message2(asmw_e_value_exceeds_bounds,'word',tostr(currval));
  1535. if assigned(currsym) then
  1536. sec.writereloc(currval,2,currsym,RELOC_ABSOLUTE)
  1537. else
  1538. sec.writebytes(currval,2);
  1539. end;
  1540. 28,29,30 :
  1541. begin
  1542. getvalsym(c-28);
  1543. if assigned(currsym) then
  1544. sec.writereloc(currval,4,currsym,RELOC_ABSOLUTE)
  1545. else
  1546. sec.writebytes(currval,4);
  1547. end;
  1548. 32,33,34 :
  1549. begin
  1550. getvalsym(c-32);
  1551. if assigned(currsym) then
  1552. sec.writereloc(currval,4,currsym,RELOC_ABSOLUTE)
  1553. else
  1554. sec.writebytes(currval,4);
  1555. end;
  1556. 40,41,42 :
  1557. begin
  1558. getvalsym(c-40);
  1559. data:=currval-insend;
  1560. if assigned(currsym) then
  1561. inc(data,currsym.address);
  1562. if (data>127) or (data<-128) then
  1563. Message1(asmw_e_short_jmp_out_of_range,tostr(data));
  1564. sec.writebytes(data,1);
  1565. end;
  1566. 52,53,54 :
  1567. begin
  1568. getvalsym(c-52);
  1569. if assigned(currsym) then
  1570. sec.writereloc(currval,4,currsym,RELOC_RELATIVE)
  1571. else
  1572. sec.writereloc(currval-insend,4,nil,RELOC_ABSOLUTE)
  1573. end;
  1574. 56,57,58 :
  1575. begin
  1576. getvalsym(c-56);
  1577. if assigned(currsym) then
  1578. sec.writereloc(currval,4,currsym,RELOC_RELATIVE)
  1579. else
  1580. sec.writereloc(currval-insend,4,nil,RELOC_ABSOLUTE)
  1581. end;
  1582. 192,193,194 :
  1583. begin
  1584. if NeedAddrPrefix(c-192) then
  1585. begin
  1586. bytes[0]:=$67;
  1587. sec.writebytes(bytes,1);
  1588. end;
  1589. end;
  1590. 200 :
  1591. begin
  1592. bytes[0]:=$67;
  1593. sec.writebytes(bytes,1);
  1594. end;
  1595. 208 :
  1596. begin
  1597. bytes[0]:=$66;
  1598. sec.writebytes(bytes,1);
  1599. end;
  1600. 216 :
  1601. begin
  1602. bytes[0]:=ord(codes^)+condval[condition];
  1603. inc(codes);
  1604. sec.writebytes(bytes,1);
  1605. end;
  1606. 201,
  1607. 202,
  1608. 209,
  1609. 210,
  1610. 217,218,219 :
  1611. begin
  1612. { these are dissambler hints or 32 bit prefixes which
  1613. are not needed }
  1614. end;
  1615. 31,
  1616. 48,49,50,
  1617. 224,225,226 :
  1618. begin
  1619. InternalError(777006);
  1620. end
  1621. else
  1622. begin
  1623. if (c>=64) and (c<=191) then
  1624. begin
  1625. if (c<127) then
  1626. begin
  1627. if (oper[c and 7].typ=top_reg) then
  1628. rfield:=regval(oper[c and 7].reg)
  1629. else
  1630. rfield:=regval(oper[c and 7].ref^.base);
  1631. end
  1632. else
  1633. rfield:=c and 7;
  1634. opidx:=(c shr 3) and 7;
  1635. if not process_ea(oper[opidx], ea_data, rfield) then
  1636. Message(asmw_e_invalid_effective_address);
  1637. pb:=@bytes;
  1638. pb^:=chr(ea_data.modrm);
  1639. inc(pb);
  1640. if ea_data.sib_present then
  1641. begin
  1642. pb^:=chr(ea_data.sib);
  1643. inc(pb);
  1644. end;
  1645. s:=pb-pchar(@bytes);
  1646. sec.writebytes(bytes,s);
  1647. case ea_data.bytes of
  1648. 0 : ;
  1649. 1 :
  1650. begin
  1651. if (oper[opidx].ot and OT_MEMORY)=OT_MEMORY then
  1652. sec.writereloc(oper[opidx].ref^.offset+oper[opidx].ref^.offsetfixup,1,oper[opidx].ref^.symbol,RELOC_ABSOLUTE)
  1653. else
  1654. begin
  1655. bytes[0]:=oper[opidx].ref^.offset+oper[opidx].ref^.offsetfixup;
  1656. sec.writebytes(bytes,1);
  1657. end;
  1658. inc(s);
  1659. end;
  1660. 2,4 :
  1661. begin
  1662. sec.writereloc(oper[opidx].ref^.offset+oper[opidx].ref^.offsetfixup,ea_data.bytes,
  1663. oper[opidx].ref^.symbol,RELOC_ABSOLUTE);
  1664. inc(s,ea_data.bytes);
  1665. end;
  1666. end;
  1667. end
  1668. else
  1669. InternalError(777007);
  1670. end;
  1671. end;
  1672. until false;
  1673. end;
  1674. {$endif NOAG386BIN}
  1675. {*****************************************************************************
  1676. Instruction table
  1677. *****************************************************************************}
  1678. procedure BuildInsTabCache;
  1679. {$ifndef NOAG386BIN}
  1680. var
  1681. i : longint;
  1682. {$endif}
  1683. begin
  1684. {$ifndef NOAG386BIN}
  1685. new(instabcache);
  1686. FillChar(instabcache^,sizeof(tinstabcache),$ff);
  1687. i:=0;
  1688. while (i<InsTabEntries) do
  1689. begin
  1690. if InsTabCache^[InsTab[i].OPcode]=-1 then
  1691. InsTabCache^[InsTab[i].OPcode]:=i;
  1692. inc(i);
  1693. end;
  1694. {$endif NOAG386BIN}
  1695. end;
  1696. procedure InitAsm;
  1697. begin
  1698. {$ifndef NOAG386BIN}
  1699. if not assigned(instabcache) then
  1700. BuildInsTabCache;
  1701. {$endif NOAG386BIN}
  1702. end;
  1703. procedure DoneAsm;
  1704. begin
  1705. {$ifndef NOAG386BIN}
  1706. if assigned(instabcache) then
  1707. dispose(instabcache);
  1708. {$endif NOAG386BIN}
  1709. end;
  1710. end.
  1711. {
  1712. $Log$
  1713. Revision 1.7 2002-11-15 01:58:54 peter
  1714. * merged changes from 1.0.7 up to 04-11
  1715. - -V option for generating bug report tracing
  1716. - more tracing for option parsing
  1717. - errors for cdecl and high()
  1718. - win32 import stabs
  1719. - win32 records<=8 are returned in eax:edx (turned off by default)
  1720. - heaptrc update
  1721. - more info for temp management in .s file with EXTDEBUG
  1722. Revision 1.6 2002/10/31 13:28:32 pierre
  1723. * correct last wrong fix for tw2158
  1724. Revision 1.5 2002/10/30 17:10:00 pierre
  1725. * merge of fix for tw2158 bug
  1726. Revision 1.4 2002/08/15 19:10:36 peter
  1727. * first things tai,tnode storing in ppu
  1728. Revision 1.3 2002/08/13 18:01:52 carl
  1729. * rename swatoperands to swapoperands
  1730. + m68k first compilable version (still needs a lot of testing):
  1731. assembler generator, system information , inline
  1732. assembler reader.
  1733. Revision 1.2 2002/07/20 11:57:59 florian
  1734. * types.pas renamed to defbase.pas because D6 contains a types
  1735. unit so this would conflicts if D6 programms are compiled
  1736. + Willamette/SSE2 instructions to assembler added
  1737. Revision 1.1 2002/07/01 18:46:29 peter
  1738. * internal linker
  1739. * reorganized aasm layer
  1740. }