cpubase.pas 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl, Carl Eric Codere
  4. This unit implements an types and classes specific for the
  5. MC68000/MC68020
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. ****************************************************************************
  18. }
  19. unit cpubase;
  20. interface
  21. uses
  22. cobjects,aasm,globtype;
  23. const
  24. { if real fpu is used }
  25. { otherwise maps to }
  26. { s32real. }
  27. extended_size = 12;
  28. type
  29. { warning: CPU32 opcodes are not fully compatible with the MC68020. }
  30. { 68000 only opcodes }
  31. tasmop = (A_ABCD,
  32. A_ADD,A_ADDA,A_ADDI,A_ADDQ,A_ADDX,A_AND,A_ANDI,
  33. A_ASL,A_ASR,A_BCC,A_BCS,A_BEQ,A_BGE,A_BGT,A_BHI,
  34. A_BLE,A_BLS,A_BLT,A_BMI,A_BNE,A_BPL,A_BVC,A_BVS,
  35. A_BCHG,A_BCLR,A_BRA,A_BSET,A_BSR,A_BTST,A_CHK,
  36. A_CLR,A_CMP,A_CMPA,A_CMPI,A_CMPM,A_DBCC,A_DBCS,A_DBEQ,A_DBGE,
  37. A_DBGT,A_DBHI,A_DBLE,A_DBLS,A_DBLT,A_DBMI,A_DBNE,A_DBRA,
  38. A_DBPL,A_DBT,A_DBVC,A_DBVS,A_DBF,A_DIVS,A_DIVU,
  39. A_EOR,A_EORI,A_EXG,A_ILLEGAL,A_EXT,A_JMP,A_JSR,
  40. A_LEA,A_LINK,A_LSL,A_LSR,A_MOVE,A_MOVEA,A_MOVEI,A_MOVEQ,
  41. A_MOVEM,A_MOVEP,A_MULS,A_MULU,A_NBCD,A_NEG,A_NEGX,
  42. A_NOP,A_NOT,A_OR,A_ORI,A_PEA,A_ROL,A_ROR,A_ROXL,
  43. A_ROXR,A_RTR,A_RTS,A_SBCD,A_SCC,A_SCS,A_SEQ,A_SGE,
  44. A_SGT,A_SHI,A_SLE,A_SLS,A_SLT,A_SMI,A_SNE,
  45. A_SPL,A_ST,A_SVC,A_SVS,A_SF,A_SUB,A_SUBA,A_SUBI,A_SUBQ,
  46. A_SUBX,A_SWAP,A_TAS,A_TRAP,A_TRAPV,A_TST,A_UNLK,
  47. A_RTE,A_RESET,A_STOP,
  48. { MC68010 instructions }
  49. A_BKPT,A_MOVEC,A_MOVES,A_RTD,
  50. { MC68020 instructions }
  51. A_BFCHG,A_BFCLR,A_BFEXTS,A_BFEXTU,A_BFFFO,
  52. A_BFINS,A_BFSET,A_BFTST,A_CALLM,A_CAS,A_CAS2,
  53. A_CHK2,A_CMP2,A_DIVSL,A_DIVUL,A_EXTB,A_PACK,A_RTM,
  54. A_TRAPCC,A_TRACS,A_TRAPEQ,A_TRAPF,A_TRAPGE,A_TRAPGT,
  55. A_TRAPHI,A_TRAPLE,A_TRAPLS,A_TRAPLT,A_TRAPMI,A_TRAPNE,
  56. A_TRAPPL,A_TRAPT,A_TRAPVC,A_TRAPVS,A_UNPK,
  57. { FPU Processor instructions - directly supported only. }
  58. { IEEE aware and misc. condition codes not supported }
  59. A_FABS,A_FADD,
  60. A_FBEQ,A_FBNE,A_FBNGT,A_FBGT,A_FBGE,A_FBNGE,
  61. A_FBLT,A_FBNLT,A_FBLE,A_FBGL,A_FBNGL,A_FBGLE,A_FBNGLE,
  62. A_FDBEQ,A_FDBNE,A_FDBGT,A_FDBNGT,A_FDBGE,A_FDBNGE,
  63. A_FDBLT,A_FDBNLT,A_FDBLE,A_FDBGL,A_FDBNGL,A_FDBGLE,A_FBDNGLE,
  64. A_FSEQ,A_FSNE,A_FSGT,A_FSNGT,A_FSGE,A_FSNGE,
  65. A_FSLT,A_FSNLT,A_FSLE,A_FSGL,A_FSNGL,A_FSGLE,A_FSNGLE,
  66. A_FCMP,A_FDIV,A_FMOVE,A_FMOVEM,
  67. A_FMUL,A_FNEG,A_FNOP,A_FSQRT,A_FSUB,A_FSGLDIV,
  68. A_FSFLMUL,A_FTST,
  69. A_FTRAPEQ,A_FTRAPNE,A_FTRAPGT,A_FTRAPNGT,A_FTRAPGE,A_FTRAPNGE,
  70. A_FTRAPLT,A_FTRAPNLT,A_FTRAPLE,A_FTRAPGL,A_FTRAPNGL,A_FTRAPGLE,A_FTRAPNGLE,
  71. { Protected instructions }
  72. A_CPRESTORE,A_CPSAVE,
  73. { FPU Unit protected instructions }
  74. { and 68030/68851 common MMU instructions }
  75. { (this may include 68040 MMU instructions) }
  76. A_FRESTORE,A_FSAVE,A_PFLUSH,A_PFLUSHA,A_PLOAD,A_PMOVE,A_PTEST,
  77. { Useful for assembly langage output }
  78. A_LABEL,A_NONE);
  79. { enumeration for registers, don't change the }
  80. { order of this table }
  81. { Registers which can and will be used by the compiler }
  82. tregister = (
  83. R_NO,R_D0,R_D1,R_D2,R_D3,R_D4,R_D5,R_D6,R_D7,
  84. R_A0,R_A1,R_A2,R_A3,R_A4,R_A5,R_A6,R_SP,
  85. { PUSH/PULL- quick and dirty hack }
  86. R_SPPUSH,R_SPPULL,
  87. { misc. }
  88. R_CCR,R_FP0,R_FP1,R_FP2,R_FP3,R_FP4,R_FP5,R_FP6,
  89. R_FP7,R_FPCR,R_SR,R_SSP,R_DFC,R_SFC,R_VBR,R_FPSR,
  90. { other - not used in reg2str }
  91. R_DEFAULT_SEG);
  92. { S_NO = No Size of operand }
  93. { S_B = Byte size operand }
  94. { S_W = Word size operand }
  95. { S_L = DWord size operand }
  96. { USED FOR conversions in x86}
  97. { S_BW = Byte to word }
  98. { S_BL = Byte to long }
  99. { S_WL = Word to long }
  100. { Floating point types }
  101. { S_FS = single type (32 bit) }
  102. { S_FL = double/64bit integer }
  103. { S_FX = Extended type }
  104. { S_IS = integer on 16 bits }
  105. { S_IL = integer on 32 bits }
  106. { S_IQ = integer on 64 bits }
  107. topsize = (S_NO,S_B,S_W,S_L,S_BW,S_BL,S_WL,
  108. S_FS,S_FL,S_FX,S_IS,S_IL,S_IQ);
  109. plocation = ^tlocation;
  110. { information about the location of an operand }
  111. { LOC_FPU FPU registers = Dn if emulation }
  112. { LOC_REGISTER in a processor register }
  113. { LOC_MEM in the memory }
  114. { LOC_REFERENCE like LOC_MEM, but lvalue }
  115. { LOC_JUMP nur bool'sche Resultate, Sprung zu false- oder }
  116. { truelabel }
  117. { LOC_FLAGS nur bool'sche Rsultate, Flags sind gesetzt }
  118. { LOC_CREGISTER register which shouldn't be modified }
  119. { LOC_INVALID added for tracking problems}
  120. tloc = (LOC_INVALID,LOC_FPU,LOC_REGISTER,LOC_MEM,LOC_REFERENCE,LOC_JUMP,
  121. LOC_FLAGS,LOC_CREGISTER);
  122. tregisterlist = set of tregister;
  123. { F_E = Equal
  124. F_NE = Not Equal
  125. F_G = Greater then
  126. F_L = Less then
  127. F_GE = Greater or equal then
  128. F_LE = Less or equal then
  129. F_C = Carry
  130. F_NC = Not Carry
  131. F_A = Above
  132. F_AE = Above or Equal
  133. F_B = Below
  134. F_BE = Below or Equal
  135. other flags:
  136. FL_xxx = floating type flags .
  137. }
  138. tresflags = (F_E,F_NE,F_G,F_L,F_GE,F_LE,F_C,F_NC,
  139. F_A,F_AE,F_B,F_BE);
  140. { floating type flags used by FBCC are auotmatically converted }
  141. { to standard condition codes }
  142. { FL_E,FL_NE,FL_A,FL_AE,FL_B,FL_BE);}
  143. preference = ^treference;
  144. { direction of address register : }
  145. { (An) (An)+ -(An) }
  146. tdirection = (dir_none,dir_inc,dir_dec);
  147. treference = record
  148. base,segment,index : tregister;
  149. offset : longint;
  150. symbol : pstring;
  151. { indexed increment and decrement mode }
  152. { (An)+ and -(An) }
  153. direction : tdirection;
  154. { a constant is also a treference, this makes the code generator }
  155. { easier }
  156. isintvalue : boolean;
  157. scalefactor : byte;
  158. end;
  159. tlocation = record
  160. case loc : tloc of
  161. { segment in reference at the same place as in loc_register }
  162. LOC_REGISTER,LOC_CREGISTER : (register,segment : tregister);
  163. LOC_MEM,LOC_REFERENCE : (reference : treference);
  164. LOC_FPU : (fpureg:tregister);
  165. LOC_JUMP : ();
  166. LOC_FLAGS : (resflags : tresflags);
  167. LOC_INVALID : ();
  168. end;
  169. pcsymbol = ^tcsymbol;
  170. tcsymbol = record
  171. symbol : pchar;
  172. offset : longint;
  173. end;
  174. const
  175. {----------------------------------------------------------------------}
  176. { F_E = Equal }
  177. { F_NE = Not Equal }
  178. { F_G = Greater then }
  179. { F_L = Less then }
  180. { F_GE = Greater or equal then }
  181. { F_LE = Less or equal then }
  182. { F_C = Carry = C }
  183. { F_NC = Not Carry = not C }
  184. { F_A = Above = not C and not Z }
  185. { F_AE = Above or Equal = not C }
  186. { F_B = Below = C }
  187. { F_BE = Below or Equal = C or Z }
  188. { FL_E = Floating point equal = Z }
  189. { FL_NE = Floating point Not equal = not Z }
  190. { FL_A = Floating point above = }
  191. { FL_AE = Floating point above or equal = }
  192. { FL_B = Floating point below = }
  193. { FL_BE = Floating point below or equal = }
  194. { THE ORDER OF THIS TABLE SHOULD NOT BE CHANGED! }
  195. flag_2_jmp: array[F_E..F_BE] of tasmop =
  196. (A_BEQ,A_BNE,A_BGT,A_BLT,A_BGE,A_BLE,A_BCS,A_BCC,
  197. A_BHI,A_BCC,A_BCS,A_BLS);
  198. { floating point jumps - CURRENTLY NOT USED }
  199. { A_FBEQ,A_FBNE,A_FBGT,A_FBGE,A_FBLT,A_FBLE); }
  200. { don't change the order of this table, it is related to }
  201. { the flags table. }
  202. flag_2_set: array[F_E..F_BE] of tasmop =
  203. (A_SEQ,A_SNE,A_SGT,A_SLT,A_SGE,A_SLE,A_SCS,A_SCC,
  204. A_SHI,A_SCC,A_SCS,A_SLS);
  205. { operand types }
  206. top_none = 0;
  207. top_reg = 1;
  208. top_ref = 2;
  209. top_reglist = 5;
  210. { a constant can be also written as treference }
  211. top_const = 3;
  212. { this is for calls }
  213. top_symbol = 4;
  214. {This constant is an alias for the stack pointer, as it's name may
  215. differ from processor to processor.}
  216. stack_pointer_reg = R_SP;
  217. frame_pointer_reg = R_A6;
  218. {This constant is an alias for the accumulator, as it's name may
  219. differ from processor to processor.}
  220. accumulator = R_D0;
  221. type
  222. pai_labeled = ^tai_labeled;
  223. tai_labeled = object(tai)
  224. _operator : tasmop;
  225. _op1: tregister;
  226. lab : pasmlabel;
  227. constructor init(op : tasmop; l : pasmlabel);
  228. constructor init_reg(op: tasmop; l : pasmlabel; reg: tregister);
  229. destructor done;virtual;
  230. end;
  231. paicpu = ^taicpu;
  232. taicpu = object(tai)
  233. { this isn't a proper style, but not very memory expensive }
  234. op1,op2,op3 : pointer;
  235. _operator : tasmop;
  236. op1t,op2t,op3t : byte;
  237. size : topsize;
  238. reglist: set of tregister;
  239. constructor op_none(op : tasmop;_size : topsize);
  240. constructor op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  241. constructor op_const(op : tasmop;_size : topsize;_op1 : longint);
  242. constructor op_ref(op : tasmop;_size : topsize;_op1 : preference);
  243. constructor op_loc(op : tasmop;_size : topsize;_op1 : tlocation);
  244. constructor op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  245. constructor op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : preference);
  246. constructor op_reg_loc(op : tasmop;_size : topsize;_op1 : tregister;_op2 : tlocation);
  247. constructor op_loc_reg(op : tasmop;_size : topsize;_op1 : tlocation;_op2 : tregister);
  248. constructor op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  249. { this combination is needed by ENTER }
  250. constructor op_const_const(op : tasmop;_size : topsize;_op1,_op2 : longint);
  251. constructor op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference);
  252. constructor op_const_loc(op : tasmop;_size : topsize;_op1 : longint;_op2 : tlocation);
  253. constructor op_ref_reg(op : tasmop;_size : topsize;_op1 : preference;_op2 : tregister);
  254. { this is only allowed if _op1 is an int value (_op1^.isintvalue=true) }
  255. constructor op_ref_ref(op : tasmop;_size : topsize;_op1,_op2 : preference);
  256. {
  257. constructor op_ref_loc(op : tasmop;_size : topsize;_op1 : preference;_op2 : tlcation);}
  258. constructor op_const_reg_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : tregister);
  259. { used by MC68020 mul/div }
  260. constructor op_reg_reg_Reg(op: tasmop;_size: topsize;_op1: tregister; _op2: tregister; _op3: tregister);
  261. { used by link }
  262. constructor op_reg_const(op: tasmop; _size: topsize; _op1: tregister; _op2: longint);
  263. { this is for CALL etc. }
  264. { symbol is replaced by the address of symbol }
  265. { so op_csymbol(A_PUSH,S_L,strnew('P')); generates }
  266. { an instruction which pushes the address of P }
  267. { to the stack }
  268. constructor op_csymbol(op : tasmop;_size : topsize;_op1 : pcsymbol);
  269. constructor op_csymbol_reg(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : tregister);
  270. constructor op_csymbol_ref(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : preference);
  271. constructor op_csymbol_loc(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : tlocation);
  272. constructor op_ref_reglist(op: tasmop; _size : topsize; _op1: preference;_op2: tregisterlist);
  273. constructor op_reglist_ref(op: tasmop; _size : topsize; _op1: tregisterlist; _op2: preference);
  274. destructor done;virtual;
  275. end;
  276. const
  277. maxvarregs = 5;
  278. maxfpuvarregs = 8;
  279. varregs : array[1..maxvarregs] of tregister =
  280. (R_D2,R_D3,R_D4,R_D5,R_D7);
  281. fpuvarregs : array[1..maxfpuvarregs] of tregister =
  282. (R_FP0,R_FP1,R_FP2,R_FP3,R_FP4,R_FP5,R_FP6,
  283. R_FP7);
  284. { resets all values of ref to defaults }
  285. procedure reset_reference(var ref : treference);
  286. { set mostly used values of a new reference }
  287. function new_reference(base : tregister;offset : longint) : preference;
  288. { same as reset_reference, but symbol is disposed }
  289. { use this only for already used references }
  290. procedure clear_reference(var ref : treference);
  291. procedure disposereference(var r : preference);
  292. function newreference(const r : treference) : preference;
  293. { generates an help record for constants }
  294. function newcsymbol(const s : string;l : longint) : pcsymbol;
  295. const
  296. ao_unknown = $0;
  297. { 8 bit reg }
  298. ao_reg8 = $1;
  299. { 16 bit reg }
  300. ao_reg16 = $2;
  301. { 32 bit reg }
  302. ao_reg32 = $4;
  303. ao_reg = (ao_reg8 or ao_reg16 or ao_reg32);
  304. { for push/pop operands }
  305. ao_wordreg = (ao_reg16 or ao_reg32);
  306. ao_imm8 = $8; { 8 bit immediate }
  307. ao_imm8S = $10; { 8 bit immediate sign extended }
  308. ao_imm16 = $20; { 16 bit immediate }
  309. ao_imm32 = $40; { 32 bit immediate }
  310. ao_imm1 = $80; { 1 bit immediate }
  311. { for unknown expressions }
  312. ao_immunknown = ao_imm32;
  313. { gen'l immediate }
  314. ao_imm = (ao_imm8 or ao_imm8S or ao_imm16 or ao_imm32);
  315. ao_disp8 = $200; { 8 bit displacement (for jumps) }
  316. ao_disp16 = $400; { 16 bit displacement }
  317. ao_disp32 = $800; { 32 bit displacement }
  318. { general displacement }
  319. ao_disp = (ao_disp8 or ao_disp16 or ao_disp32);
  320. { for unknown size displacements }
  321. ao_dispunknown = ao_disp32;
  322. ao_mem8 = $1000;
  323. ao_mem16 = $2000;
  324. ao_mem32 = $4000;
  325. ao_baseindex = $8000;
  326. { general mem }
  327. ao_mem = (ao_disp or ao_mem8 or ao_mem16 or ao_mem32 or ao_baseindex);
  328. ao_wordmem = (ao_mem16 or ao_mem32 or ao_disp or ao_baseindex);
  329. ao_bytemem = (ao_mem8 or ao_disp or ao_baseindex);
  330. ao_control = $40000; { Control register }
  331. ao_debug = $80000; { Debug register }
  332. ao_test = $100000; { Test register }
  333. ao_floatreg = $200000; { Float register }
  334. ao_jumpabsolute = $4000000;
  335. ao_abs8 = $08000000;
  336. ao_abs16 = $10000000;
  337. ao_abs32 = $20000000;
  338. ao_abs = (ao_abs8 or ao_abs16 or ao_abs32);
  339. ao_none = $ff;
  340. const
  341. AB_DN = 1;
  342. AB_AN = 2;
  343. AB_INDAN = 3;
  344. AB_INDPP = 4;
  345. AB_MMIND = 5;
  346. AB_OFFAN = 6;
  347. AB_OFFIDX = 7;
  348. AB_ABSW = 8;
  349. AB_ABSL = 9;
  350. AB_OFFPC = 10;
  351. AB_OFFIDXPC =11;
  352. AB_IMM =12;
  353. AB_REGS =13; {* movem *}
  354. AB_BBRANCH =14;
  355. AB_WBRANCH =15;
  356. AB_CCR =16;
  357. AB_SR =17;
  358. AB_USP =18;
  359. AB_MULDREGS =19;
  360. AB_MULDREGU =20;
  361. AF_DN =(1 SHL AB_DN);
  362. AF_AN =(1 SHL AB_AN);
  363. AF_INDAN = (1 SHL AB_INDAN);
  364. AF_INDPP = (1 SHL AB_INDPP);
  365. AF_MMIND = (1 SHL AB_MMIND);
  366. AF_OFFAN = (1 SHL AB_OFFAN);
  367. AF_OFFIDX = (1 SHL AB_OFFIDX);
  368. AF_ABSW = (1 SHL AB_ABSW);
  369. AF_ABSL = (1 SHL AB_ABSL);
  370. AF_OFFPC = (1 SHL AB_OFFPC);
  371. AF_OFFIDXPC= (1 SHL AB_OFFIDXPC);
  372. AF_IMM =(1 SHL AB_IMM);
  373. AF_REGS = (1 SHL AB_REGS);
  374. AF_BBRANCH = (1 SHL AB_BBRANCH);
  375. AF_WBRANCH = (1 SHL AB_WBRANCH);
  376. AF_CCR =(1 SHL AB_CCR);
  377. AF_SR =(1 SHL AB_SR);
  378. AF_USP =(1 SHL AB_USP);
  379. AF_MULDREGS= (1 SHL AB_MULDREGS);
  380. AF_MULDREGU= (1 SHL AB_MULDREGU);
  381. AF_ALL = AF_DN OR AF_AN OR AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR
  382. AF_ABSL OR AF_OFFPC OR AF_OFFIDXPC OR AF_IMM;
  383. AF_ALLNA = AF_DN OR AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL
  384. OR AF_OFFPC OR AF_OFFIDXPC OR AF_IMM;
  385. AF_ALT = AF_DN OR AF_AN OR AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR
  386. AF_OFFIDX OR AF_ABSW OR AF_ABSL;
  387. AF_ALTNA = AF_DN OR AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL;
  388. AF_ALTM = AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL;
  389. AF_CTL = AF_INDAN OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL OR AF_OFFPC OR AF_OFFIDXPC;
  390. AF_CTLNPC = AF_INDAN OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL OR AF_OFFIDXPC;
  391. { S_WL (S_W|S_L)
  392. S_BW (S_B|S_W)}
  393. const
  394. S_ALL = [S_B] + [S_W] + [S_L];
  395. {#define S_ALL (S_B|S_W|S_L)}
  396. type
  397. ttemplate = record
  398. i : tasmop;
  399. oc : longint;
  400. ops : byte;
  401. size: set of topsize;
  402. o1,o2: longint;
  403. end;
  404. tins_cache = array[A_ABCD..A_UNLK] of longint;
  405. var
  406. ins_cache : tins_cache;
  407. const
  408. it : array[0..188] of ttemplate = (
  409. ( i:A_ABCD; oc: $C100; ops:2;size: [S_B]; o1:AF_DN; o2:AF_DN ),
  410. ( i:A_ABCD; oc: $C108; ops:2;size: [S_B]; o1:AF_MMIND; o2:AF_MMIND ),
  411. ( i:A_ADD; oc: $D000; ops:2;size: S_ALL; o1:AF_ALL; o2:AF_DN ),
  412. ( i:A_ADD; oc: $D100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTM ),
  413. ( i:A_ADD; oc: $D0C0; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  414. ( i:A_ADD; oc: $D1C0; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  415. ( i:A_ADD; oc: $0600; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  416. ( i:A_ADDQ; oc: $5000; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALT ),
  417. ( i:A_ADDX; oc: $D100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  418. ( i:A_ADDX; oc: $D108; ops:2;size: S_ALL; o1:AF_MMIND; o2:AF_MMIND ),
  419. ( i:A_AND; oc: $C000; ops:2;size: S_ALL; o1:AF_ALLNA; o2:AF_DN ),
  420. ( i:A_AND; oc: $C100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTM ),
  421. ( i:A_AND; oc: $0200; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  422. ( i:A_AND; oc: $023C; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_CCR ),
  423. ( i:A_AND; oc: $027C; ops:2;size: [S_W]; o1:AF_IMM; o2:AF_SR ),
  424. ( i:A_ASL; oc: $E120; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  425. ( i:A_ASL; oc: $E100; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  426. ( i:A_ASL; oc: $E1C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  427. ( i:A_ASR; oc: $E020; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  428. ( i:A_ASR; oc: $E000; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  429. ( i:A_ASR; oc: $E0C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  430. ( i:A_BCC; oc: $6400; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  431. ( i:A_BCS; oc: $6500; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  432. ( i:A_BEQ; oc: $6700; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  433. ( i:A_BGE; oc: $6C00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  434. ( i:A_BGT; oc: $6E00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  435. ( i:A_BHI; oc: $6200; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  436. ( i:A_BLE; oc: $6F00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  437. ( i:A_BLS; oc: $6300; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  438. ( i:A_BLT; oc: $6D00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  439. ( i:A_BMI; oc: $6B00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  440. ( i:A_BNE; oc: $6600; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  441. ( i:A_BPL; oc: $6A00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  442. ( i:A_BVC; oc: $6800; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  443. ( i:A_BVS; oc: $6900; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  444. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  445. ( i:A_BCHG; oc: $0140; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  446. ( i:A_BCHG; oc: $0140; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  447. ( i:A_BCHG; oc: $0840; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  448. ( i:A_BCHG; oc: $0840; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  449. ( i:A_BCLR; oc: $0180; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  450. ( i:A_BCLR; oc: $0180; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  451. ( i:A_BCLR; oc: $0880; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  452. ( i:A_BCLR; oc: $0880; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  453. ( i:A_BRA; oc: $6000; ops:1;size: [S_NO]; o1:AF_WBRANCH;o2:0 ),
  454. ( i:A_BSET; oc: $01C0; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  455. ( i:A_BSET; oc: $01C0; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  456. ( i:A_BSET; oc: $08C0; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  457. ( i:A_BSET; oc: $08C0; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  458. ( i:A_BTST; oc: $0100; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  459. ( i:A_BTST; oc: $0100; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  460. ( i:A_BTST; oc: $0800; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  461. ( i:A_BTST; oc: $0800; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  462. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  463. ( i:A_CHK; oc: $4180; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  464. ( i:A_CLR; oc: $4200; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  465. ( i:A_CMP; oc: $B000; ops:2;size: S_ALL; o1:AF_ALLNA; o2:AF_DN ),
  466. ( i:A_CMP; oc: $B000; ops:2;size: [S_WL]; o1:AF_AN; o2:AF_DN ),
  467. ( i:A_CMP; oc: $B0C0; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  468. ( i:A_CMP; oc: $B1C0; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  469. ( i:A_CMP; oc: $0C00; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  470. ( i:A_CMP; oc: $B108; ops:2;size: S_ALL; o1:AF_INDPP; o2:AF_INDPP ),
  471. ( i:A_DBCC; oc: $54C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  472. ( i:A_DBCS; oc: $55C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  473. ( i:A_DBEQ; oc: $57C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  474. ( i:A_DBF; oc: $51C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  475. ( i:A_DBGE; oc: $5CC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  476. ( i:A_DBGT; oc: $5EC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  477. ( i:A_DBHI; oc: $52C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  478. ( i:A_DBLE; oc: $5FC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  479. ( i:A_DBLS; oc: $53C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  480. ( i:A_DBLT; oc: $5DC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  481. ( i:A_DBMI; oc: $5BC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  482. ( i:A_DBNE; oc: $56C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  483. ( i:A_DBPL; oc: $5AC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  484. ( i:A_DBT; oc: $50C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  485. ( i:A_DBVC; oc: $58C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  486. ( i:A_DBVS; oc: $59C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  487. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  488. ( i:A_DIVS; oc: $81C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  489. ( i:A_DIVS; oc: $4C40; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGS), {* 020 *}
  490. ( i:A_DIVU; oc: $80C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  491. ( i:A_DIVU; oc: $4C40; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGU), {* 020 *}
  492. ( i:A_EOR; oc: $B100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTNA ),
  493. ( i:A_EOR; oc: $0A00; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  494. ( i:A_EOR; oc: $0A3C; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_CCR ),
  495. ( i:A_EOR; oc: $0A7C; ops:2;size: [S_W]; o1:AF_IMM; o2:AF_SR ),
  496. ( i:A_EXG; oc: $C140; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  497. ( i:A_EXG; oc: $C148; ops:2;size: [S_L]; o1:AF_AN; o2:AF_AN ),
  498. ( i:A_EXG; oc: $C188; ops:2;size: [S_L]; o1:AF_DN; o2:AF_AN ),
  499. ( i:A_EXG; oc: $C188; ops:2;size: [S_L]; o1:AF_AN; o2:AF_DN ),
  500. ( i:A_EXT; oc: $4880; ops:1;size: [S_W]; o1:AF_DN; o2:0 ),
  501. ( i:A_EXT; oc: $48C0; ops:1;size: [S_L]; o1:AF_DN; o2:0 ),
  502. { MC68020 }
  503. ( i:A_EXTB; oc: $49C0; ops:1;size: [S_L]; o1:AF_DN; o2:0 ),
  504. ( i:A_ILLEGAL;oc: $4AFC;ops:0;size: [S_NO]; o1:0; o2:0 ),
  505. {*
  506. * note: BSR/BSR/JSR ordering must remain as it is (passc.c optimizations)
  507. *}
  508. ( i:A_JMP; oc: $4EC0; ops:1;size: [S_NO]; o1:AF_CTL; o2:0 ),
  509. ( i:A_BSR; oc: $6100; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2: 0 ),
  510. ( i:A_JSR; oc: $4E80; ops:1;size: [S_NO]; o1:AF_CTL; o2:0 ),
  511. ( i:A_LEA; oc: $41C0; ops:2;size: [S_L]; o1:AF_CTL; o2:AF_AN ),
  512. ( i:A_LINK; oc: $4E50; ops:2;size: [S_W]; o1:AF_AN; o2:AF_IMM ),
  513. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  514. ( i:A_LSL; oc: $E128; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  515. ( i:A_LSL; oc: $E108; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  516. ( i:A_LSL; oc: $E3C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  517. ( i:A_LSR; oc: $E028; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  518. ( i:A_LSR; oc: $E008; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  519. ( i:A_LSR; oc: $E2C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  520. ( i:A_MOVE; oc: $2000; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_ALTNA ),
  521. ( i:A_MOVE; oc: $3000; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_ALTNA ),
  522. ( i:A_MOVE; oc: $1000; ops:2;size: [S_B]; o1:AF_ALLNA; o2:AF_ALTNA ),
  523. ( i:A_MOVE; oc: $2000; ops:2;size: [S_L]; o1:AF_AN; o2:AF_ALTNA ),
  524. ( i:A_MOVE; oc: $3000; ops:2;size: [S_W]; o1:AF_AN; o2:AF_ALTNA ),
  525. {* 68010
  526. *( 'MOVE'; i:A_MOVE; oc: $42C0; -1; -1; 0; 3; -1; size: [S_W]; o1:AF_CCR; o1:AF_ALTNA ),
  527. *}
  528. ( i:A_MOVE; oc: $44C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_CCR ),
  529. ( i:A_MOVE; oc: $46C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_SR ),
  530. ( i:A_MOVE; oc: $40C0; ops:2;size: [S_W]; o1:AF_SR; o2:AF_ALTNA ),
  531. ( i:A_MOVE; oc: $3040; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  532. ( i:A_MOVE; oc: $2040; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  533. ( i:A_MOVE; oc: $4E68; ops:2;size: [S_L]; o1:AF_USP; o2:AF_AN ),
  534. ( i:A_MOVE; oc: $4E60; ops:2;size: [S_L]; o1:AF_AN; o2:AF_USP ),
  535. {* MOVEC 68010 *}
  536. ( i:A_MOVEM;oc: $48C0; ops:8;size: [S_L]; o1:AF_REGS; o2:AF_CTL OR AF_MMIND ),
  537. ( i:A_MOVEM;oc: $4880; ops:8;size: [S_W]; o1:AF_REGS; o2:AF_CTL OR AF_MMIND ),
  538. ( i:A_MOVEM;oc: $4CC0; ops:8;size: [S_L]; o1:AF_CTL OR AF_INDPP; o2:AF_REGS ),
  539. ( i:A_MOVEM;oc: $4C80; ops:8;size: [S_W]; o1:AF_CTL OR AF_INDPP; o2:AF_REGS ),
  540. ( i:A_MOVEP;oc: $0188; ops:2;size: [S_W]; o1:AF_DN; o2:AF_OFFAN ),
  541. ( i:A_MOVEP;oc: $01C8; ops:2;size: [S_L]; o1:AF_DN; o2:AF_OFFAN ),
  542. ( i:A_MOVEP;oc: $0108; ops:2;size: [S_W]; o1:AF_OFFAN; o2:AF_DN ),
  543. ( i:A_MOVEP;oc: $0148; ops:2;size: [S_L]; o1:AF_OFFAN; o2:AF_DN ),
  544. {* MOVES 68010 *}
  545. ( i:A_MOVEQ;oc: $7000; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  546. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  547. ( i:A_MULS; oc: $C1C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  548. ( i:A_MULS; oc: $4C00; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGS), {* 020 *}
  549. ( i:A_MULU; oc: $C0C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  550. ( i:A_MULU; oc: $4C00; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGU), {* 020 *}
  551. ( i:A_NBCD; oc: $4800; ops:1;size: [S_B]; o1:AF_ALTNA; o2:0 ),
  552. ( i:A_NEG; oc: $4400; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  553. ( i:A_NEGX; oc: $4000; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  554. ( i:A_NOP; oc: $4E71; ops:0;size: [S_NO]; o1:0; o2:0 ),
  555. ( i:A_NOT; oc: $4600; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  556. ( i:A_OR; oc: $8000; ops:2;size: S_ALL; o1:AF_ALLNA; o2:AF_DN ),
  557. ( i:A_OR; oc: $8100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTNA ),
  558. ( i:A_OR; oc: $0000; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  559. ( i:A_OR; oc: $003C; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_CCR ),
  560. ( i:A_OR; oc: $007C; ops:2;size: [S_W]; o1:AF_IMM; o2:AF_SR ),
  561. ( i:A_PEA; oc: $4840; ops:1;size: [S_L]; o1:AF_CTL; o2:0 ),
  562. ( i:A_RESET;oc: $4E70; ops:0;size: [S_NO]; o1:0; o2:0 ),
  563. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  564. ( i:A_ROL; oc: $E138; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  565. ( i:A_ROL; oc: $E118; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  566. ( i:A_ROL; oc: $E7C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  567. ( i:A_ROR; oc: $E038; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  568. ( i:A_ROR; oc: $E018; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  569. ( i:A_ROR; oc: $E6C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  570. ( i:A_ROXL; oc: $E130; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  571. ( i:A_ROXL; oc: $E110; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  572. ( i:A_ROXL; oc: $E5C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  573. ( i:A_ROXR; oc: $E030; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  574. ( i:A_ROXR; oc: $E010; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  575. ( i:A_ROXR; oc: $E4C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  576. {* RTD 68010 *}
  577. ( i:A_RTE; oc: $4E73; ops:0;size: [S_NO]; o1:0; o2:0 ),
  578. ( i:A_RTR; oc: $4E77; ops:0;size: [S_NO]; o1:0; o2:0 ),
  579. ( i:A_RTS; oc: $4E75; ops:0;size: [S_NO]; o1:0; o2:0 ),
  580. ( i:A_SBCD; oc: $8100; ops:2;size: [S_B]; o1:AF_DN; o2:AF_DN ),
  581. ( i:A_SBCD; oc: $8108; ops:2;size: [S_B]; o1:AF_MMIND; o2:AF_MMIND ),
  582. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  583. {* SCC note; even though they are in the same group since all have the
  584. * same note if one isn't accepted none of the others will be either
  585. *}
  586. ( i:A_SCC; oc: $54C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  587. ( i:A_SCS; oc: $55C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  588. ( i:A_SEQ; oc: $57C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  589. ( i:A_SF; oc: $51C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  590. ( i:A_SGE; oc: $5CC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  591. ( i:A_SGT; oc: $5EC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  592. ( i:A_SHI; oc: $52C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  593. ( i:A_SLE; oc: $5FC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  594. ( i:A_SLS; oc: $53C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  595. ( i:A_SLT; oc: $5DC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  596. ( i:A_SMI; oc: $5BC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  597. ( i:A_SNE; oc: $56C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  598. ( i:A_SPL; oc: $5AC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  599. ( i:A_ST; oc: $50C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  600. ( i:A_SVC; oc: $58C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  601. ( i:A_SVS; oc: $59C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  602. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  603. ( i:A_STOP; oc: $4E72; ops:0; size: [S_W]; o1:AF_IMM; o2: 0 ),
  604. ( i:A_SUB; oc: $9000; ops:2;size: S_ALL; o1:AF_ALL; o2:AF_DN ),
  605. ( i:A_SUB; oc: $9100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTM ),
  606. ( i:A_SUB; oc: $90C0; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  607. ( i:A_SUB; oc: $91C0; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  608. ( i:A_SUB; oc: $0400; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  609. ( i:A_SUBQ; oc: $5100; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALT ),
  610. ( i:A_SUBX; oc: $9100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  611. ( i:A_SUBX; oc: $9108; ops:2;size: S_ALL; o1:AF_MMIND; o2:AF_MMIND ),
  612. ( i:A_SWAP; oc: $4840; ops:1;size: [S_W]; o1:AF_DN; o2:0 ),
  613. ( i:A_TAS; oc: $4AC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2:0 ),
  614. ( i:A_TRAP; oc: $4E40; ops:1;size: [S_NO]; o1:AF_IMM; o2:0 ),
  615. ( i:A_TRAPV;oc: $4E76; ops:0;size: [S_NO]; o1:0; o2:0 ),
  616. ( i:A_TST; oc: $4A00; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  617. ( i:A_UNLK; oc: $4E58; ops:1;size: [S_NO]; o1:AF_AN; o2:0 ),
  618. ( i:A_NONE)
  619. );
  620. {****************************************************************************
  621. Assembler Mnemoics
  622. ****************************************************************************}
  623. const
  624. firstop = A_ABCD;
  625. lastop = A_LABEL;
  626. mot_op2str : array[firstop..lastop] of string[10] =
  627. { 68000 only instructions }
  628. ('abcd','add', 'adda','addi','addq','addx','and','andi',
  629. 'asl','asr','bcc','bcs','beq','bge','bgt','bhi',
  630. 'ble','bls','blt','bmi','bne','bpl','bvc','bvs',
  631. 'bchg','bclr','bra','bset','bsr','btst','chk',
  632. 'clr','cmp','cmpa','cmpi','cmpm','dbcc','dbcs','dbeq','dbge',
  633. 'dbgt','dbhi','dble','dbls','dblt','dbmi','dbne','dbra',
  634. 'dbpl','dbt','dbvc','dbvs','dbf','divs','divu',
  635. 'eor','eori','exg','illegal','ext','jmp','jsr',
  636. 'lea','link','lsl','lsr','move','movea','movei','moveq',
  637. 'movem','movep','muls','mulu','nbcd','neg','negx',
  638. 'nop','not','or','ori','pea','rol','ror','roxl',
  639. 'roxr','rtr','rts','sbcd','scc','scs','seq','sge',
  640. 'sgt','shi','sle','sls','slt','smi','sne',
  641. 'spl','st','svc','svs','sf','sub','suba','subi','subq',
  642. 'subx','swap','tas','trap','trapv','tst','unlk',
  643. 'rte','reset','stop',
  644. { MC68010 instructions }
  645. 'bkpt','movec','moves','rtd',
  646. { MC68020 instructions }
  647. 'bfchg','bfclr','bfexts','bfextu','bfffo',
  648. 'bfins','bfset','bftst','callm','cas','cas2',
  649. 'chk2','cmp2','divsl','divul','extb','pack','rtm',
  650. 'trapcc','tracs','trapeq','trapf','trapge','trapgt',
  651. 'traphi','traple','trapls','traplt','trapmi','trapne',
  652. 'trappl','trapt','trapvc','trapvs','unpk',
  653. { FPU Processor instructions - directly supported only. }
  654. { IEEE aware and misc. condition codes not supported }
  655. 'fabs','fadd',
  656. 'fbeq','fbne','fbngt','fbgt','fbge','fbnge',
  657. 'fblt','fbnlt','fble','fbgl','fbngl','fbgle','fbngle',
  658. 'fdbeq','fdbne','fdbgt','fdbngt','fdbge','fdnbge',
  659. 'fdblt','fdbnlt','fdble','fdbgl','fdbngl','fdbgle','fbdngle',
  660. 'fseq','fsne','fsgt','fsngt','fsge','fsnge',
  661. 'fslt','fsnlt','fsle','fsgl','fsngl','fsgle','fsngle',
  662. 'fcmp','fdiv','fmove','fmovem',
  663. 'fmul','fneg','fnop','fsqrt','fsub','fsgldiv',
  664. 'fsflmul','ftst',
  665. 'ftrapeq','ftrapne','ftrapgt','ftrapngt','ftrapge','ftrapnge',
  666. 'ftraplt','ftrapnlt','ftraple','ftrapgl','ftrapngl','ftrapgle',
  667. 'ftrapngle',
  668. { Useful for assembly langage output }
  669. { Protected instructions }
  670. 'cprestore','cpsave',
  671. { FPU Unit protected instructions }
  672. { and 68030/68851 common MMU instructions }
  673. { (this may include 68040 MMU instructions) }
  674. 'frestore','fsave','pflush','pflusha','pload','pmove','ptest',
  675. { Useful for assembly langage output }
  676. '');
  677. mot_opsize2str : array[topsize] of string[2] =
  678. ('','.b','.w','.l','.b','.b','.w',
  679. '.s','.d','.x','.s','.l','.q');
  680. { I don't know about S_IS, S_IL and S_IQ for m68k
  681. so I guessed, I am not even sure it can happen !!
  682. (PM) }
  683. mot_reg2str : array[R_NO..R_FPSR] of string[6] =
  684. ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
  685. 'a0','a1','a2','a3','a4','a5','a6','sp',
  686. '-(sp)','(sp)+',
  687. 'ccr','fp0','fp1','fp2','fp3','fp4','fp5',
  688. 'fp6','fp7','fpcr','sr','ssp','dfc',
  689. 'sfc','vbr','fpsr');
  690. gas_opsize2str : array[topsize] of string[2] =
  691. ('','.b','.w','.l','.b','.b','.w',
  692. '.s','.d','.x','.s','.l','.q');
  693. gas_reg2str : array[R_NO..R_FPSR] of string[6] =
  694. ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
  695. 'a0','a1','a2','a3','a4','a5','a6','sp',
  696. '-(sp)','(sp)+',
  697. 'ccr','fp0','fp1','fp2','fp3','fp4','fp5',
  698. 'fp6','fp7','fpcr','sr','ssp','dfc',
  699. 'sfc','vbr','fpsr');
  700. mit_opsize2str : array[topsize] of string[2] =
  701. ('','b','w','l','b','b','w',
  702. 's','d','x','s','l','q');
  703. mit_reg2str : array[R_NO..R_FPSR] of string[6] =
  704. ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
  705. 'a0','a1','a2','a3','a4','a5','a6','sp',
  706. 'sp@-','sp@+',
  707. 'ccr','fp0','fp1','fp2','fp3','fp4','fp5',
  708. 'fp6','fp7','fpcr','sr','ssp','dfc',
  709. 'sfc','vbr','fpsr');
  710. gasPalmOS_reg2str : array[R_NO..R_FPSR] of string[6] =
  711. ('', '%d0','%d1','%d2','%d3','%d4','%d5','%d6','%d7',
  712. '%a0','%a1','%a2','%a3','%a4','%a5','%a6','%sp',
  713. '-(%sp)','(%sp)+',
  714. '%ccr','%fp0','%fp1','%fp2','%fp3','%fp4','%fp5',
  715. '%fp6','%fp7','%fpcr','%sr','%ssp','%dfc',
  716. '%sfc','%vbr','%fpsr');
  717. {*****************************************************************************
  718. Init/Done
  719. *****************************************************************************}
  720. procedure InitCpu;
  721. procedure DoneCpu;
  722. implementation
  723. uses
  724. strings,globals,verbose;
  725. procedure disposereference(var r : preference);
  726. begin
  727. if assigned(r^.symbol) then
  728. stringdispose(r^.symbol);
  729. dispose(r);
  730. r:=nil;
  731. end;
  732. function newreference(const r : treference) : preference;
  733. var
  734. p : preference;
  735. begin
  736. new(p);
  737. p^:=r;
  738. if assigned(r.symbol) then
  739. p^.symbol:=stringdup(r.symbol^);
  740. newreference:=p;
  741. end;
  742. procedure reset_reference(var ref : treference);
  743. begin
  744. with ref do
  745. begin
  746. index:=R_NO;
  747. base:=R_NO;
  748. segment:=R_DEFAULT_SEG;
  749. offset:=0;
  750. scalefactor:=1;
  751. isintvalue:=false;
  752. symbol:=nil;
  753. direction := dir_none;
  754. end;
  755. end;
  756. function new_reference(base : tregister;offset : longint) : preference;
  757. var
  758. r : preference;
  759. begin
  760. new(r);
  761. reset_reference(r^);
  762. r^.base:=base;
  763. r^.offset:=offset;
  764. new_reference:=r;
  765. end;
  766. procedure clear_reference(var ref : treference);
  767. begin
  768. stringdispose(ref.symbol);
  769. reset_reference(ref);
  770. end;
  771. function newcsymbol(const s : string;l : longint) : pcsymbol;
  772. var
  773. p : pcsymbol;
  774. begin
  775. new(p);
  776. p^.symbol:=strpnew(s);
  777. p^.offset:=l;
  778. newcsymbol:=p;
  779. end;
  780. procedure disposecsymbol(p : pcsymbol);
  781. begin
  782. strdispose(p^.symbol);
  783. dispose(p);
  784. end;
  785. {****************************************************************************
  786. Taicpu
  787. ****************************************************************************}
  788. constructor taicpu.op_none(op : tasmop;_size : topsize);
  789. begin
  790. inherited init;
  791. typ:=ait_instruction;
  792. _operator:=op;
  793. op1t:=top_none;
  794. op2t:=top_none;
  795. op3t:=top_none;
  796. size:=_size;
  797. { the following isn't required ! }
  798. op1:=nil;
  799. op2:=nil;
  800. op3:=nil;
  801. end;
  802. constructor taicpu.op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  803. begin
  804. inherited init;
  805. typ:=ait_instruction;
  806. _operator:=op;
  807. op1t:=top_reg;
  808. op2t:=top_none;
  809. op3t:=top_none;
  810. size:=_size;
  811. op1:=pointer(_op1);
  812. op2:=nil;
  813. op3:=nil;
  814. end;
  815. constructor taicpu.op_const(op : tasmop;_size : topsize;_op1 : longint);
  816. begin
  817. inherited init;
  818. typ:=ait_instruction;
  819. _operator:=op;
  820. op1t:=top_const;
  821. op2t:=top_none;
  822. op3t:=top_none;
  823. size:=_size;
  824. op1:=pointer(_op1);
  825. op2:=nil;
  826. op3:=nil;
  827. end;
  828. constructor taicpu.op_ref(op : tasmop;_size : topsize;_op1 : preference);
  829. begin
  830. inherited init;
  831. typ:=ait_instruction;
  832. _operator:=op;
  833. op2t:=top_none;
  834. op3t:=top_none;
  835. size:=_size;
  836. if _op1^.isintvalue then
  837. begin
  838. op1t:=top_const;
  839. op1:=pointer(_op1^.offset);
  840. disposereference(_op1);
  841. end
  842. else
  843. begin
  844. op1t:=top_ref;
  845. op1:=pointer(_op1);
  846. end;
  847. op2:=nil;
  848. op3:=nil;
  849. end;
  850. constructor taicpu.op_loc(op : tasmop;_size : topsize;_op1 : tlocation);
  851. begin
  852. inherited init;
  853. typ:=ait_instruction;
  854. _operator:=op;
  855. op2t:=top_none;
  856. op3t:=top_none;
  857. size:=_size;
  858. if (_op1.loc=loc_register) or (_op1.loc=loc_cregister) then
  859. begin
  860. op1t:=top_reg;
  861. op1:=pointer(_op1.register);
  862. end
  863. else
  864. if _op1.reference.isintvalue then
  865. begin
  866. op1t:=top_const;
  867. op1:=pointer(_op1.reference.offset);
  868. end
  869. else
  870. begin
  871. op1t:=top_ref;
  872. op1:=pointer(newreference(_op1.reference));
  873. end;
  874. op2:=nil;
  875. op3:=nil;
  876. end;
  877. constructor taicpu.op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  878. begin
  879. inherited init;
  880. typ:=ait_instruction;
  881. _operator:=op;
  882. op1t:=top_reg;
  883. op2t:=top_reg;
  884. op3t:=top_none;
  885. size:=_size;
  886. op1:=pointer(_op1);
  887. op2:=pointer(_op2);
  888. op3:=nil;
  889. end;
  890. constructor taicpu.op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : preference);
  891. begin
  892. inherited init;
  893. typ:=ait_instruction;
  894. _operator:=op;
  895. op1t:=top_reg;
  896. op3t:=top_none;
  897. size:=_size;
  898. op1:=pointer(_op1);
  899. if _op2^.isintvalue then
  900. begin
  901. op2t:=top_const;
  902. op2:=pointer(_op2^.offset);
  903. disposereference(_op2);
  904. end
  905. else
  906. begin
  907. op2t:=top_ref;
  908. op2:=pointer(_op2);
  909. end;
  910. op3:=nil;
  911. end;
  912. constructor taicpu.op_reg_loc(op : tasmop;_size : topsize;_op1 : tregister;_op2 : tlocation);
  913. begin
  914. inherited init;
  915. typ:=ait_instruction;
  916. _operator:=op;
  917. op1t:=top_reg;
  918. op3t:=top_none;
  919. size:=_size;
  920. op1:=pointer(_op1);
  921. if (_op2.loc=loc_register) or (_op2.loc=loc_cregister) then
  922. begin
  923. op2t:=top_reg;
  924. op2:=pointer(_op2.register);
  925. end
  926. else
  927. if _op2.reference.isintvalue then
  928. begin
  929. op2t:=top_const;
  930. op2:=pointer(_op2.reference.offset);
  931. end
  932. else
  933. begin
  934. op2t:=top_ref;
  935. op2:=pointer(newreference(_op2.reference));
  936. end;
  937. op3:=nil;
  938. end;
  939. constructor taicpu.op_loc_reg(op : tasmop;_size : topsize;_op1 : tlocation;_op2 : tregister);
  940. begin
  941. inherited init;
  942. typ:=ait_instruction;
  943. _operator:=op;
  944. op2t:=top_reg;
  945. op3t:=top_none;
  946. size:=_size;
  947. op2:=pointer(_op2);
  948. if (_op1.loc=loc_register) or (_op1.loc=loc_cregister) then
  949. begin
  950. op1t:=top_reg;
  951. op1:=pointer(_op1.register);
  952. end
  953. else
  954. if _op1.reference.isintvalue then
  955. begin
  956. op1t:=top_const;
  957. op1:=pointer(_op1.reference.offset);
  958. end
  959. else
  960. begin
  961. op1t:=top_ref;
  962. op1:=pointer(newreference(_op1.reference));
  963. end;
  964. op3:=nil;
  965. end;
  966. constructor taicpu.op_const_reg_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : tregister);
  967. begin
  968. inherited init;
  969. typ:=ait_instruction;
  970. _operator:=op;
  971. op1t:=top_const;
  972. op2t:=top_reg;
  973. op3t:=top_reg;
  974. size:=_size;
  975. op1:=pointer(_op1);
  976. op2:=pointer(_op2);
  977. op3:=pointer(_op3);
  978. end;
  979. constructor taicpu.op_reg_const(op: tasmop; _size: topsize; _op1: tregister; _op2: longint);
  980. begin
  981. inherited init;
  982. typ := ait_instruction;
  983. _operator := op;
  984. op1t := top_reg;
  985. op2t := top_const;
  986. op3t := top_none;
  987. op1 := pointer(_op1);
  988. op2 := pointer(_op2);
  989. size := _size;
  990. end;
  991. constructor taicpu.op_reg_reg_reg(op : tasmop;_size : topsize;_op1 : tregister;_op2 : tregister;_op3 : tregister);
  992. begin
  993. inherited init;
  994. typ:=ait_instruction;
  995. _operator:=op;
  996. op1t:=top_reg;
  997. op2t:=top_reg;
  998. op3t:=top_reg;
  999. size:=_size;
  1000. op1:=pointer(_op1);
  1001. op2:=pointer(_op2);
  1002. op3:=pointer(_op3);
  1003. end;
  1004. constructor taicpu.op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  1005. begin
  1006. inherited init;
  1007. typ:=ait_instruction;
  1008. _operator:=op;
  1009. op1t:=top_const;
  1010. op2t:=top_reg;
  1011. op3t:=top_none;
  1012. size:=_size;
  1013. op1:=pointer(_op1);
  1014. op2:=pointer(_op2);
  1015. op3:=nil;
  1016. end;
  1017. constructor taicpu.op_const_const(op : tasmop;_size : topsize;_op1,_op2 : longint);
  1018. begin
  1019. inherited init;
  1020. typ:=ait_instruction;
  1021. _operator:=op;
  1022. op1t:=top_const;
  1023. op2t:=top_const;
  1024. op3t:=top_none;
  1025. size:=_size;
  1026. op1:=pointer(_op1);
  1027. op2:=pointer(_op2);
  1028. op3:=nil;
  1029. end;
  1030. constructor taicpu.op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference);
  1031. begin
  1032. inherited init;
  1033. typ:=ait_instruction;
  1034. _operator:=op;
  1035. op1t:=top_const;
  1036. op3t:=top_none;
  1037. size:=_size;
  1038. op1:=pointer(_op1);
  1039. if _op2^.isintvalue then
  1040. begin
  1041. op2t:=top_const;
  1042. op2:=pointer(_op2^.offset);
  1043. disposereference(_op2);
  1044. end
  1045. else
  1046. begin
  1047. op2t:=top_ref;
  1048. op2:=pointer(_op2);
  1049. end;
  1050. op3:=nil;
  1051. end;
  1052. constructor taicpu.op_const_loc(op : tasmop;_size : topsize;_op1 : longint;_op2 : tlocation);
  1053. begin
  1054. inherited init;
  1055. typ:=ait_instruction;
  1056. _operator:=op;
  1057. op1t:=top_const;
  1058. op3t:=top_none;
  1059. size:=_size;
  1060. op1:=pointer(_op1);
  1061. if (_op2.loc=loc_register) or (_op2.loc=loc_cregister) then
  1062. begin
  1063. op2t:=top_reg;
  1064. op2:=pointer(_op2.register);
  1065. end
  1066. else
  1067. if _op2.reference.isintvalue then
  1068. begin
  1069. op2t:=top_const;
  1070. op2:=pointer(_op2.reference.offset);
  1071. end
  1072. else
  1073. begin
  1074. op2t:=top_ref;
  1075. op2:=pointer(newreference(_op2.reference));
  1076. end;
  1077. op3:=nil;
  1078. end;
  1079. constructor taicpu.op_ref_reg(op : tasmop;_size : topsize;_op1 : preference;_op2 : tregister);
  1080. begin
  1081. inherited init;
  1082. typ:=ait_instruction;
  1083. _operator:=op;
  1084. op2t:=top_reg;
  1085. op3t:=top_none;
  1086. size:=_size;
  1087. op2:=pointer(_op2);
  1088. if _op1^.isintvalue then
  1089. begin
  1090. op1t:=top_const;
  1091. op1:=pointer(_op1^.offset);
  1092. disposereference(_op1);
  1093. end
  1094. else
  1095. begin
  1096. op1t:=top_ref;
  1097. op1:=pointer(_op1);
  1098. end;
  1099. op3:=nil;
  1100. end;
  1101. constructor taicpu.op_ref_ref(op : tasmop;_size : topsize;_op1,_op2 : preference);
  1102. begin
  1103. inherited init;
  1104. typ:=ait_instruction;
  1105. _operator:=op;
  1106. op3t:=top_none;
  1107. size:=_size;
  1108. if _op1^.isintvalue then
  1109. begin
  1110. op1t:=top_const;
  1111. op1:=pointer(_op1^.offset);
  1112. disposereference(_op1);
  1113. end
  1114. else
  1115. begin
  1116. op1t:=top_ref;
  1117. op1:=pointer(_op1);
  1118. end;
  1119. if _op2^.isintvalue then
  1120. begin
  1121. op2t:=top_const;
  1122. op2:=pointer(_op2^.offset);
  1123. disposereference(_op2);
  1124. end
  1125. else
  1126. begin
  1127. op2t:=top_ref;
  1128. op2:=pointer(_op2);
  1129. end;
  1130. op3:=nil;
  1131. end;
  1132. constructor taicpu.op_csymbol(op : tasmop;_size : topsize;_op1 : pcsymbol);
  1133. begin
  1134. inherited init;
  1135. typ:=ait_instruction;
  1136. _operator:=op;
  1137. if (op=A_JSR) and
  1138. (use_esp_stackframe) then
  1139. Message(cg_e_stackframe_with_esp);
  1140. op1t:=top_symbol;
  1141. op2t:=top_none;
  1142. op3t:=top_none;
  1143. size:=_size;
  1144. op1:=pointer(_op1);
  1145. op2:=nil;
  1146. op3:=nil;
  1147. end;
  1148. constructor taicpu.op_csymbol_reg(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : tregister);
  1149. begin
  1150. inherited init;
  1151. typ:=ait_instruction;
  1152. _operator:=op;
  1153. op1t:=top_symbol;
  1154. op2t:=top_reg;
  1155. op3t:=top_none;
  1156. size:=_size;
  1157. op1:=pointer(_op1);
  1158. op2:=pointer(_op2);
  1159. op3:=nil;
  1160. end;
  1161. constructor taicpu.op_csymbol_ref(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : preference);
  1162. begin
  1163. inherited init;
  1164. typ:=ait_instruction;
  1165. _operator:=op;
  1166. op1t:=top_symbol;
  1167. op3t:=top_none;
  1168. size:=_size;
  1169. op1:=pointer(_op1);
  1170. if _op2^.isintvalue then
  1171. begin
  1172. op2t:=top_const;
  1173. op2:=pointer(_op2^.offset);
  1174. disposereference(_op2);
  1175. end
  1176. else
  1177. begin
  1178. op2t:=top_ref;
  1179. op2:=pointer(_op2);
  1180. end;
  1181. op3:=nil;
  1182. end;
  1183. constructor taicpu.op_csymbol_loc(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : tlocation);
  1184. begin
  1185. inherited init;
  1186. typ:=ait_instruction;
  1187. _operator:=op;
  1188. op1t:=top_symbol;
  1189. op3t:=top_none;
  1190. size:=_size;
  1191. op1:=pointer(_op1);
  1192. if (_op2.loc=loc_register) or (_op2.loc=loc_cregister) then
  1193. begin
  1194. op2t:=top_reg;
  1195. op2:=pointer(_op2.register);
  1196. end
  1197. else
  1198. if _op2.reference.isintvalue then
  1199. begin
  1200. op2t:=top_const;
  1201. op2:=pointer(_op2.reference.offset);
  1202. end
  1203. else
  1204. begin
  1205. op2t:=top_ref;
  1206. op2:=pointer(newreference(_op2.reference));
  1207. end;
  1208. op3:=nil;
  1209. end;
  1210. destructor taicpu.done;
  1211. begin
  1212. if op1t=top_symbol then
  1213. disposecsymbol(pcsymbol(op1))
  1214. else if op1t=top_ref then
  1215. begin
  1216. clear_reference(preference(op1)^);
  1217. dispose(preference(op1));
  1218. end;
  1219. if op2t=top_symbol then
  1220. disposecsymbol(pcsymbol(op2))
  1221. else if op2t=top_ref then
  1222. begin
  1223. clear_reference(preference(op2)^);
  1224. dispose(preference(op2));
  1225. end;
  1226. if op3t=top_symbol then
  1227. disposecsymbol(pcsymbol(op3))
  1228. else if op3t = top_ref then
  1229. begin
  1230. clear_reference(preference(op3)^);
  1231. dispose(preference(op3));
  1232. end;
  1233. inherited done;
  1234. end;
  1235. constructor taicpu.op_ref_reglist(op: tasmop; _size : topsize; _op1: preference;_op2: tregisterlist);
  1236. Begin
  1237. Inherited Init;
  1238. typ:=ait_instruction;
  1239. _operator:=op;
  1240. op2t:=top_reglist;
  1241. op3t:=top_none;
  1242. size:=_size;
  1243. reglist := _op2;
  1244. if _op1^.isintvalue then
  1245. begin
  1246. op1t:=top_const;
  1247. op1:=pointer(_op1^.offset);
  1248. disposereference(_op1);
  1249. end
  1250. else
  1251. begin
  1252. op1t:=top_ref;
  1253. op1:=pointer(_op1);
  1254. end;
  1255. op3:=nil;
  1256. end;
  1257. constructor taicpu.op_reglist_ref(op: tasmop; _size : topsize; _op1: tregisterlist; _op2: preference);
  1258. Begin
  1259. Inherited Init;
  1260. typ:=ait_instruction;
  1261. _operator:=op;
  1262. reglist:=_op1;
  1263. op1t:=top_reglist;
  1264. op3t:=top_none;
  1265. size:=_size;
  1266. if _op2^.isintvalue then
  1267. begin
  1268. op2t:=top_const;
  1269. op2:=pointer(_op2^.offset);
  1270. disposereference(_op2);
  1271. end
  1272. else
  1273. begin
  1274. op2t:=top_ref;
  1275. op2:=pointer(_op2);
  1276. end;
  1277. op3:=nil;
  1278. end;
  1279. {****************************************************************************
  1280. TAI_LABELED
  1281. ****************************************************************************}
  1282. constructor tai_labeled.init(op : tasmop; l : pasmlabel);
  1283. begin
  1284. inherited init;
  1285. typ:=ait_labeled_instruction;
  1286. _operator:=op;
  1287. _op1:=R_NO;
  1288. lab:=l;
  1289. inc(lab^.refs);
  1290. end;
  1291. constructor tai_labeled.init_reg(op : tasmop; l : pasmlabel; reg: tregister);
  1292. begin
  1293. inherited init;
  1294. typ:=ait_labeled_instruction;
  1295. _op1:=reg;
  1296. _operator:=op;
  1297. lab:=l;
  1298. inc(lab^.refs);
  1299. end;
  1300. destructor tai_labeled.done;
  1301. begin
  1302. dec(lab^.refs);
  1303. inherited done;
  1304. end;
  1305. {*****************************************************************************
  1306. Init/Done
  1307. *****************************************************************************}
  1308. procedure InitCpu;
  1309. begin
  1310. end;
  1311. procedure DoneCpu;
  1312. begin
  1313. end;
  1314. end.
  1315. {
  1316. $Log$
  1317. Revision 1.2 2002-04-20 21:40:48 carl
  1318. * renamed some constants
  1319. Revision 1.1 2000/07/13 06:30:05 michael
  1320. + Initial import
  1321. Revision 1.2 2000/01/07 01:14:50 peter
  1322. * updated copyright to 2000
  1323. Revision 1.1 1999/09/16 23:05:57 florian
  1324. * m68k compiler is again compilable (only gas writer, no assembler reader)
  1325. Revision 1.12 1999/08/19 13:02:08 pierre
  1326. + label faillabel added for _FAIL support
  1327. Revision 1.11 1999/06/22 16:24:42 pierre
  1328. * local browser stuff corrected
  1329. Revision 1.10 1998/10/29 11:35:45 florian
  1330. * some dll support for win32
  1331. * fixed assembler writing for PalmOS
  1332. Revision 1.9 1998/10/14 08:47:18 pierre
  1333. * bugs in secondfuncret for result in subprocedures removed
  1334. Revision 1.8 1998/10/13 16:50:15 pierre
  1335. * undid some changes of Peter that made the compiler wrong
  1336. for m68k (I had to reinsert some ifdefs)
  1337. * removed several memory leaks under m68k
  1338. * removed the meory leaks for assembler readers
  1339. * cross compiling shoud work again better
  1340. ( crosscompiling sysamiga works
  1341. but as68k still complain about some code !)
  1342. Revision 1.7 1998/08/31 12:26:27 peter
  1343. * m68k and palmos updates from surebugfixes
  1344. Revision 1.6 1998/08/21 14:08:44 pierre
  1345. + TEST_FUNCRET now default (old code removed)
  1346. works also for m68k (at least compiles)
  1347. Revision 1.5 1998/06/04 23:51:45 peter
  1348. * m68k compiles
  1349. + .def file creation moved to gendef.pas so it could also be used
  1350. for win32
  1351. Revision 1.4 1998/05/23 01:21:10 peter
  1352. + aktasmmode, aktoptprocessor, aktoutputformat
  1353. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1354. + $LIBNAME to set the library name where the unit will be put in
  1355. * splitted cgi386 a bit (codeseg to large for bp7)
  1356. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1357. Revision 1.3 1998/05/11 13:07:54 peter
  1358. + $ifdef NEWPPU for the new ppuformat
  1359. + $define GDB not longer required
  1360. * removed all warnings and stripped some log comments
  1361. * no findfirst/findnext anymore to remove smartlink *.o files
  1362. Revision 1.2 1998/04/29 10:33:54 pierre
  1363. + added some code for ansistring (not complete nor working yet)
  1364. * corrected operator overloading
  1365. * corrected nasm output
  1366. + started inline procedures
  1367. + added starstarn : use ** for exponentiation (^ gave problems)
  1368. + started UseTokenInfo cond to get accurate positions
  1369. }