cpubase.pas 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  1. {
  2. $Id$
  3. Copyright (c) 1995-98 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 = R_SP;
  217. frame_pointer = 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. function reg2str(r : tregister) : string;
  294. { generates an help record for constants }
  295. function newcsymbol(const s : string;l : longint) : pcsymbol;
  296. const
  297. ao_unknown = $0;
  298. { 8 bit reg }
  299. ao_reg8 = $1;
  300. { 16 bit reg }
  301. ao_reg16 = $2;
  302. { 32 bit reg }
  303. ao_reg32 = $4;
  304. ao_reg = (ao_reg8 or ao_reg16 or ao_reg32);
  305. { for push/pop operands }
  306. ao_wordreg = (ao_reg16 or ao_reg32);
  307. ao_imm8 = $8; { 8 bit immediate }
  308. ao_imm8S = $10; { 8 bit immediate sign extended }
  309. ao_imm16 = $20; { 16 bit immediate }
  310. ao_imm32 = $40; { 32 bit immediate }
  311. ao_imm1 = $80; { 1 bit immediate }
  312. { for unknown expressions }
  313. ao_immunknown = ao_imm32;
  314. { gen'l immediate }
  315. ao_imm = (ao_imm8 or ao_imm8S or ao_imm16 or ao_imm32);
  316. ao_disp8 = $200; { 8 bit displacement (for jumps) }
  317. ao_disp16 = $400; { 16 bit displacement }
  318. ao_disp32 = $800; { 32 bit displacement }
  319. { general displacement }
  320. ao_disp = (ao_disp8 or ao_disp16 or ao_disp32);
  321. { for unknown size displacements }
  322. ao_dispunknown = ao_disp32;
  323. ao_mem8 = $1000;
  324. ao_mem16 = $2000;
  325. ao_mem32 = $4000;
  326. ao_baseindex = $8000;
  327. { general mem }
  328. ao_mem = (ao_disp or ao_mem8 or ao_mem16 or ao_mem32 or ao_baseindex);
  329. ao_wordmem = (ao_mem16 or ao_mem32 or ao_disp or ao_baseindex);
  330. ao_bytemem = (ao_mem8 or ao_disp or ao_baseindex);
  331. ao_control = $40000; { Control register }
  332. ao_debug = $80000; { Debug register }
  333. ao_test = $100000; { Test register }
  334. ao_floatreg = $200000; { Float register }
  335. ao_jumpabsolute = $4000000;
  336. ao_abs8 = $08000000;
  337. ao_abs16 = $10000000;
  338. ao_abs32 = $20000000;
  339. ao_abs = (ao_abs8 or ao_abs16 or ao_abs32);
  340. ao_none = $ff;
  341. const
  342. AB_DN = 1;
  343. AB_AN = 2;
  344. AB_INDAN = 3;
  345. AB_INDPP = 4;
  346. AB_MMIND = 5;
  347. AB_OFFAN = 6;
  348. AB_OFFIDX = 7;
  349. AB_ABSW = 8;
  350. AB_ABSL = 9;
  351. AB_OFFPC = 10;
  352. AB_OFFIDXPC =11;
  353. AB_IMM =12;
  354. AB_REGS =13; {* movem *}
  355. AB_BBRANCH =14;
  356. AB_WBRANCH =15;
  357. AB_CCR =16;
  358. AB_SR =17;
  359. AB_USP =18;
  360. AB_MULDREGS =19;
  361. AB_MULDREGU =20;
  362. AF_DN =(1 SHL AB_DN);
  363. AF_AN =(1 SHL AB_AN);
  364. AF_INDAN = (1 SHL AB_INDAN);
  365. AF_INDPP = (1 SHL AB_INDPP);
  366. AF_MMIND = (1 SHL AB_MMIND);
  367. AF_OFFAN = (1 SHL AB_OFFAN);
  368. AF_OFFIDX = (1 SHL AB_OFFIDX);
  369. AF_ABSW = (1 SHL AB_ABSW);
  370. AF_ABSL = (1 SHL AB_ABSL);
  371. AF_OFFPC = (1 SHL AB_OFFPC);
  372. AF_OFFIDXPC= (1 SHL AB_OFFIDXPC);
  373. AF_IMM =(1 SHL AB_IMM);
  374. AF_REGS = (1 SHL AB_REGS);
  375. AF_BBRANCH = (1 SHL AB_BBRANCH);
  376. AF_WBRANCH = (1 SHL AB_WBRANCH);
  377. AF_CCR =(1 SHL AB_CCR);
  378. AF_SR =(1 SHL AB_SR);
  379. AF_USP =(1 SHL AB_USP);
  380. AF_MULDREGS= (1 SHL AB_MULDREGS);
  381. AF_MULDREGU= (1 SHL AB_MULDREGU);
  382. 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
  383. AF_ABSL OR AF_OFFPC OR AF_OFFIDXPC OR AF_IMM;
  384. 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
  385. OR AF_OFFPC OR AF_OFFIDXPC OR AF_IMM;
  386. AF_ALT = AF_DN OR AF_AN OR AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR
  387. AF_OFFIDX OR AF_ABSW OR AF_ABSL;
  388. 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;
  389. AF_ALTM = AF_INDAN OR AF_INDPP OR AF_MMIND OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL;
  390. AF_CTL = AF_INDAN OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL OR AF_OFFPC OR AF_OFFIDXPC;
  391. AF_CTLNPC = AF_INDAN OR AF_OFFAN OR AF_OFFIDX OR AF_ABSW OR AF_ABSL OR AF_OFFIDXPC;
  392. { S_WL (S_W|S_L)
  393. S_BW (S_B|S_W)}
  394. const
  395. S_ALL = [S_B] + [S_W] + [S_L];
  396. {#define S_ALL (S_B|S_W|S_L)}
  397. type
  398. ttemplate = record
  399. i : tasmop;
  400. oc : longint;
  401. ops : byte;
  402. size: set of topsize;
  403. o1,o2: longint;
  404. end;
  405. tins_cache = array[A_ABCD..A_UNLK] of longint;
  406. var
  407. ins_cache : tins_cache;
  408. const
  409. it : array[0..188] of ttemplate = (
  410. ( i:A_ABCD; oc: $C100; ops:2;size: [S_B]; o1:AF_DN; o2:AF_DN ),
  411. ( i:A_ABCD; oc: $C108; ops:2;size: [S_B]; o1:AF_MMIND; o2:AF_MMIND ),
  412. ( i:A_ADD; oc: $D000; ops:2;size: S_ALL; o1:AF_ALL; o2:AF_DN ),
  413. ( i:A_ADD; oc: $D100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTM ),
  414. ( i:A_ADD; oc: $D0C0; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  415. ( i:A_ADD; oc: $D1C0; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  416. ( i:A_ADD; oc: $0600; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  417. ( i:A_ADDQ; oc: $5000; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALT ),
  418. ( i:A_ADDX; oc: $D100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  419. ( i:A_ADDX; oc: $D108; ops:2;size: S_ALL; o1:AF_MMIND; o2:AF_MMIND ),
  420. ( i:A_AND; oc: $C000; ops:2;size: S_ALL; o1:AF_ALLNA; o2:AF_DN ),
  421. ( i:A_AND; oc: $C100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTM ),
  422. ( i:A_AND; oc: $0200; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  423. ( i:A_AND; oc: $023C; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_CCR ),
  424. ( i:A_AND; oc: $027C; ops:2;size: [S_W]; o1:AF_IMM; o2:AF_SR ),
  425. ( i:A_ASL; oc: $E120; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  426. ( i:A_ASL; oc: $E100; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  427. ( i:A_ASL; oc: $E1C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  428. ( i:A_ASR; oc: $E020; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  429. ( i:A_ASR; oc: $E000; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  430. ( i:A_ASR; oc: $E0C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  431. ( i:A_BCC; oc: $6400; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  432. ( i:A_BCS; oc: $6500; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  433. ( i:A_BEQ; oc: $6700; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  434. ( i:A_BGE; oc: $6C00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  435. ( i:A_BGT; oc: $6E00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  436. ( i:A_BHI; oc: $6200; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  437. ( i:A_BLE; oc: $6F00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  438. ( i:A_BLS; oc: $6300; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  439. ( i:A_BLT; oc: $6D00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  440. ( i:A_BMI; oc: $6B00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  441. ( i:A_BNE; oc: $6600; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  442. ( i:A_BPL; oc: $6A00; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  443. ( i:A_BVC; oc: $6800; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  444. ( i:A_BVS; oc: $6900; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2:0 ),
  445. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  446. ( i:A_BCHG; oc: $0140; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  447. ( i:A_BCHG; oc: $0140; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  448. ( i:A_BCHG; oc: $0840; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  449. ( i:A_BCHG; oc: $0840; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  450. ( i:A_BCLR; oc: $0180; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  451. ( i:A_BCLR; oc: $0180; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  452. ( i:A_BCLR; oc: $0880; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  453. ( i:A_BCLR; oc: $0880; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  454. ( i:A_BRA; oc: $6000; ops:1;size: [S_NO]; o1:AF_WBRANCH;o2:0 ),
  455. ( i:A_BSET; oc: $01C0; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  456. ( i:A_BSET; oc: $01C0; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  457. ( i:A_BSET; oc: $08C0; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  458. ( i:A_BSET; oc: $08C0; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  459. ( i:A_BTST; oc: $0100; ops:2;size: [S_B]; o1:AF_DN; o2:AF_ALTM ),
  460. ( i:A_BTST; oc: $0100; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  461. ( i:A_BTST; oc: $0800; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_ALTM ),
  462. ( i:A_BTST; oc: $0800; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  463. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  464. ( i:A_CHK; oc: $4180; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  465. ( i:A_CLR; oc: $4200; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  466. ( i:A_CMP; oc: $B000; ops:2;size: S_ALL; o1:AF_ALLNA; o2:AF_DN ),
  467. ( i:A_CMP; oc: $B000; ops:2;size: [S_WL]; o1:AF_AN; o2:AF_DN ),
  468. ( i:A_CMP; oc: $B0C0; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  469. ( i:A_CMP; oc: $B1C0; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  470. ( i:A_CMP; oc: $0C00; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  471. ( i:A_CMP; oc: $B108; ops:2;size: S_ALL; o1:AF_INDPP; o2:AF_INDPP ),
  472. ( i:A_DBCC; oc: $54C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  473. ( i:A_DBCS; oc: $55C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  474. ( i:A_DBEQ; oc: $57C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  475. ( i:A_DBF; oc: $51C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  476. ( i:A_DBGE; oc: $5CC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  477. ( i:A_DBGT; oc: $5EC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  478. ( i:A_DBHI; oc: $52C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  479. ( i:A_DBLE; oc: $5FC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  480. ( i:A_DBLS; oc: $53C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  481. ( i:A_DBLT; oc: $5DC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  482. ( i:A_DBMI; oc: $5BC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  483. ( i:A_DBNE; oc: $56C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  484. ( i:A_DBPL; oc: $5AC8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  485. ( i:A_DBT; oc: $50C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  486. ( i:A_DBVC; oc: $58C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  487. ( i:A_DBVS; oc: $59C8; ops:2;size: [S_NO]; o1:AF_DN; o2:AF_WBRANCH ),
  488. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  489. ( i:A_DIVS; oc: $81C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  490. ( i:A_DIVS; oc: $4C40; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGS), {* 020 *}
  491. ( i:A_DIVU; oc: $80C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  492. ( i:A_DIVU; oc: $4C40; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGU), {* 020 *}
  493. ( i:A_EOR; oc: $B100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTNA ),
  494. ( i:A_EOR; oc: $0A00; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  495. ( i:A_EOR; oc: $0A3C; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_CCR ),
  496. ( i:A_EOR; oc: $0A7C; ops:2;size: [S_W]; o1:AF_IMM; o2:AF_SR ),
  497. ( i:A_EXG; oc: $C140; ops:2;size: [S_L]; o1:AF_DN; o2:AF_DN ),
  498. ( i:A_EXG; oc: $C148; ops:2;size: [S_L]; o1:AF_AN; o2:AF_AN ),
  499. ( i:A_EXG; oc: $C188; ops:2;size: [S_L]; o1:AF_DN; o2:AF_AN ),
  500. ( i:A_EXG; oc: $C188; ops:2;size: [S_L]; o1:AF_AN; o2:AF_DN ),
  501. ( i:A_EXT; oc: $4880; ops:1;size: [S_W]; o1:AF_DN; o2:0 ),
  502. ( i:A_EXT; oc: $48C0; ops:1;size: [S_L]; o1:AF_DN; o2:0 ),
  503. { MC68020 }
  504. ( i:A_EXTB; oc: $49C0; ops:1;size: [S_L]; o1:AF_DN; o2:0 ),
  505. ( i:A_ILLEGAL;oc: $4AFC;ops:0;size: [S_NO]; o1:0; o2:0 ),
  506. {*
  507. * note: BSR/BSR/JSR ordering must remain as it is (passc.c optimizations)
  508. *}
  509. ( i:A_JMP; oc: $4EC0; ops:1;size: [S_NO]; o1:AF_CTL; o2:0 ),
  510. ( i:A_BSR; oc: $6100; ops:1;size: [S_NO]; o1:AF_WBRANCH; o2: 0 ),
  511. ( i:A_JSR; oc: $4E80; ops:1;size: [S_NO]; o1:AF_CTL; o2:0 ),
  512. ( i:A_LEA; oc: $41C0; ops:2;size: [S_L]; o1:AF_CTL; o2:AF_AN ),
  513. ( i:A_LINK; oc: $4E50; ops:2;size: [S_W]; o1:AF_AN; o2:AF_IMM ),
  514. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  515. ( i:A_LSL; oc: $E128; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  516. ( i:A_LSL; oc: $E108; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  517. ( i:A_LSL; oc: $E3C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  518. ( i:A_LSR; oc: $E028; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  519. ( i:A_LSR; oc: $E008; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  520. ( i:A_LSR; oc: $E2C0; ops:1;size: [S_W]; o1:0; o2:AF_ALTM ),
  521. ( i:A_MOVE; oc: $2000; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_ALTNA ),
  522. ( i:A_MOVE; oc: $3000; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_ALTNA ),
  523. ( i:A_MOVE; oc: $1000; ops:2;size: [S_B]; o1:AF_ALLNA; o2:AF_ALTNA ),
  524. ( i:A_MOVE; oc: $2000; ops:2;size: [S_L]; o1:AF_AN; o2:AF_ALTNA ),
  525. ( i:A_MOVE; oc: $3000; ops:2;size: [S_W]; o1:AF_AN; o2:AF_ALTNA ),
  526. {* 68010
  527. *( 'MOVE'; i:A_MOVE; oc: $42C0; -1; -1; 0; 3; -1; size: [S_W]; o1:AF_CCR; o1:AF_ALTNA ),
  528. *}
  529. ( i:A_MOVE; oc: $44C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_CCR ),
  530. ( i:A_MOVE; oc: $46C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_SR ),
  531. ( i:A_MOVE; oc: $40C0; ops:2;size: [S_W]; o1:AF_SR; o2:AF_ALTNA ),
  532. ( i:A_MOVE; oc: $3040; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  533. ( i:A_MOVE; oc: $2040; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  534. ( i:A_MOVE; oc: $4E68; ops:2;size: [S_L]; o1:AF_USP; o2:AF_AN ),
  535. ( i:A_MOVE; oc: $4E60; ops:2;size: [S_L]; o1:AF_AN; o2:AF_USP ),
  536. {* MOVEC 68010 *}
  537. ( i:A_MOVEM;oc: $48C0; ops:8;size: [S_L]; o1:AF_REGS; o2:AF_CTL OR AF_MMIND ),
  538. ( i:A_MOVEM;oc: $4880; ops:8;size: [S_W]; o1:AF_REGS; o2:AF_CTL OR AF_MMIND ),
  539. ( i:A_MOVEM;oc: $4CC0; ops:8;size: [S_L]; o1:AF_CTL OR AF_INDPP; o2:AF_REGS ),
  540. ( i:A_MOVEM;oc: $4C80; ops:8;size: [S_W]; o1:AF_CTL OR AF_INDPP; o2:AF_REGS ),
  541. ( i:A_MOVEP;oc: $0188; ops:2;size: [S_W]; o1:AF_DN; o2:AF_OFFAN ),
  542. ( i:A_MOVEP;oc: $01C8; ops:2;size: [S_L]; o1:AF_DN; o2:AF_OFFAN ),
  543. ( i:A_MOVEP;oc: $0108; ops:2;size: [S_W]; o1:AF_OFFAN; o2:AF_DN ),
  544. ( i:A_MOVEP;oc: $0148; ops:2;size: [S_L]; o1:AF_OFFAN; o2:AF_DN ),
  545. {* MOVES 68010 *}
  546. ( i:A_MOVEQ;oc: $7000; ops:2;size: [S_L]; o1:AF_IMM; o2:AF_DN ),
  547. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  548. ( i:A_MULS; oc: $C1C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  549. ( i:A_MULS; oc: $4C00; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGS), {* 020 *}
  550. ( i:A_MULU; oc: $C0C0; ops:2;size: [S_W]; o1:AF_ALLNA; o2:AF_DN ),
  551. ( i:A_MULU; oc: $4C00; ops:2;size: [S_L]; o1:AF_ALLNA; o2:AF_DN OR AF_MULDREGU), {* 020 *}
  552. ( i:A_NBCD; oc: $4800; ops:1;size: [S_B]; o1:AF_ALTNA; o2:0 ),
  553. ( i:A_NEG; oc: $4400; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  554. ( i:A_NEGX; oc: $4000; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  555. ( i:A_NOP; oc: $4E71; ops:0;size: [S_NO]; o1:0; o2:0 ),
  556. ( i:A_NOT; oc: $4600; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  557. ( i:A_OR; oc: $8000; ops:2;size: S_ALL; o1:AF_ALLNA; o2:AF_DN ),
  558. ( i:A_OR; oc: $8100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTNA ),
  559. ( i:A_OR; oc: $0000; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  560. ( i:A_OR; oc: $003C; ops:2;size: [S_B]; o1:AF_IMM; o2:AF_CCR ),
  561. ( i:A_OR; oc: $007C; ops:2;size: [S_W]; o1:AF_IMM; o2:AF_SR ),
  562. ( i:A_PEA; oc: $4840; ops:1;size: [S_L]; o1:AF_CTL; o2:0 ),
  563. ( i:A_RESET;oc: $4E70; ops:0;size: [S_NO]; o1:0; o2:0 ),
  564. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  565. ( i:A_ROL; oc: $E138; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  566. ( i:A_ROL; oc: $E118; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  567. ( i:A_ROL; oc: $E7C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  568. ( i:A_ROR; oc: $E038; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  569. ( i:A_ROR; oc: $E018; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  570. ( i:A_ROR; oc: $E6C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  571. ( i:A_ROXL; oc: $E130; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  572. ( i:A_ROXL; oc: $E110; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  573. ( i:A_ROXL; oc: $E5C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  574. ( i:A_ROXR; oc: $E030; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  575. ( i:A_ROXR; oc: $E010; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_DN ),
  576. ( i:A_ROXR; oc: $E4C0; ops:1;size: [S_W]; o1:AF_ALTM; o2:0 ),
  577. {* RTD 68010 *}
  578. ( i:A_RTE; oc: $4E73; ops:0;size: [S_NO]; o1:0; o2:0 ),
  579. ( i:A_RTR; oc: $4E77; ops:0;size: [S_NO]; o1:0; o2:0 ),
  580. ( i:A_RTS; oc: $4E75; ops:0;size: [S_NO]; o1:0; o2:0 ),
  581. ( i:A_SBCD; oc: $8100; ops:2;size: [S_B]; o1:AF_DN; o2:AF_DN ),
  582. ( i:A_SBCD; oc: $8108; ops:2;size: [S_B]; o1:AF_MMIND; o2:AF_MMIND ),
  583. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  584. {* SCC note; even though they are in the same group since all have the
  585. * same note if one isn't accepted none of the others will be either
  586. *}
  587. ( i:A_SCC; oc: $54C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  588. ( i:A_SCS; oc: $55C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  589. ( i:A_SEQ; oc: $57C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  590. ( i:A_SF; oc: $51C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  591. ( i:A_SGE; oc: $5CC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  592. ( i:A_SGT; oc: $5EC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  593. ( i:A_SHI; oc: $52C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  594. ( i:A_SLE; oc: $5FC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  595. ( i:A_SLS; oc: $53C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  596. ( i:A_SLT; oc: $5DC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  597. ( i:A_SMI; oc: $5BC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  598. ( i:A_SNE; oc: $56C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  599. ( i:A_SPL; oc: $5AC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  600. ( i:A_ST; oc: $50C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  601. ( i:A_SVC; oc: $58C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  602. ( i:A_SVS; oc: $59C0; ops:1;size: [S_B]; o1:AF_ALTNA; o2: 0 ),
  603. {* opcode Temp Rs EAs Rd EAd Siz Sizes SModes DModes Spec# *}
  604. ( i:A_STOP; oc: $4E72; ops:0; size: [S_W]; o1:AF_IMM; o2: 0 ),
  605. ( i:A_SUB; oc: $9000; ops:2;size: S_ALL; o1:AF_ALL; o2:AF_DN ),
  606. ( i:A_SUB; oc: $9100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_ALTM ),
  607. ( i:A_SUB; oc: $90C0; ops:2;size: [S_W]; o1:AF_ALL; o2:AF_AN ),
  608. ( i:A_SUB; oc: $91C0; ops:2;size: [S_L]; o1:AF_ALL; o2:AF_AN ),
  609. ( i:A_SUB; oc: $0400; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALTNA ),
  610. ( i:A_SUBQ; oc: $5100; ops:2;size: S_ALL; o1:AF_IMM; o2:AF_ALT ),
  611. ( i:A_SUBX; oc: $9100; ops:2;size: S_ALL; o1:AF_DN; o2:AF_DN ),
  612. ( i:A_SUBX; oc: $9108; ops:2;size: S_ALL; o1:AF_MMIND; o2:AF_MMIND ),
  613. ( i:A_SWAP; oc: $4840; ops:1;size: [S_W]; o1:AF_DN; o2:0 ),
  614. ( i:A_TAS; oc: $4AC0; ops:1;size: [S_B]; o1:AF_ALTNA; o2:0 ),
  615. ( i:A_TRAP; oc: $4E40; ops:1;size: [S_NO]; o1:AF_IMM; o2:0 ),
  616. ( i:A_TRAPV;oc: $4E76; ops:0;size: [S_NO]; o1:0; o2:0 ),
  617. ( i:A_TST; oc: $4A00; ops:1;size: S_ALL; o1:AF_ALTNA; o2:0 ),
  618. ( i:A_UNLK; oc: $4E58; ops:1;size: [S_NO]; o1:AF_AN; o2:0 ),
  619. ( i:A_NONE)
  620. );
  621. {****************************************************************************
  622. Assembler Mnemoics
  623. ****************************************************************************}
  624. const
  625. firstop = A_ABCD;
  626. lastop = A_LABEL;
  627. mot_op2str : array[firstop..lastop] of string[10] =
  628. { 68000 only instructions }
  629. ('abcd','add', 'adda','addi','addq','addx','and','andi',
  630. 'asl','asr','bcc','bcs','beq','bge','bgt','bhi',
  631. 'ble','bls','blt','bmi','bne','bpl','bvc','bvs',
  632. 'bchg','bclr','bra','bset','bsr','btst','chk',
  633. 'clr','cmp','cmpa','cmpi','cmpm','dbcc','dbcs','dbeq','dbge',
  634. 'dbgt','dbhi','dble','dbls','dblt','dbmi','dbne','dbra',
  635. 'dbpl','dbt','dbvc','dbvs','dbf','divs','divu',
  636. 'eor','eori','exg','illegal','ext','jmp','jsr',
  637. 'lea','link','lsl','lsr','move','movea','movei','moveq',
  638. 'movem','movep','muls','mulu','nbcd','neg','negx',
  639. 'nop','not','or','ori','pea','rol','ror','roxl',
  640. 'roxr','rtr','rts','sbcd','scc','scs','seq','sge',
  641. 'sgt','shi','sle','sls','slt','smi','sne',
  642. 'spl','st','svc','svs','sf','sub','suba','subi','subq',
  643. 'subx','swap','tas','trap','trapv','tst','unlk',
  644. 'rte','reset','stop',
  645. { MC68010 instructions }
  646. 'bkpt','movec','moves','rtd',
  647. { MC68020 instructions }
  648. 'bfchg','bfclr','bfexts','bfextu','bfffo',
  649. 'bfins','bfset','bftst','callm','cas','cas2',
  650. 'chk2','cmp2','divsl','divul','extb','pack','rtm',
  651. 'trapcc','tracs','trapeq','trapf','trapge','trapgt',
  652. 'traphi','traple','trapls','traplt','trapmi','trapne',
  653. 'trappl','trapt','trapvc','trapvs','unpk',
  654. { FPU Processor instructions - directly supported only. }
  655. { IEEE aware and misc. condition codes not supported }
  656. 'fabs','fadd',
  657. 'fbeq','fbne','fbngt','fbgt','fbge','fbnge',
  658. 'fblt','fbnlt','fble','fbgl','fbngl','fbgle','fbngle',
  659. 'fdbeq','fdbne','fdbgt','fdbngt','fdbge','fdnbge',
  660. 'fdblt','fdbnlt','fdble','fdbgl','fdbngl','fdbgle','fbdngle',
  661. 'fseq','fsne','fsgt','fsngt','fsge','fsnge',
  662. 'fslt','fsnlt','fsle','fsgl','fsngl','fsgle','fsngle',
  663. 'fcmp','fdiv','fmove','fmovem',
  664. 'fmul','fneg','fnop','fsqrt','fsub','fsgldiv',
  665. 'fsflmul','ftst',
  666. 'ftrapeq','ftrapne','ftrapgt','ftrapngt','ftrapge','ftrapnge',
  667. 'ftraplt','ftrapnlt','ftraple','ftrapgl','ftrapngl','ftrapgle',
  668. 'ftrapngle',
  669. { Useful for assembly langage output }
  670. { Protected instructions }
  671. 'cprestore','cpsave',
  672. { FPU Unit protected instructions }
  673. { and 68030/68851 common MMU instructions }
  674. { (this may include 68040 MMU instructions) }
  675. 'frestore','fsave','pflush','pflusha','pload','pmove','ptest',
  676. { Useful for assembly langage output }
  677. '');
  678. mot_opsize2str : array[topsize] of string[2] =
  679. ('','.b','.w','.l','.b','.b','.w',
  680. '.s','.d','.x','.s','.l','.q');
  681. { I don't know about S_IS, S_IL and S_IQ for m68k
  682. so I guessed, I am not even sure it can happen !!
  683. (PM) }
  684. mot_reg2str : array[R_NO..R_FPSR] of string[6] =
  685. ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
  686. 'a0','a1','a2','a3','a4','a5','a6','sp',
  687. '-(sp)','(sp)+',
  688. 'ccr','fp0','fp1','fp2','fp3','fp4','fp5',
  689. 'fp6','fp7','fpcr','sr','ssp','dfc',
  690. 'sfc','vbr','fpsr');
  691. gas_opsize2str : array[topsize] of string[2] =
  692. ('','.b','.w','.l','.b','.b','.w',
  693. '.s','.d','.x','.s','.l','.q');
  694. gas_reg2str : array[R_NO..R_FPSR] of string[6] =
  695. ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
  696. 'a0','a1','a2','a3','a4','a5','a6','sp',
  697. '-(sp)','(sp)+',
  698. 'ccr','fp0','fp1','fp2','fp3','fp4','fp5',
  699. 'fp6','fp7','fpcr','sr','ssp','dfc',
  700. 'sfc','vbr','fpsr');
  701. mit_opsize2str : array[topsize] of string[2] =
  702. ('','b','w','l','b','b','w',
  703. 's','d','x','s','l','q');
  704. mit_reg2str : array[R_NO..R_FPSR] of string[6] =
  705. ('', 'd0','d1','d2','d3','d4','d5','d6','d7',
  706. 'a0','a1','a2','a3','a4','a5','a6','sp',
  707. 'sp@-','sp@+',
  708. 'ccr','fp0','fp1','fp2','fp3','fp4','fp5',
  709. 'fp6','fp7','fpcr','sr','ssp','dfc',
  710. 'sfc','vbr','fpsr');
  711. gasPalmOS_reg2str : array[R_NO..R_FPSR] of string[6] =
  712. ('', '%d0','%d1','%d2','%d3','%d4','%d5','%d6','%d7',
  713. '%a0','%a1','%a2','%a3','%a4','%a5','%a6','%sp',
  714. '-(%sp)','(%sp)+',
  715. '%ccr','%fp0','%fp1','%fp2','%fp3','%fp4','%fp5',
  716. '%fp6','%fp7','%fpcr','%sr','%ssp','%dfc',
  717. '%sfc','%vbr','%fpsr');
  718. {*****************************************************************************
  719. Init/Done
  720. *****************************************************************************}
  721. procedure InitCpu;
  722. procedure DoneCpu;
  723. implementation
  724. uses
  725. strings,globals,verbose;
  726. function reg2str(r : tregister) : string;
  727. const
  728. a : array[R_NO..R_FPSR] of string[3] =
  729. ('','D0','D1','D2','D3','D4','D5','D6','D7',
  730. 'A0','A1','A2','A3','A4','A5','A6','A7',
  731. '-(SP)','(SP)+',
  732. 'CCR','FP0','FP1','FP2',
  733. 'FP3','FP4','FP5','FP6','FP7','FPCR','SR',
  734. 'SSP','DFC','SFC','VBR','FPSR');
  735. begin
  736. reg2str:=a[r];
  737. end;
  738. procedure disposereference(var r : preference);
  739. begin
  740. if assigned(r^.symbol) then
  741. stringdispose(r^.symbol);
  742. dispose(r);
  743. r:=nil;
  744. end;
  745. function newreference(const r : treference) : preference;
  746. var
  747. p : preference;
  748. begin
  749. new(p);
  750. p^:=r;
  751. if assigned(r.symbol) then
  752. p^.symbol:=stringdup(r.symbol^);
  753. newreference:=p;
  754. end;
  755. procedure reset_reference(var ref : treference);
  756. begin
  757. with ref do
  758. begin
  759. index:=R_NO;
  760. base:=R_NO;
  761. segment:=R_DEFAULT_SEG;
  762. offset:=0;
  763. scalefactor:=1;
  764. isintvalue:=false;
  765. symbol:=nil;
  766. direction := dir_none;
  767. end;
  768. end;
  769. function new_reference(base : tregister;offset : longint) : preference;
  770. var
  771. r : preference;
  772. begin
  773. new(r);
  774. reset_reference(r^);
  775. r^.base:=base;
  776. r^.offset:=offset;
  777. new_reference:=r;
  778. end;
  779. procedure clear_reference(var ref : treference);
  780. begin
  781. stringdispose(ref.symbol);
  782. reset_reference(ref);
  783. end;
  784. function newcsymbol(const s : string;l : longint) : pcsymbol;
  785. var
  786. p : pcsymbol;
  787. begin
  788. new(p);
  789. p^.symbol:=strpnew(s);
  790. p^.offset:=l;
  791. newcsymbol:=p;
  792. end;
  793. procedure disposecsymbol(p : pcsymbol);
  794. begin
  795. strdispose(p^.symbol);
  796. dispose(p);
  797. end;
  798. {****************************************************************************
  799. Taicpu
  800. ****************************************************************************}
  801. constructor taicpu.op_none(op : tasmop;_size : topsize);
  802. begin
  803. inherited init;
  804. typ:=ait_instruction;
  805. _operator:=op;
  806. op1t:=top_none;
  807. op2t:=top_none;
  808. op3t:=top_none;
  809. size:=_size;
  810. { the following isn't required ! }
  811. op1:=nil;
  812. op2:=nil;
  813. op3:=nil;
  814. end;
  815. constructor taicpu.op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  816. begin
  817. inherited init;
  818. typ:=ait_instruction;
  819. _operator:=op;
  820. op1t:=top_reg;
  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_const(op : tasmop;_size : topsize;_op1 : longint);
  829. begin
  830. inherited init;
  831. typ:=ait_instruction;
  832. _operator:=op;
  833. op1t:=top_const;
  834. op2t:=top_none;
  835. op3t:=top_none;
  836. size:=_size;
  837. op1:=pointer(_op1);
  838. op2:=nil;
  839. op3:=nil;
  840. end;
  841. constructor taicpu.op_ref(op : tasmop;_size : topsize;_op1 : preference);
  842. begin
  843. inherited init;
  844. typ:=ait_instruction;
  845. _operator:=op;
  846. op2t:=top_none;
  847. op3t:=top_none;
  848. size:=_size;
  849. if _op1^.isintvalue then
  850. begin
  851. op1t:=top_const;
  852. op1:=pointer(_op1^.offset);
  853. disposereference(_op1);
  854. end
  855. else
  856. begin
  857. op1t:=top_ref;
  858. op1:=pointer(_op1);
  859. end;
  860. op2:=nil;
  861. op3:=nil;
  862. end;
  863. constructor taicpu.op_loc(op : tasmop;_size : topsize;_op1 : tlocation);
  864. begin
  865. inherited init;
  866. typ:=ait_instruction;
  867. _operator:=op;
  868. op2t:=top_none;
  869. op3t:=top_none;
  870. size:=_size;
  871. if (_op1.loc=loc_register) or (_op1.loc=loc_cregister) then
  872. begin
  873. op1t:=top_reg;
  874. op1:=pointer(_op1.register);
  875. end
  876. else
  877. if _op1.reference.isintvalue then
  878. begin
  879. op1t:=top_const;
  880. op1:=pointer(_op1.reference.offset);
  881. end
  882. else
  883. begin
  884. op1t:=top_ref;
  885. op1:=pointer(newreference(_op1.reference));
  886. end;
  887. op2:=nil;
  888. op3:=nil;
  889. end;
  890. constructor taicpu.op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  891. begin
  892. inherited init;
  893. typ:=ait_instruction;
  894. _operator:=op;
  895. op1t:=top_reg;
  896. op2t:=top_reg;
  897. op3t:=top_none;
  898. size:=_size;
  899. op1:=pointer(_op1);
  900. op2:=pointer(_op2);
  901. op3:=nil;
  902. end;
  903. constructor taicpu.op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : preference);
  904. begin
  905. inherited init;
  906. typ:=ait_instruction;
  907. _operator:=op;
  908. op1t:=top_reg;
  909. op3t:=top_none;
  910. size:=_size;
  911. op1:=pointer(_op1);
  912. if _op2^.isintvalue then
  913. begin
  914. op2t:=top_const;
  915. op2:=pointer(_op2^.offset);
  916. disposereference(_op2);
  917. end
  918. else
  919. begin
  920. op2t:=top_ref;
  921. op2:=pointer(_op2);
  922. end;
  923. op3:=nil;
  924. end;
  925. constructor taicpu.op_reg_loc(op : tasmop;_size : topsize;_op1 : tregister;_op2 : tlocation);
  926. begin
  927. inherited init;
  928. typ:=ait_instruction;
  929. _operator:=op;
  930. op1t:=top_reg;
  931. op3t:=top_none;
  932. size:=_size;
  933. op1:=pointer(_op1);
  934. if (_op2.loc=loc_register) or (_op2.loc=loc_cregister) then
  935. begin
  936. op2t:=top_reg;
  937. op2:=pointer(_op2.register);
  938. end
  939. else
  940. if _op2.reference.isintvalue then
  941. begin
  942. op2t:=top_const;
  943. op2:=pointer(_op2.reference.offset);
  944. end
  945. else
  946. begin
  947. op2t:=top_ref;
  948. op2:=pointer(newreference(_op2.reference));
  949. end;
  950. op3:=nil;
  951. end;
  952. constructor taicpu.op_loc_reg(op : tasmop;_size : topsize;_op1 : tlocation;_op2 : tregister);
  953. begin
  954. inherited init;
  955. typ:=ait_instruction;
  956. _operator:=op;
  957. op2t:=top_reg;
  958. op3t:=top_none;
  959. size:=_size;
  960. op2:=pointer(_op2);
  961. if (_op1.loc=loc_register) or (_op1.loc=loc_cregister) then
  962. begin
  963. op1t:=top_reg;
  964. op1:=pointer(_op1.register);
  965. end
  966. else
  967. if _op1.reference.isintvalue then
  968. begin
  969. op1t:=top_const;
  970. op1:=pointer(_op1.reference.offset);
  971. end
  972. else
  973. begin
  974. op1t:=top_ref;
  975. op1:=pointer(newreference(_op1.reference));
  976. end;
  977. op3:=nil;
  978. end;
  979. constructor taicpu.op_const_reg_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister;_op3 : tregister);
  980. begin
  981. inherited init;
  982. typ:=ait_instruction;
  983. _operator:=op;
  984. op1t:=top_const;
  985. op2t:=top_reg;
  986. op3t:=top_reg;
  987. size:=_size;
  988. op1:=pointer(_op1);
  989. op2:=pointer(_op2);
  990. op3:=pointer(_op3);
  991. end;
  992. constructor taicpu.op_reg_const(op: tasmop; _size: topsize; _op1: tregister; _op2: longint);
  993. begin
  994. inherited init;
  995. typ := ait_instruction;
  996. _operator := op;
  997. op1t := top_reg;
  998. op2t := top_const;
  999. op3t := top_none;
  1000. op1 := pointer(_op1);
  1001. op2 := pointer(_op2);
  1002. size := _size;
  1003. end;
  1004. constructor taicpu.op_reg_reg_reg(op : tasmop;_size : topsize;_op1 : tregister;_op2 : tregister;_op3 : tregister);
  1005. begin
  1006. inherited init;
  1007. typ:=ait_instruction;
  1008. _operator:=op;
  1009. op1t:=top_reg;
  1010. op2t:=top_reg;
  1011. op3t:=top_reg;
  1012. size:=_size;
  1013. op1:=pointer(_op1);
  1014. op2:=pointer(_op2);
  1015. op3:=pointer(_op3);
  1016. end;
  1017. constructor taicpu.op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  1018. begin
  1019. inherited init;
  1020. typ:=ait_instruction;
  1021. _operator:=op;
  1022. op1t:=top_const;
  1023. op2t:=top_reg;
  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_const(op : tasmop;_size : topsize;_op1,_op2 : longint);
  1031. begin
  1032. inherited init;
  1033. typ:=ait_instruction;
  1034. _operator:=op;
  1035. op1t:=top_const;
  1036. op2t:=top_const;
  1037. op3t:=top_none;
  1038. size:=_size;
  1039. op1:=pointer(_op1);
  1040. op2:=pointer(_op2);
  1041. op3:=nil;
  1042. end;
  1043. constructor taicpu.op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : preference);
  1044. begin
  1045. inherited init;
  1046. typ:=ait_instruction;
  1047. _operator:=op;
  1048. op1t:=top_const;
  1049. op3t:=top_none;
  1050. size:=_size;
  1051. op1:=pointer(_op1);
  1052. if _op2^.isintvalue then
  1053. begin
  1054. op2t:=top_const;
  1055. op2:=pointer(_op2^.offset);
  1056. disposereference(_op2);
  1057. end
  1058. else
  1059. begin
  1060. op2t:=top_ref;
  1061. op2:=pointer(_op2);
  1062. end;
  1063. op3:=nil;
  1064. end;
  1065. constructor taicpu.op_const_loc(op : tasmop;_size : topsize;_op1 : longint;_op2 : tlocation);
  1066. begin
  1067. inherited init;
  1068. typ:=ait_instruction;
  1069. _operator:=op;
  1070. op1t:=top_const;
  1071. op3t:=top_none;
  1072. size:=_size;
  1073. op1:=pointer(_op1);
  1074. if (_op2.loc=loc_register) or (_op2.loc=loc_cregister) then
  1075. begin
  1076. op2t:=top_reg;
  1077. op2:=pointer(_op2.register);
  1078. end
  1079. else
  1080. if _op2.reference.isintvalue then
  1081. begin
  1082. op2t:=top_const;
  1083. op2:=pointer(_op2.reference.offset);
  1084. end
  1085. else
  1086. begin
  1087. op2t:=top_ref;
  1088. op2:=pointer(newreference(_op2.reference));
  1089. end;
  1090. op3:=nil;
  1091. end;
  1092. constructor taicpu.op_ref_reg(op : tasmop;_size : topsize;_op1 : preference;_op2 : tregister);
  1093. begin
  1094. inherited init;
  1095. typ:=ait_instruction;
  1096. _operator:=op;
  1097. op2t:=top_reg;
  1098. op3t:=top_none;
  1099. size:=_size;
  1100. op2:=pointer(_op2);
  1101. if _op1^.isintvalue then
  1102. begin
  1103. op1t:=top_const;
  1104. op1:=pointer(_op1^.offset);
  1105. disposereference(_op1);
  1106. end
  1107. else
  1108. begin
  1109. op1t:=top_ref;
  1110. op1:=pointer(_op1);
  1111. end;
  1112. op3:=nil;
  1113. end;
  1114. constructor taicpu.op_ref_ref(op : tasmop;_size : topsize;_op1,_op2 : preference);
  1115. begin
  1116. inherited init;
  1117. typ:=ait_instruction;
  1118. _operator:=op;
  1119. op3t:=top_none;
  1120. size:=_size;
  1121. if _op1^.isintvalue then
  1122. begin
  1123. op1t:=top_const;
  1124. op1:=pointer(_op1^.offset);
  1125. disposereference(_op1);
  1126. end
  1127. else
  1128. begin
  1129. op1t:=top_ref;
  1130. op1:=pointer(_op1);
  1131. end;
  1132. if _op2^.isintvalue then
  1133. begin
  1134. op2t:=top_const;
  1135. op2:=pointer(_op2^.offset);
  1136. disposereference(_op2);
  1137. end
  1138. else
  1139. begin
  1140. op2t:=top_ref;
  1141. op2:=pointer(_op2);
  1142. end;
  1143. op3:=nil;
  1144. end;
  1145. constructor taicpu.op_csymbol(op : tasmop;_size : topsize;_op1 : pcsymbol);
  1146. begin
  1147. inherited init;
  1148. typ:=ait_instruction;
  1149. _operator:=op;
  1150. if (op=A_JSR) and
  1151. (use_esp_stackframe) then
  1152. Message(cg_e_stackframe_with_esp);
  1153. op1t:=top_symbol;
  1154. op2t:=top_none;
  1155. op3t:=top_none;
  1156. size:=_size;
  1157. op1:=pointer(_op1);
  1158. op2:=nil;
  1159. op3:=nil;
  1160. end;
  1161. constructor taicpu.op_csymbol_reg(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : tregister);
  1162. begin
  1163. inherited init;
  1164. typ:=ait_instruction;
  1165. _operator:=op;
  1166. op1t:=top_symbol;
  1167. op2t:=top_reg;
  1168. op3t:=top_none;
  1169. size:=_size;
  1170. op1:=pointer(_op1);
  1171. op2:=pointer(_op2);
  1172. op3:=nil;
  1173. end;
  1174. constructor taicpu.op_csymbol_ref(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : preference);
  1175. begin
  1176. inherited init;
  1177. typ:=ait_instruction;
  1178. _operator:=op;
  1179. op1t:=top_symbol;
  1180. op3t:=top_none;
  1181. size:=_size;
  1182. op1:=pointer(_op1);
  1183. if _op2^.isintvalue then
  1184. begin
  1185. op2t:=top_const;
  1186. op2:=pointer(_op2^.offset);
  1187. disposereference(_op2);
  1188. end
  1189. else
  1190. begin
  1191. op2t:=top_ref;
  1192. op2:=pointer(_op2);
  1193. end;
  1194. op3:=nil;
  1195. end;
  1196. constructor taicpu.op_csymbol_loc(op : tasmop;_size : topsize;_op1 : pcsymbol;_op2 : tlocation);
  1197. begin
  1198. inherited init;
  1199. typ:=ait_instruction;
  1200. _operator:=op;
  1201. op1t:=top_symbol;
  1202. op3t:=top_none;
  1203. size:=_size;
  1204. op1:=pointer(_op1);
  1205. if (_op2.loc=loc_register) or (_op2.loc=loc_cregister) then
  1206. begin
  1207. op2t:=top_reg;
  1208. op2:=pointer(_op2.register);
  1209. end
  1210. else
  1211. if _op2.reference.isintvalue then
  1212. begin
  1213. op2t:=top_const;
  1214. op2:=pointer(_op2.reference.offset);
  1215. end
  1216. else
  1217. begin
  1218. op2t:=top_ref;
  1219. op2:=pointer(newreference(_op2.reference));
  1220. end;
  1221. op3:=nil;
  1222. end;
  1223. destructor taicpu.done;
  1224. begin
  1225. if op1t=top_symbol then
  1226. disposecsymbol(pcsymbol(op1))
  1227. else if op1t=top_ref then
  1228. begin
  1229. clear_reference(preference(op1)^);
  1230. dispose(preference(op1));
  1231. end;
  1232. if op2t=top_symbol then
  1233. disposecsymbol(pcsymbol(op2))
  1234. else if op2t=top_ref then
  1235. begin
  1236. clear_reference(preference(op2)^);
  1237. dispose(preference(op2));
  1238. end;
  1239. if op3t=top_symbol then
  1240. disposecsymbol(pcsymbol(op3))
  1241. else if op3t = top_ref then
  1242. begin
  1243. clear_reference(preference(op3)^);
  1244. dispose(preference(op3));
  1245. end;
  1246. inherited done;
  1247. end;
  1248. constructor taicpu.op_ref_reglist(op: tasmop; _size : topsize; _op1: preference;_op2: tregisterlist);
  1249. Begin
  1250. Inherited Init;
  1251. typ:=ait_instruction;
  1252. _operator:=op;
  1253. op2t:=top_reglist;
  1254. op3t:=top_none;
  1255. size:=_size;
  1256. reglist := _op2;
  1257. if _op1^.isintvalue then
  1258. begin
  1259. op1t:=top_const;
  1260. op1:=pointer(_op1^.offset);
  1261. disposereference(_op1);
  1262. end
  1263. else
  1264. begin
  1265. op1t:=top_ref;
  1266. op1:=pointer(_op1);
  1267. end;
  1268. op3:=nil;
  1269. end;
  1270. constructor taicpu.op_reglist_ref(op: tasmop; _size : topsize; _op1: tregisterlist; _op2: preference);
  1271. Begin
  1272. Inherited Init;
  1273. typ:=ait_instruction;
  1274. _operator:=op;
  1275. reglist:=_op1;
  1276. op1t:=top_reglist;
  1277. op3t:=top_none;
  1278. size:=_size;
  1279. if _op2^.isintvalue then
  1280. begin
  1281. op2t:=top_const;
  1282. op2:=pointer(_op2^.offset);
  1283. disposereference(_op2);
  1284. end
  1285. else
  1286. begin
  1287. op2t:=top_ref;
  1288. op2:=pointer(_op2);
  1289. end;
  1290. op3:=nil;
  1291. end;
  1292. {****************************************************************************
  1293. TAI_LABELED
  1294. ****************************************************************************}
  1295. constructor tai_labeled.init(op : tasmop; l : pasmlabel);
  1296. begin
  1297. inherited init;
  1298. typ:=ait_labeled_instruction;
  1299. _operator:=op;
  1300. _op1:=R_NO;
  1301. lab:=l;
  1302. inc(lab^.refs);
  1303. end;
  1304. constructor tai_labeled.init_reg(op : tasmop; l : pasmlabel; reg: tregister);
  1305. begin
  1306. inherited init;
  1307. typ:=ait_labeled_instruction;
  1308. _op1:=reg;
  1309. _operator:=op;
  1310. lab:=l;
  1311. inc(lab^.refs);
  1312. end;
  1313. destructor tai_labeled.done;
  1314. begin
  1315. dec(lab^.refs);
  1316. inherited done;
  1317. end;
  1318. {*****************************************************************************
  1319. Init/Done
  1320. *****************************************************************************}
  1321. procedure InitCpu;
  1322. begin
  1323. end;
  1324. procedure DoneCpu;
  1325. begin
  1326. end;
  1327. end.
  1328. {
  1329. $Log$
  1330. Revision 1.1 1999-09-16 23:05:57 florian
  1331. * m68k compiler is again compilable (only gas writer, no assembler reader)
  1332. Revision 1.12 1999/08/19 13:02:08 pierre
  1333. + label faillabel added for _FAIL support
  1334. Revision 1.11 1999/06/22 16:24:42 pierre
  1335. * local browser stuff corrected
  1336. Revision 1.10 1998/10/29 11:35:45 florian
  1337. * some dll support for win32
  1338. * fixed assembler writing for PalmOS
  1339. Revision 1.9 1998/10/14 08:47:18 pierre
  1340. * bugs in secondfuncret for result in subprocedures removed
  1341. Revision 1.8 1998/10/13 16:50:15 pierre
  1342. * undid some changes of Peter that made the compiler wrong
  1343. for m68k (I had to reinsert some ifdefs)
  1344. * removed several memory leaks under m68k
  1345. * removed the meory leaks for assembler readers
  1346. * cross compiling shoud work again better
  1347. ( crosscompiling sysamiga works
  1348. but as68k still complain about some code !)
  1349. Revision 1.7 1998/08/31 12:26:27 peter
  1350. * m68k and palmos updates from surebugfixes
  1351. Revision 1.6 1998/08/21 14:08:44 pierre
  1352. + TEST_FUNCRET now default (old code removed)
  1353. works also for m68k (at least compiles)
  1354. Revision 1.5 1998/06/04 23:51:45 peter
  1355. * m68k compiles
  1356. + .def file creation moved to gendef.pas so it could also be used
  1357. for win32
  1358. Revision 1.4 1998/05/23 01:21:10 peter
  1359. + aktasmmode, aktoptprocessor, aktoutputformat
  1360. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1361. + $LIBNAME to set the library name where the unit will be put in
  1362. * splitted cgi386 a bit (codeseg to large for bp7)
  1363. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1364. Revision 1.3 1998/05/11 13:07:54 peter
  1365. + $ifdef NEWPPU for the new ppuformat
  1366. + $define GDB not longer required
  1367. * removed all warnings and stripped some log comments
  1368. * no findfirst/findnext anymore to remove smartlink *.o files
  1369. Revision 1.2 1998/04/29 10:33:54 pierre
  1370. + added some code for ansistring (not complete nor working yet)
  1371. * corrected operator overloading
  1372. * corrected nasm output
  1373. + started inline procedures
  1374. + added starstarn : use ** for exponentiation (^ gave problems)
  1375. + started UseTokenInfo cond to get accurate positions
  1376. }