m68k.pas 58 KB

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