ra386int.pas 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  1. {
  2. Copyright (c) 1998-2002 by Carl Eric Codere and Peter Vreman
  3. Does the parsing process for the intel styled inline assembler.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. Unit Ra386int;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,
  22. cpubase,
  23. globtype,
  24. aasmbase,
  25. rasm,
  26. rax86;
  27. type
  28. tasmtoken = (
  29. AS_NONE,AS_LABEL,AS_LLABEL,AS_STRING,AS_INTNUM,
  30. AS_COMMA,AS_LBRACKET,AS_RBRACKET,AS_LPAREN,
  31. AS_RPAREN,AS_COLON,AS_DOT,AS_PLUS,AS_MINUS,AS_STAR,
  32. AS_SEPARATOR,AS_ID,AS_REGISTER,AS_OPCODE,AS_SLASH,
  33. {------------------ Assembler directives --------------------}
  34. AS_ALIGN,AS_DB,AS_DW,AS_DD,AS_END,
  35. {------------------ Assembler Operators --------------------}
  36. AS_BYTE,AS_WORD,AS_DWORD,AS_QWORD,AS_TBYTE,AS_DQWORD,AS_NEAR,AS_FAR,
  37. AS_HIGH,AS_LOW,AS_OFFSET,AS_SIZEOF,AS_SEG,AS_TYPE,AS_PTR,AS_MOD,AS_SHL,AS_SHR,AS_NOT,
  38. AS_AND,AS_OR,AS_XOR);
  39. type
  40. ti386intreader = class(tasmreader)
  41. actasmtoken : tasmtoken;
  42. prevasmtoken : tasmtoken;
  43. ActOpsize : topsize;
  44. constructor create;override;
  45. function is_asmopcode(const s: string):boolean;
  46. function is_asmoperator(const s: string):boolean;
  47. function is_asmdirective(const s: string):boolean;
  48. function is_register(const s:string):boolean;
  49. function is_locallabel(const s:string):boolean;
  50. function Assemble: tlinkedlist;override;
  51. procedure GetToken;
  52. function consume(t : tasmtoken):boolean;
  53. procedure RecoverConsume(allowcomma:boolean);
  54. procedure BuildRecordOffsetSize(const expr: string;var offset:aint;var size:aint);
  55. procedure BuildConstSymbolExpression(needofs,isref:boolean;var value:aint;var asmsym:string;var asmsymtyp:TAsmsymtype);
  56. function BuildConstExpression:aint;
  57. function BuildRefConstExpression:aint;
  58. procedure BuildReference(oper : tx86operand);
  59. procedure BuildOperand(oper: tx86operand;istypecast:boolean);
  60. procedure BuildConstantOperand(oper: tx86operand);
  61. procedure BuildOpCode(instr : tx86instruction);
  62. procedure BuildConstant(constsize: byte);
  63. end;
  64. implementation
  65. uses
  66. { common }
  67. cutils,
  68. { global }
  69. globals,verbose,
  70. systems,
  71. { aasm }
  72. aasmtai,aasmcpu,
  73. { symtable }
  74. symconst,symbase,symtype,symsym,symdef,symtable,
  75. { parser }
  76. scanner,
  77. { register allocator }
  78. rabase,rautils,itx86int,
  79. { codegen }
  80. cgbase,cgobj,procinfo
  81. ;
  82. type
  83. tasmkeyword = string[6];
  84. const
  85. { These tokens should be modified accordingly to the modifications }
  86. { in the different enumerations. }
  87. firstdirective = AS_ALIGN;
  88. lastdirective = AS_END;
  89. firstoperator = AS_BYTE;
  90. lastoperator = AS_XOR;
  91. _count_asmdirectives = longint(lastdirective)-longint(firstdirective);
  92. _count_asmoperators = longint(lastoperator)-longint(firstoperator);
  93. _asmdirectives : array[0.._count_asmdirectives] of tasmkeyword =
  94. ('ALIGN','DB','DW','DD','END');
  95. { problems with shl,shr,not,and,or and xor, they are }
  96. { context sensitive. }
  97. _asmoperators : array[0.._count_asmoperators] of tasmkeyword = (
  98. 'BYTE','WORD','DWORD','QWORD','TBYTE','DQWORD','NEAR','FAR','HIGH',
  99. 'LOW','OFFSET','SIZEOF','SEG','TYPE','PTR','MOD','SHL','SHR','NOT','AND',
  100. 'OR','XOR');
  101. token2str : array[tasmtoken] of string[10] = (
  102. '','Label','LLabel','String','Integer',
  103. ',','[',']','(',
  104. ')',':','.','+','-','*',
  105. ';','identifier','register','opcode','/',
  106. '','','','','END',
  107. '','','','','','','','','',
  108. '','','sizeof','','type','ptr','mod','shl','shr','not',
  109. 'and','or','xor'
  110. );
  111. var
  112. inexpression : boolean;
  113. constructor ti386intreader.create;
  114. var
  115. i : tasmop;
  116. str2opentry: tstr2opentry;
  117. Begin
  118. inherited create;
  119. { opcodes }
  120. { creates uppercased symbol tables for speed access }
  121. iasmops:=tdictionary.create;
  122. iasmops.delete_doubles:=true;
  123. for i:=firstop to lastop do
  124. begin
  125. str2opentry:=tstr2opentry.createname(upper(std_op2str[i]));
  126. str2opentry.op:=i;
  127. iasmops.insert(str2opentry);
  128. end;
  129. end;
  130. {---------------------------------------------------------------------}
  131. { Routines for the tokenizing }
  132. {---------------------------------------------------------------------}
  133. function ti386intreader.is_asmopcode(const s: string):boolean;
  134. var
  135. str2opentry: tstr2opentry;
  136. cond : string[4];
  137. cnd : tasmcond;
  138. j: longint;
  139. Begin
  140. is_asmopcode:=FALSE;
  141. actopcode:=A_None;
  142. actcondition:=C_None;
  143. actopsize:=S_NO;
  144. str2opentry:=tstr2opentry(iasmops.search(s));
  145. if assigned(str2opentry) then
  146. begin
  147. actopcode:=str2opentry.op;
  148. actasmtoken:=AS_OPCODE;
  149. is_asmopcode:=TRUE;
  150. exit;
  151. end;
  152. { not found yet, check condition opcodes }
  153. j:=0;
  154. while (j<CondAsmOps) do
  155. begin
  156. if Copy(s,1,Length(CondAsmOpStr[j]))=CondAsmOpStr[j] then
  157. begin
  158. cond:=Copy(s,Length(CondAsmOpStr[j])+1,255);
  159. if cond<>'' then
  160. begin
  161. for cnd:=low(TasmCond) to high(TasmCond) do
  162. if Cond=Upper(cond2str[cnd]) then
  163. begin
  164. actopcode:=CondASmOp[j];
  165. actcondition:=cnd;
  166. is_asmopcode:=TRUE;
  167. actasmtoken:=AS_OPCODE;
  168. exit
  169. end;
  170. end;
  171. end;
  172. inc(j);
  173. end;
  174. end;
  175. function ti386intreader.is_asmoperator(const s: string):boolean;
  176. var
  177. i : longint;
  178. Begin
  179. for i:=0 to _count_asmoperators do
  180. if s=_asmoperators[i] then
  181. begin
  182. actasmtoken:=tasmtoken(longint(firstoperator)+i);
  183. is_asmoperator:=true;
  184. exit;
  185. end;
  186. is_asmoperator:=false;
  187. end;
  188. Function ti386intreader.is_asmdirective(const s: string):boolean;
  189. var
  190. i : longint;
  191. Begin
  192. for i:=0 to _count_asmdirectives do
  193. if s=_asmdirectives[i] then
  194. begin
  195. actasmtoken:=tasmtoken(longint(firstdirective)+i);
  196. is_asmdirective:=true;
  197. exit;
  198. end;
  199. is_asmdirective:=false;
  200. end;
  201. function ti386intreader.is_register(const s:string):boolean;
  202. begin
  203. is_register:=false;
  204. actasmregister:=masm_regnum_search(lower(s));
  205. if actasmregister<>NR_NO then
  206. begin
  207. is_register:=true;
  208. actasmtoken:=AS_REGISTER;
  209. end;
  210. end;
  211. function ti386intreader.is_locallabel(const s:string):boolean;
  212. begin
  213. is_locallabel:=(length(s)>1) and (s[1]='@');
  214. end;
  215. Procedure ti386intreader.GetToken;
  216. var
  217. len : longint;
  218. forcelabel : boolean;
  219. srsym : tsym;
  220. srsymtable : tsymtable;
  221. begin
  222. { save old token and reset new token }
  223. prevasmtoken:=actasmtoken;
  224. actasmtoken:=AS_NONE;
  225. { reset }
  226. forcelabel:=FALSE;
  227. actasmpattern:='';
  228. { while space and tab , continue scan... }
  229. while (c in [' ',#9]) do
  230. c:=current_scanner.asmgetchar;
  231. { get token pos }
  232. if not (c in [#10,#13,'{',';']) then
  233. current_scanner.gettokenpos;
  234. { Local Label, Label, Directive, Prefix or Opcode }
  235. if firsttoken and not (c in [#10,#13,'{',';']) then
  236. begin
  237. firsttoken:=FALSE;
  238. len:=0;
  239. while c in ['A'..'Z','a'..'z','0'..'9','_','@'] do
  240. begin
  241. { if there is an at_sign, then this must absolutely be a label }
  242. if c = '@' then
  243. forcelabel:=TRUE;
  244. inc(len);
  245. actasmpattern[len]:=c;
  246. c:=current_scanner.asmgetchar;
  247. end;
  248. actasmpattern[0]:=chr(len);
  249. uppervar(actasmpattern);
  250. { allow spaces }
  251. while (c in [' ',#9]) do
  252. c:=current_scanner.asmgetchar;
  253. { label ? }
  254. if c = ':' then
  255. begin
  256. if actasmpattern[1]='@' then
  257. actasmtoken:=AS_LLABEL
  258. else
  259. actasmtoken:=AS_LABEL;
  260. { let us point to the next character }
  261. c:=current_scanner.asmgetchar;
  262. firsttoken:=true;
  263. exit;
  264. end;
  265. { Are we trying to create an identifier with }
  266. { an at-sign...? }
  267. if forcelabel then
  268. Message(asmr_e_none_label_contain_at);
  269. { opcode ? }
  270. If is_asmopcode(actasmpattern) then
  271. Begin
  272. { check if we are in an expression }
  273. { then continue with asm directives }
  274. if not inexpression then
  275. exit;
  276. end;
  277. if is_asmdirective(actasmpattern) then
  278. exit;
  279. message1(asmr_e_unknown_opcode,actasmpattern);
  280. actasmtoken:=AS_NONE;
  281. exit;
  282. end
  283. else { else firsttoken }
  284. begin
  285. case c of
  286. '@' : { possiblities : - local label reference , such as in jmp @local1 }
  287. { - @Result, @Code or @Data special variables. }
  288. begin
  289. actasmpattern:=c;
  290. c:=current_scanner.asmgetchar;
  291. while c in ['A'..'Z','a'..'z','0'..'9','_','@'] do
  292. begin
  293. actasmpattern:=actasmpattern + c;
  294. c:=current_scanner.asmgetchar;
  295. end;
  296. uppervar(actasmpattern);
  297. actasmtoken:=AS_ID;
  298. exit;
  299. end;
  300. 'A'..'Z','a'..'z','_': { identifier, register, opcode, prefix or directive }
  301. begin
  302. actasmpattern:=c;
  303. c:=current_scanner.asmgetchar;
  304. while c in ['A'..'Z','a'..'z','0'..'9','_'] do
  305. begin
  306. actasmpattern:=actasmpattern + c;
  307. c:=current_scanner.asmgetchar;
  308. end;
  309. uppervar(actasmpattern);
  310. { after prefix we allow also a new opcode }
  311. If is_prefix(actopcode) and is_asmopcode(actasmpattern) then
  312. Begin
  313. { if we are not in a constant }
  314. { expression than this is an }
  315. { opcode. }
  316. if not inexpression then
  317. exit;
  318. end;
  319. { support st(X) for fpu registers }
  320. if (actasmpattern = 'ST') and (c='(') then
  321. Begin
  322. actasmpattern:=actasmpattern+c;
  323. c:=current_scanner.asmgetchar;
  324. { allow spaces }
  325. while (c in [' ',#9]) do
  326. c:=current_scanner.asmgetchar;
  327. if c in ['0'..'7'] then
  328. actasmpattern:=actasmpattern + c
  329. else
  330. Message(asmr_e_invalid_fpu_register);
  331. c:=current_scanner.asmgetchar;
  332. { allow spaces }
  333. while (c in [' ',#9]) do
  334. c:=current_scanner.asmgetchar;
  335. if c <> ')' then
  336. Message(asmr_e_invalid_fpu_register)
  337. else
  338. Begin
  339. actasmpattern:=actasmpattern + c;
  340. c:=current_scanner.asmgetchar;
  341. end;
  342. end;
  343. if is_register(actasmpattern) then
  344. exit;
  345. if is_asmdirective(actasmpattern) then
  346. exit;
  347. if is_asmoperator(actasmpattern) then
  348. exit;
  349. { allow spaces }
  350. while (c in [' ',#9]) do
  351. c:=current_scanner.asmgetchar;
  352. { if next is a '.' and this is a unitsym then we also need to
  353. parse the identifier }
  354. if (c='.') then
  355. begin
  356. searchsym(actasmpattern,srsym,srsymtable);
  357. if assigned(srsym) and
  358. (srsym.typ=unitsym) and
  359. (srsym.owner.symtabletype in [staticsymtable,globalsymtable]) and
  360. srsym.owner.iscurrentunit then
  361. begin
  362. { Add . to create System.Identifier }
  363. actasmpattern:=actasmpattern+c;
  364. c:=current_scanner.asmgetchar;
  365. { Delphi allows System.@Halt, just ignore the @ }
  366. if c='@' then
  367. c:=current_scanner.asmgetchar;
  368. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  369. begin
  370. actasmpattern:=actasmpattern + upcase(c);
  371. c:=current_scanner.asmgetchar;
  372. end;
  373. end;
  374. end;
  375. actasmtoken:=AS_ID;
  376. exit;
  377. end;
  378. '''' : { string or character }
  379. begin
  380. actasmpattern:='';
  381. current_scanner.in_asm_string:=true;
  382. repeat
  383. if c = '''' then
  384. begin
  385. c:=current_scanner.asmgetchar;
  386. if c in [#10,#13] then
  387. begin
  388. Message(scan_f_string_exceeds_line);
  389. break;
  390. end;
  391. repeat
  392. if c='''' then
  393. begin
  394. c:=current_scanner.asmgetchar;
  395. if c='''' then
  396. begin
  397. actasmpattern:=actasmpattern+'''';
  398. c:=current_scanner.asmgetchar;
  399. if c in [#10,#13] then
  400. begin
  401. Message(scan_f_string_exceeds_line);
  402. break;
  403. end;
  404. end
  405. else
  406. break;
  407. end
  408. else
  409. begin
  410. actasmpattern:=actasmpattern+c;
  411. c:=current_scanner.asmgetchar;
  412. if c in [#10,#13] then
  413. begin
  414. Message(scan_f_string_exceeds_line);
  415. break
  416. end;
  417. end;
  418. until false; { end repeat }
  419. end
  420. else
  421. break; { end if }
  422. until false;
  423. current_scanner.in_asm_string:=false;
  424. actasmtoken:=AS_STRING;
  425. exit;
  426. end;
  427. '"' : { string or character }
  428. begin
  429. current_scanner.in_asm_string:=true;
  430. actasmpattern:='';
  431. repeat
  432. if c = '"' then
  433. begin
  434. c:=current_scanner.asmgetchar;
  435. if c in [#10,#13] then
  436. begin
  437. Message(scan_f_string_exceeds_line);
  438. break;
  439. end;
  440. repeat
  441. if c='"' then
  442. begin
  443. c:=current_scanner.asmgetchar;
  444. if c='"' then
  445. begin
  446. actasmpattern:=actasmpattern+'"';
  447. c:=current_scanner.asmgetchar;
  448. if c in [#10,#13] then
  449. begin
  450. Message(scan_f_string_exceeds_line);
  451. break;
  452. end;
  453. end
  454. else
  455. break;
  456. end
  457. else
  458. begin
  459. actasmpattern:=actasmpattern+c;
  460. c:=current_scanner.asmgetchar;
  461. if c in [#10,#13] then
  462. begin
  463. Message(scan_f_string_exceeds_line);
  464. break
  465. end;
  466. end;
  467. until false; { end repeat }
  468. end
  469. else
  470. break; { end if }
  471. until false;
  472. current_scanner.in_asm_string:=false;
  473. actasmtoken:=AS_STRING;
  474. exit;
  475. end;
  476. '$' :
  477. begin
  478. c:=current_scanner.asmgetchar;
  479. while c in ['0'..'9','A'..'F','a'..'f'] do
  480. begin
  481. actasmpattern:=actasmpattern + c;
  482. c:=current_scanner.asmgetchar;
  483. end;
  484. actasmpattern:=tostr(ParseVal(actasmpattern,16));
  485. actasmtoken:=AS_INTNUM;
  486. exit;
  487. end;
  488. ',' :
  489. begin
  490. actasmtoken:=AS_COMMA;
  491. c:=current_scanner.asmgetchar;
  492. exit;
  493. end;
  494. '[' :
  495. begin
  496. actasmtoken:=AS_LBRACKET;
  497. c:=current_scanner.asmgetchar;
  498. exit;
  499. end;
  500. ']' :
  501. begin
  502. actasmtoken:=AS_RBRACKET;
  503. c:=current_scanner.asmgetchar;
  504. exit;
  505. end;
  506. '(' :
  507. begin
  508. actasmtoken:=AS_LPAREN;
  509. c:=current_scanner.asmgetchar;
  510. exit;
  511. end;
  512. ')' :
  513. begin
  514. actasmtoken:=AS_RPAREN;
  515. c:=current_scanner.asmgetchar;
  516. exit;
  517. end;
  518. ':' :
  519. begin
  520. actasmtoken:=AS_COLON;
  521. c:=current_scanner.asmgetchar;
  522. exit;
  523. end;
  524. '.' :
  525. begin
  526. actasmtoken:=AS_DOT;
  527. c:=current_scanner.asmgetchar;
  528. exit;
  529. end;
  530. '+' :
  531. begin
  532. actasmtoken:=AS_PLUS;
  533. c:=current_scanner.asmgetchar;
  534. exit;
  535. end;
  536. '-' :
  537. begin
  538. actasmtoken:=AS_MINUS;
  539. c:=current_scanner.asmgetchar;
  540. exit;
  541. end;
  542. '*' :
  543. begin
  544. actasmtoken:=AS_STAR;
  545. c:=current_scanner.asmgetchar;
  546. exit;
  547. end;
  548. '/' :
  549. begin
  550. actasmtoken:=AS_SLASH;
  551. c:=current_scanner.asmgetchar;
  552. exit;
  553. end;
  554. '0'..'9':
  555. begin
  556. actasmpattern:=c;
  557. c:=current_scanner.asmgetchar;
  558. { Get the possible characters }
  559. while c in ['0'..'9','A'..'F','a'..'f'] do
  560. begin
  561. actasmpattern:=actasmpattern + c;
  562. c:=current_scanner.asmgetchar;
  563. end;
  564. { Get ending character }
  565. uppervar(actasmpattern);
  566. c:=upcase(c);
  567. { possibly a binary number. }
  568. if (actasmpattern[length(actasmpattern)] = 'B') and (c <> 'H') then
  569. Begin
  570. { Delete the last binary specifier }
  571. delete(actasmpattern,length(actasmpattern),1);
  572. actasmpattern:=tostr(ParseVal(actasmpattern,2));
  573. actasmtoken:=AS_INTNUM;
  574. exit;
  575. end
  576. else
  577. Begin
  578. case c of
  579. 'O' :
  580. Begin
  581. actasmpattern:=tostr(ParseVal(actasmpattern,8));
  582. actasmtoken:=AS_INTNUM;
  583. c:=current_scanner.asmgetchar;
  584. exit;
  585. end;
  586. 'H' :
  587. Begin
  588. actasmpattern:=tostr(ParseVal(actasmpattern,16));
  589. actasmtoken:=AS_INTNUM;
  590. c:=current_scanner.asmgetchar;
  591. exit;
  592. end;
  593. else { must be an integer number }
  594. begin
  595. actasmpattern:=tostr(ParseVal(actasmpattern,10));
  596. actasmtoken:=AS_INTNUM;
  597. exit;
  598. end;
  599. end;
  600. end;
  601. end;
  602. ';','{',#13,#10 :
  603. begin
  604. c:=current_scanner.asmgetchar;
  605. firsttoken:=TRUE;
  606. actasmtoken:=AS_SEPARATOR;
  607. exit;
  608. end;
  609. else
  610. current_scanner.illegal_char(c);
  611. end;
  612. end;
  613. end;
  614. function ti386intreader.consume(t : tasmtoken):boolean;
  615. begin
  616. Consume:=true;
  617. if t<>actasmtoken then
  618. begin
  619. Message2(scan_f_syn_expected,token2str[t],token2str[actasmtoken]);
  620. Consume:=false;
  621. end;
  622. repeat
  623. gettoken;
  624. until actasmtoken<>AS_NONE;
  625. end;
  626. procedure ti386intreader.RecoverConsume(allowcomma:boolean);
  627. begin
  628. While not (actasmtoken in [AS_SEPARATOR,AS_END]) do
  629. begin
  630. if allowcomma and (actasmtoken=AS_COMMA) then
  631. break;
  632. Consume(actasmtoken);
  633. end;
  634. end;
  635. {*****************************************************************************
  636. Parsing Helpers
  637. *****************************************************************************}
  638. { This routine builds up a record offset after a AS_DOT
  639. token is encountered.
  640. On entry actasmtoken should be equal to AS_DOT }
  641. Procedure ti386intreader.BuildRecordOffsetSize(const expr: string;var offset:aint;var size:aint);
  642. var
  643. s : string;
  644. Begin
  645. offset:=0;
  646. size:=0;
  647. s:=expr;
  648. while (actasmtoken=AS_DOT) do
  649. begin
  650. Consume(AS_DOT);
  651. if actasmtoken in [AS_BYTE,AS_ID,AS_WORD,AS_DWORD,AS_QWORD] then
  652. begin
  653. s:=s+'.'+actasmpattern;
  654. consume(actasmtoken);
  655. end
  656. else
  657. begin
  658. Consume(AS_ID);
  659. RecoverConsume(true);
  660. break;
  661. end;
  662. end;
  663. if not GetRecordOffsetSize(s,offset,size) then
  664. Message(asmr_e_building_record_offset);
  665. end;
  666. Procedure ti386intreader.BuildConstSymbolExpression(needofs,isref:boolean;var value:aint;var asmsym:string;var asmsymtyp:TAsmsymtype);
  667. var
  668. tempstr,expr,hs : string;
  669. parenlevel : longint;
  670. l,k : aint;
  671. hasparen,
  672. errorflag : boolean;
  673. prevtok : tasmtoken;
  674. hl : tasmlabel;
  675. hssymtyp : Tasmsymtype;
  676. def : tdef;
  677. sym : tsym;
  678. srsymtable : tsymtable;
  679. Begin
  680. { reset }
  681. value:=0;
  682. asmsym:='';
  683. asmsymtyp:=AT_DATA;
  684. errorflag:=FALSE;
  685. tempstr:='';
  686. expr:='';
  687. inexpression:=TRUE;
  688. parenlevel:=0;
  689. Repeat
  690. { Support ugly delphi constructs like: [ECX].1+2[EDX] }
  691. if isref and (actasmtoken=AS_LBRACKET) then
  692. break;
  693. Case actasmtoken of
  694. AS_LPAREN:
  695. Begin
  696. Consume(AS_LPAREN);
  697. expr:=expr + '(';
  698. inc(parenlevel);
  699. end;
  700. AS_RPAREN:
  701. Begin
  702. { Keep the AS_PAREN in actasmtoken, it is maybe a typecast }
  703. if parenlevel=0 then
  704. break;
  705. Consume(AS_RPAREN);
  706. expr:=expr + ')';
  707. dec(parenlevel);
  708. end;
  709. AS_SHL:
  710. Begin
  711. Consume(AS_SHL);
  712. expr:=expr + '<';
  713. end;
  714. AS_SHR:
  715. Begin
  716. Consume(AS_SHR);
  717. expr:=expr + '>';
  718. end;
  719. AS_SLASH:
  720. Begin
  721. Consume(AS_SLASH);
  722. expr:=expr + '/';
  723. end;
  724. AS_MOD:
  725. Begin
  726. Consume(AS_MOD);
  727. expr:=expr + '%';
  728. end;
  729. AS_STAR:
  730. Begin
  731. Consume(AS_STAR);
  732. if isref and (actasmtoken=AS_REGISTER) then
  733. break;
  734. expr:=expr + '*';
  735. end;
  736. AS_PLUS:
  737. Begin
  738. Consume(AS_PLUS);
  739. if isref and (actasmtoken=AS_REGISTER) then
  740. break;
  741. expr:=expr + '+';
  742. end;
  743. AS_MINUS:
  744. Begin
  745. Consume(AS_MINUS);
  746. expr:=expr + '-';
  747. end;
  748. AS_AND:
  749. Begin
  750. Consume(AS_AND);
  751. expr:=expr + '&';
  752. end;
  753. AS_NOT:
  754. Begin
  755. Consume(AS_NOT);
  756. expr:=expr + '~';
  757. end;
  758. AS_XOR:
  759. Begin
  760. Consume(AS_XOR);
  761. expr:=expr + '^';
  762. end;
  763. AS_OR:
  764. Begin
  765. Consume(AS_OR);
  766. expr:=expr + '|';
  767. end;
  768. AS_INTNUM:
  769. Begin
  770. expr:=expr + actasmpattern;
  771. Consume(AS_INTNUM);
  772. end;
  773. AS_OFFSET:
  774. begin
  775. Consume(AS_OFFSET);
  776. needofs:=true;
  777. if actasmtoken<>AS_ID then
  778. Message(asmr_e_offset_without_identifier);
  779. end;
  780. AS_SIZEOF,
  781. AS_TYPE:
  782. begin
  783. l:=0;
  784. hasparen:=false;
  785. Consume(actasmtoken);
  786. if actasmtoken=AS_LPAREN then
  787. begin
  788. hasparen:=true;
  789. Consume(AS_LPAREN);
  790. end;
  791. if actasmtoken<>AS_ID then
  792. Message(asmr_e_type_without_identifier)
  793. else
  794. begin
  795. tempstr:=actasmpattern;
  796. Consume(AS_ID);
  797. if actasmtoken=AS_DOT then
  798. BuildRecordOffsetSize(tempstr,k,l)
  799. else
  800. begin
  801. searchsym(tempstr,sym,srsymtable);
  802. if assigned(sym) then
  803. begin
  804. case sym.typ of
  805. globalvarsym,
  806. localvarsym,
  807. paravarsym :
  808. l:=tabstractvarsym(sym).getsize;
  809. typedconstsym :
  810. l:=ttypedconstsym(sym).getsize;
  811. typesym :
  812. l:=ttypesym(sym).restype.def.size;
  813. else
  814. Message(asmr_e_wrong_sym_type);
  815. end;
  816. end
  817. else
  818. Message1(sym_e_unknown_id,tempstr);
  819. end;
  820. end;
  821. str(l, tempstr);
  822. expr:=expr + tempstr;
  823. if hasparen then
  824. Consume(AS_RPAREN);
  825. end;
  826. AS_PTR :
  827. begin
  828. { Support ugly delphi constructs like <constant> PTR [ref] }
  829. break;
  830. end;
  831. AS_STRING:
  832. begin
  833. l:=0;
  834. case Length(actasmpattern) of
  835. 1 :
  836. l:=ord(actasmpattern[1]);
  837. 2 :
  838. l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
  839. 3 :
  840. l:=ord(actasmpattern[3]) +
  841. Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
  842. 4 :
  843. l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
  844. Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
  845. else
  846. Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
  847. end;
  848. str(l, tempstr);
  849. expr:=expr + tempstr;
  850. Consume(AS_STRING);
  851. end;
  852. AS_ID:
  853. begin
  854. hs:='';
  855. hssymtyp:=AT_DATA;
  856. def:=nil;
  857. tempstr:=actasmpattern;
  858. prevtok:=prevasmtoken;
  859. consume(AS_ID);
  860. if SearchIConstant(tempstr,l) then
  861. begin
  862. str(l, tempstr);
  863. expr:=expr + tempstr;
  864. end
  865. else
  866. begin
  867. if is_locallabel(tempstr) then
  868. begin
  869. CreateLocalLabel(tempstr,hl,false);
  870. hs:=hl.name;
  871. hssymtyp:=AT_FUNCTION;
  872. end
  873. else
  874. if SearchLabel(tempstr,hl,false) then
  875. begin
  876. hs:=hl.name;
  877. hssymtyp:=AT_FUNCTION;
  878. end
  879. else
  880. begin
  881. searchsym(tempstr,sym,srsymtable);
  882. if assigned(sym) then
  883. begin
  884. case sym.typ of
  885. globalvarsym :
  886. begin
  887. hs:=tglobalvarsym(sym).mangledname;
  888. def:=tglobalvarsym(sym).vartype.def;
  889. end;
  890. localvarsym,
  891. paravarsym :
  892. begin
  893. Message(asmr_e_no_local_or_para_allowed);
  894. end;
  895. typedconstsym :
  896. begin
  897. hs:=ttypedconstsym(sym).mangledname;
  898. def:=ttypedconstsym(sym).typedconsttype.def;
  899. end;
  900. procsym :
  901. begin
  902. if Tprocsym(sym).procdef_count>1 then
  903. Message(asmr_w_calling_overload_func);
  904. hs:=tprocsym(sym).first_procdef.mangledname;
  905. hssymtyp:=AT_FUNCTION;
  906. end;
  907. typesym :
  908. begin
  909. if not(ttypesym(sym).restype.def.deftype in [recorddef,objectdef]) then
  910. Message(asmr_e_wrong_sym_type);
  911. end;
  912. else
  913. Message(asmr_e_wrong_sym_type);
  914. end;
  915. end
  916. else
  917. Message1(sym_e_unknown_id,tempstr);
  918. end;
  919. { symbol found? }
  920. if hs<>'' then
  921. begin
  922. if asmsym='' then
  923. begin
  924. asmsym:=hs;
  925. asmsymtyp:=hssymtyp;
  926. end
  927. else
  928. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  929. if (expr='') or (expr[length(expr)]='+') then
  930. begin
  931. { don't remove the + if there could be a record field }
  932. if actasmtoken<>AS_DOT then
  933. delete(expr,length(expr),1);
  934. end
  935. else
  936. if needofs then
  937. begin
  938. if (prevtok<>AS_OFFSET) then
  939. Message(asmr_e_need_offset);
  940. end
  941. else
  942. Message(asmr_e_only_add_relocatable_symbol);
  943. end;
  944. if actasmtoken=AS_DOT then
  945. begin
  946. BuildRecordOffsetSize(tempstr,l,k);
  947. str(l, tempstr);
  948. expr:=expr + tempstr;
  949. end
  950. else
  951. begin
  952. if (expr='') or (expr[length(expr)] in ['+','-','/','*']) then
  953. delete(expr,length(expr),1);
  954. end;
  955. if (actasmtoken=AS_LBRACKET) and
  956. assigned(def) and
  957. (def.deftype=arraydef) then
  958. begin
  959. consume(AS_LBRACKET);
  960. l:=BuildConstExpression;
  961. if l<tarraydef(def).lowrange then
  962. begin
  963. Message(asmr_e_constant_out_of_bounds);
  964. l:=0;
  965. end
  966. else
  967. l:=(l-tarraydef(def).lowrange)*tarraydef(def).elesize;
  968. str(l, tempstr);
  969. expr:=expr + '+' + tempstr;
  970. consume(AS_RBRACKET);
  971. end;
  972. end;
  973. { check if there are wrong operator used like / or mod etc. }
  974. if (hs<>'') and not(actasmtoken in [AS_MINUS,AS_PLUS,AS_COMMA,AS_SEPARATOR,AS_END,AS_RBRACKET]) then
  975. Message(asmr_e_only_add_relocatable_symbol);
  976. end;
  977. AS_END,
  978. AS_RBRACKET,
  979. AS_SEPARATOR,
  980. AS_COMMA,
  981. AS_COLON:
  982. break;
  983. else
  984. begin
  985. { write error only once. }
  986. if not errorflag then
  987. Message(asmr_e_invalid_constant_expression);
  988. { consume tokens until we find COMMA or SEPARATOR }
  989. Consume(actasmtoken);
  990. errorflag:=TRUE;
  991. end;
  992. end;
  993. Until false;
  994. { calculate expression }
  995. if not ErrorFlag then
  996. value:=CalculateExpression(expr)
  997. else
  998. value:=0;
  999. { no longer in an expression }
  1000. inexpression:=FALSE;
  1001. end;
  1002. Function ti386intreader.BuildConstExpression:aint;
  1003. var
  1004. l : aint;
  1005. hs : string;
  1006. hssymtyp : TAsmsymtype;
  1007. begin
  1008. BuildConstSymbolExpression(false,false,l,hs,hssymtyp);
  1009. if hs<>'' then
  1010. Message(asmr_e_relocatable_symbol_not_allowed);
  1011. BuildConstExpression:=l;
  1012. end;
  1013. Function ti386intreader.BuildRefConstExpression:aint;
  1014. var
  1015. l : aint;
  1016. hs : string;
  1017. hssymtyp : TAsmsymtype;
  1018. begin
  1019. BuildConstSymbolExpression(false,true,l,hs,hssymtyp);
  1020. if hs<>'' then
  1021. Message(asmr_e_relocatable_symbol_not_allowed);
  1022. BuildRefConstExpression:=l;
  1023. end;
  1024. procedure ti386intreader.BuildReference(oper : tx86operand);
  1025. var
  1026. scale : byte;
  1027. k,l : aint;
  1028. tempstr,hs : string;
  1029. tempsymtyp : tasmsymtype;
  1030. code : integer;
  1031. hreg : tregister;
  1032. GotStar,GotOffset,HadVar,
  1033. GotPlus,Negative : boolean;
  1034. hl : tasmlabel;
  1035. Begin
  1036. Consume(AS_LBRACKET);
  1037. if not(oper.opr.typ in [OPR_LOCAL,OPR_REFERENCE]) then
  1038. oper.InitRef;
  1039. GotStar:=false;
  1040. GotPlus:=true;
  1041. GotOffset:=false;
  1042. Negative:=false;
  1043. Scale:=0;
  1044. repeat
  1045. if GotOffset and (actasmtoken<>AS_ID) then
  1046. Message(asmr_e_invalid_reference_syntax);
  1047. Case actasmtoken of
  1048. AS_ID: { Constant reference expression OR variable reference expression }
  1049. Begin
  1050. if not GotPlus then
  1051. Message(asmr_e_invalid_reference_syntax);
  1052. GotStar:=false;
  1053. GotPlus:=false;
  1054. if SearchIConstant(actasmpattern,l) or
  1055. SearchRecordType(actasmpattern) then
  1056. begin
  1057. l:=BuildRefConstExpression;
  1058. GotPlus:=(prevasmtoken=AS_PLUS);
  1059. GotStar:=(prevasmtoken=AS_STAR);
  1060. case oper.opr.typ of
  1061. OPR_LOCAL :
  1062. begin
  1063. if GotStar then
  1064. Message(asmr_e_invalid_reference_syntax);
  1065. if negative then
  1066. Dec(oper.opr.localsymofs,l)
  1067. else
  1068. Inc(oper.opr.localsymofs,l);
  1069. end;
  1070. OPR_REFERENCE :
  1071. begin
  1072. if GotStar then
  1073. oper.opr.ref.scalefactor:=l
  1074. else
  1075. begin
  1076. if negative then
  1077. Dec(oper.opr.ref.offset,l)
  1078. else
  1079. Inc(oper.opr.ref.offset,l);
  1080. end;
  1081. end;
  1082. end;
  1083. end
  1084. else
  1085. Begin
  1086. if oper.hasvar and not GotOffset then
  1087. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1088. HadVar:=oper.hasvar and GotOffset;
  1089. if negative then
  1090. Message(asmr_e_only_add_relocatable_symbol);
  1091. tempstr:=actasmpattern;
  1092. Consume(AS_ID);
  1093. { typecasting? }
  1094. if (actasmtoken=AS_LPAREN) and
  1095. SearchType(tempstr,l) then
  1096. begin
  1097. oper.hastype:=true;
  1098. oper.typesize:=l;
  1099. Consume(AS_LPAREN);
  1100. BuildOperand(oper,true);
  1101. Consume(AS_RPAREN);
  1102. end
  1103. else
  1104. if is_locallabel(tempstr) then
  1105. begin
  1106. CreateLocalLabel(tempstr,hl,false);
  1107. oper.InitRef;
  1108. oper.opr.ref.symbol:=hl;
  1109. oper.hasvar:=true;
  1110. end
  1111. else
  1112. if oper.SetupVar(tempstr,GotOffset) then
  1113. begin
  1114. { force OPR_LOCAL to be a reference }
  1115. if oper.opr.typ=OPR_LOCAL then
  1116. oper.opr.localforceref:=true;
  1117. end
  1118. else
  1119. Message1(sym_e_unknown_id,tempstr);
  1120. { record.field ? }
  1121. if actasmtoken=AS_DOT then
  1122. begin
  1123. BuildRecordOffsetSize(tempstr,l,k);
  1124. case oper.opr.typ of
  1125. OPR_LOCAL :
  1126. inc(oper.opr.localsymofs,l);
  1127. OPR_REFERENCE :
  1128. inc(oper.opr.ref.offset,l);
  1129. end;
  1130. end;
  1131. if GotOffset then
  1132. begin
  1133. if oper.hasvar and (oper.opr.ref.base=current_procinfo.framepointer) then
  1134. begin
  1135. if (oper.opr.typ=OPR_REFERENCE) then
  1136. oper.opr.ref.base:=NR_NO;
  1137. oper.hasvar:=hadvar;
  1138. end
  1139. else
  1140. begin
  1141. if oper.hasvar and hadvar then
  1142. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1143. { should we allow ?? }
  1144. end;
  1145. end;
  1146. end;
  1147. GotOffset:=false;
  1148. end;
  1149. AS_PLUS :
  1150. Begin
  1151. Consume(AS_PLUS);
  1152. Negative:=false;
  1153. GotPlus:=true;
  1154. GotStar:=false;
  1155. Scale:=0;
  1156. end;
  1157. AS_MINUS :
  1158. begin
  1159. Consume(AS_MINUS);
  1160. Negative:=true;
  1161. GotPlus:=true;
  1162. GotStar:=false;
  1163. Scale:=0;
  1164. end;
  1165. AS_STAR : { Scaling, with eax*4 order }
  1166. begin
  1167. Consume(AS_STAR);
  1168. hs:='';
  1169. l:=0;
  1170. case actasmtoken of
  1171. AS_LPAREN :
  1172. l:=BuildConstExpression;
  1173. AS_INTNUM:
  1174. Begin
  1175. hs:=actasmpattern;
  1176. Consume(AS_INTNUM);
  1177. end;
  1178. AS_REGISTER :
  1179. begin
  1180. case oper.opr.typ of
  1181. OPR_REFERENCE :
  1182. begin
  1183. if oper.opr.ref.scalefactor=0 then
  1184. begin
  1185. if scale<>0 then
  1186. begin
  1187. oper.opr.ref.scalefactor:=scale;
  1188. scale:=0;
  1189. end
  1190. else
  1191. Message(asmr_e_wrong_scale_factor);
  1192. end
  1193. else
  1194. Message(asmr_e_invalid_reference_syntax);
  1195. end;
  1196. OPR_LOCAL :
  1197. begin
  1198. if oper.opr.localscale=0 then
  1199. begin
  1200. if scale<>0 then
  1201. begin
  1202. oper.opr.localscale:=scale;
  1203. scale:=0;
  1204. end
  1205. else
  1206. Message(asmr_e_wrong_scale_factor);
  1207. end
  1208. else
  1209. Message(asmr_e_invalid_reference_syntax);
  1210. end;
  1211. end;
  1212. end;
  1213. else
  1214. Message(asmr_e_invalid_reference_syntax);
  1215. end;
  1216. if actasmtoken<>AS_REGISTER then
  1217. begin
  1218. if hs<>'' then
  1219. val(hs,l,code);
  1220. case oper.opr.typ of
  1221. OPR_REFERENCE :
  1222. oper.opr.ref.scalefactor:=l;
  1223. OPR_LOCAL :
  1224. oper.opr.localscale:=l;
  1225. end;
  1226. if l>9 then
  1227. Message(asmr_e_wrong_scale_factor);
  1228. end;
  1229. GotPlus:=false;
  1230. GotStar:=false;
  1231. end;
  1232. AS_REGISTER :
  1233. begin
  1234. if not((GotPlus and (not Negative)) or
  1235. GotStar) then
  1236. Message(asmr_e_invalid_reference_syntax);
  1237. hreg:=actasmregister;
  1238. Consume(AS_REGISTER);
  1239. { this register will be the index:
  1240. 1. just read a *
  1241. 2. next token is a *
  1242. 3. base register is already used }
  1243. case oper.opr.typ of
  1244. OPR_LOCAL :
  1245. begin
  1246. if (oper.opr.localindexreg<>NR_NO) then
  1247. Message(asmr_e_multiple_index);
  1248. oper.opr.localindexreg:=hreg;
  1249. if scale<>0 then
  1250. begin
  1251. oper.opr.localscale:=scale;
  1252. scale:=0;
  1253. end;
  1254. end;
  1255. OPR_REFERENCE :
  1256. begin
  1257. if (GotStar) or
  1258. (actasmtoken=AS_STAR) or
  1259. (oper.opr.ref.base<>NR_NO) then
  1260. begin
  1261. if (oper.opr.ref.index<>NR_NO) then
  1262. Message(asmr_e_multiple_index);
  1263. oper.opr.ref.index:=hreg;
  1264. if scale<>0 then
  1265. begin
  1266. oper.opr.ref.scalefactor:=scale;
  1267. scale:=0;
  1268. end;
  1269. end
  1270. else
  1271. oper.opr.ref.base:=hreg;
  1272. end;
  1273. end;
  1274. GotPlus:=false;
  1275. GotStar:=false;
  1276. end;
  1277. AS_OFFSET :
  1278. begin
  1279. Consume(AS_OFFSET);
  1280. GotOffset:=true;
  1281. end;
  1282. AS_TYPE,
  1283. AS_NOT,
  1284. AS_STRING,
  1285. AS_INTNUM,
  1286. AS_LPAREN : { Constant reference expression }
  1287. begin
  1288. if not GotPlus and not GotStar then
  1289. Message(asmr_e_invalid_reference_syntax);
  1290. BuildConstSymbolExpression(true,true,l,tempstr,tempsymtyp);
  1291. if tempstr<>'' then
  1292. begin
  1293. if GotStar then
  1294. Message(asmr_e_only_add_relocatable_symbol);
  1295. if not assigned(oper.opr.ref.symbol) then
  1296. oper.opr.ref.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp)
  1297. else
  1298. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1299. end;
  1300. case oper.opr.typ of
  1301. OPR_REFERENCE :
  1302. begin
  1303. if GotStar then
  1304. oper.opr.ref.scalefactor:=l
  1305. else if (prevasmtoken = AS_STAR) then
  1306. begin
  1307. if scale<>0 then
  1308. scale:=l*scale
  1309. else
  1310. scale:=l;
  1311. end
  1312. else
  1313. begin
  1314. if negative then
  1315. Dec(oper.opr.ref.offset,l)
  1316. else
  1317. Inc(oper.opr.ref.offset,l);
  1318. end;
  1319. end;
  1320. OPR_LOCAL :
  1321. begin
  1322. if GotStar then
  1323. oper.opr.localscale:=l
  1324. else if (prevasmtoken = AS_STAR) then
  1325. begin
  1326. if scale<>0 then
  1327. scale:=l*scale
  1328. else
  1329. scale:=l;
  1330. end
  1331. else
  1332. begin
  1333. if negative then
  1334. Dec(oper.opr.localsymofs,l)
  1335. else
  1336. Inc(oper.opr.localsymofs,l);
  1337. end;
  1338. end;
  1339. end;
  1340. GotPlus:=(prevasmtoken=AS_PLUS) or
  1341. (prevasmtoken=AS_MINUS);
  1342. if GotPlus then
  1343. negative := prevasmtoken = AS_MINUS;
  1344. GotStar:=(prevasmtoken=AS_STAR);
  1345. end;
  1346. AS_RBRACKET :
  1347. begin
  1348. if GotPlus or GotStar then
  1349. Message(asmr_e_invalid_reference_syntax);
  1350. Consume(AS_RBRACKET);
  1351. break;
  1352. end;
  1353. else
  1354. Begin
  1355. Message(asmr_e_invalid_reference_syntax);
  1356. RecoverConsume(true);
  1357. break;
  1358. end;
  1359. end;
  1360. until false;
  1361. end;
  1362. Procedure ti386intreader.BuildConstantOperand(oper: tx86operand);
  1363. var
  1364. l : aint;
  1365. tempstr : string;
  1366. tempsymtyp : tasmsymtype;
  1367. begin
  1368. if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
  1369. Message(asmr_e_invalid_operand_type);
  1370. BuildConstSymbolExpression(true,false,l,tempstr,tempsymtyp);
  1371. if tempstr<>'' then
  1372. begin
  1373. oper.opr.typ:=OPR_SYMBOL;
  1374. oper.opr.symofs:=l;
  1375. oper.opr.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp);
  1376. end
  1377. else
  1378. if oper.opr.typ=OPR_NONE then
  1379. begin
  1380. oper.opr.typ:=OPR_CONSTANT;
  1381. oper.opr.val:=l;
  1382. end
  1383. else
  1384. inc(oper.opr.val,l);
  1385. end;
  1386. Procedure ti386intreader.BuildOperand(oper: tx86operand;istypecast:boolean);
  1387. procedure AddLabelOperand(hl:tasmlabel);
  1388. begin
  1389. if (oper.opr.typ=OPR_NONE) and
  1390. is_calljmp(actopcode) then
  1391. begin
  1392. oper.opr.typ:=OPR_SYMBOL;
  1393. oper.opr.symbol:=hl;
  1394. end
  1395. else
  1396. begin
  1397. oper.InitRef;
  1398. oper.opr.ref.symbol:=hl;
  1399. end;
  1400. end;
  1401. var
  1402. expr : string;
  1403. tempreg : tregister;
  1404. l : aint;
  1405. hl : tasmlabel;
  1406. toffset,
  1407. tsize : aint;
  1408. begin
  1409. expr:='';
  1410. repeat
  1411. if actasmtoken=AS_DOT then
  1412. begin
  1413. if expr<>'' then
  1414. begin
  1415. BuildRecordOffsetSize(expr,toffset,tsize);
  1416. oper.SetSize(tsize,true);
  1417. case oper.opr.typ of
  1418. OPR_LOCAL :
  1419. begin
  1420. { don't allow direct access to fields of parameters, becuase that
  1421. will generate buggy code. Allow it only for explicit typecasting
  1422. and when the parameter is in a register (delphi compatible) }
  1423. if (not oper.hastype) and
  1424. (oper.opr.localsym.owner.symtabletype=parasymtable) and
  1425. (current_procinfo.procdef.proccalloption<>pocall_register) then
  1426. Message(asmr_e_cannot_access_field_directly_for_parameters);
  1427. inc(oper.opr.localsymofs,toffset)
  1428. end;
  1429. OPR_CONSTANT :
  1430. inc(oper.opr.val,toffset);
  1431. OPR_REFERENCE :
  1432. inc(oper.opr.ref.offset,toffset);
  1433. OPR_NONE :
  1434. begin
  1435. oper.opr.typ:=OPR_CONSTANT;
  1436. oper.opr.val:=toffset;
  1437. end;
  1438. else
  1439. internalerror(200309222);
  1440. end;
  1441. expr:='';
  1442. end
  1443. else
  1444. begin
  1445. { See it as a separator }
  1446. Consume(AS_DOT);
  1447. end;
  1448. end;
  1449. case actasmtoken of
  1450. AS_OFFSET,
  1451. AS_SIZEOF,
  1452. AS_TYPE,
  1453. AS_NOT,
  1454. AS_STRING,
  1455. AS_PLUS,
  1456. AS_MINUS,
  1457. AS_LPAREN,
  1458. AS_INTNUM :
  1459. begin
  1460. case oper.opr.typ of
  1461. OPR_REFERENCE :
  1462. inc(oper.opr.ref.offset,BuildRefConstExpression);
  1463. OPR_LOCAL :
  1464. inc(oper.opr.localsymofs,BuildConstExpression);
  1465. OPR_NONE,
  1466. OPR_CONSTANT :
  1467. BuildConstantOperand(oper);
  1468. else
  1469. Message(asmr_e_invalid_operand_type);
  1470. end;
  1471. end;
  1472. AS_PTR :
  1473. begin
  1474. if not oper.hastype then
  1475. begin
  1476. if (oper.opr.typ=OPR_CONSTANT) then
  1477. begin
  1478. oper.typesize:=oper.opr.val;
  1479. { reset constant value of operand }
  1480. oper.opr.typ:=OPR_NONE;
  1481. oper.opr.val:=0;
  1482. end
  1483. else
  1484. Message(asmr_e_syn_operand);
  1485. end;
  1486. Consume(AS_PTR);
  1487. oper.InitRef;
  1488. BuildOperand(oper,false);
  1489. end;
  1490. AS_ID : { A constant expression, or a Variable ref. }
  1491. Begin
  1492. { Label or Special symbol reference? }
  1493. if actasmpattern[1] = '@' then
  1494. Begin
  1495. if actasmpattern = '@RESULT' then
  1496. Begin
  1497. oper.SetupResult;
  1498. Consume(AS_ID);
  1499. end
  1500. else
  1501. if (actasmpattern = '@CODE') or (actasmpattern = '@DATA') then
  1502. begin
  1503. Message(asmr_w_CODE_and_DATA_not_supported);
  1504. Consume(AS_ID);
  1505. end
  1506. else
  1507. { Local Label }
  1508. begin
  1509. CreateLocalLabel(actasmpattern,hl,false);
  1510. Consume(AS_ID);
  1511. AddLabelOperand(hl);
  1512. end;
  1513. end
  1514. else
  1515. { support result for delphi modes }
  1516. if (m_objpas in aktmodeswitches) and (actasmpattern='RESULT') then
  1517. begin
  1518. oper.SetUpResult;
  1519. Consume(AS_ID);
  1520. end
  1521. { probably a variable or normal expression }
  1522. { or a procedure (such as in CALL ID) }
  1523. else
  1524. Begin
  1525. { is it a constant ? }
  1526. if SearchIConstant(actasmpattern,l) then
  1527. Begin
  1528. case oper.opr.typ of
  1529. OPR_REFERENCE :
  1530. inc(oper.opr.ref.offset,BuildRefConstExpression);
  1531. OPR_LOCAL :
  1532. inc(oper.opr.localsymofs,BuildRefConstExpression);
  1533. OPR_NONE,
  1534. OPR_CONSTANT :
  1535. BuildConstantOperand(oper);
  1536. else
  1537. Message(asmr_e_invalid_operand_type);
  1538. end;
  1539. end
  1540. else
  1541. { Check for pascal label }
  1542. if SearchLabel(actasmpattern,hl,false) then
  1543. begin
  1544. Consume(AS_ID);
  1545. AddLabelOperand(hl);
  1546. end
  1547. else
  1548. { is it a normal variable ? }
  1549. Begin
  1550. expr:=actasmpattern;
  1551. Consume(AS_ID);
  1552. { typecasting? }
  1553. if SearchType(expr,l) then
  1554. begin
  1555. oper.hastype:=true;
  1556. oper.typesize:=l;
  1557. case actasmtoken of
  1558. AS_LPAREN :
  1559. begin
  1560. { Support Type([Reference]) }
  1561. Consume(AS_LPAREN);
  1562. BuildOperand(oper,true);
  1563. Consume(AS_RPAREN);
  1564. end;
  1565. AS_LBRACKET :
  1566. begin
  1567. { Support Var.Type[Index] }
  1568. { Convert @label.Byte[1] to reference }
  1569. if oper.opr.typ=OPR_SYMBOL then
  1570. oper.initref;
  1571. end;
  1572. end;
  1573. end
  1574. else
  1575. begin
  1576. if not oper.SetupVar(expr,false) then
  1577. Begin
  1578. { not a variable, check special variables.. }
  1579. if expr = 'SELF' then
  1580. oper.SetupSelf
  1581. else
  1582. Message1(sym_e_unknown_id,expr);
  1583. expr:='';
  1584. end;
  1585. end;
  1586. end;
  1587. end;
  1588. end;
  1589. AS_REGISTER : { Register, a variable reference or a constant reference }
  1590. begin
  1591. { save the type of register used. }
  1592. tempreg:=actasmregister;
  1593. Consume(AS_REGISTER);
  1594. if actasmtoken = AS_COLON then
  1595. Begin
  1596. Consume(AS_COLON);
  1597. oper.InitRef;
  1598. oper.opr.ref.segment:=tempreg;
  1599. BuildReference(oper);
  1600. end
  1601. else
  1602. { Simple register }
  1603. begin
  1604. if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then
  1605. Message(asmr_e_invalid_operand_type);
  1606. oper.opr.typ:=OPR_REGISTER;
  1607. oper.opr.reg:=tempreg;
  1608. oper.SetSize(tcgsize2size[reg_cgsize(oper.opr.reg)],true);
  1609. end;
  1610. end;
  1611. AS_LBRACKET: { a variable reference, register ref. or a constant reference }
  1612. Begin
  1613. BuildReference(oper);
  1614. end;
  1615. AS_SEG :
  1616. Begin
  1617. Message(asmr_e_seg_not_supported);
  1618. Consume(actasmtoken);
  1619. end;
  1620. AS_DWORD,
  1621. AS_BYTE,
  1622. AS_WORD,
  1623. AS_TBYTE,
  1624. AS_DQWORD,
  1625. AS_QWORD :
  1626. begin
  1627. { Type specifier }
  1628. oper.hastype:=true;
  1629. oper.typesize:=0;
  1630. case actasmtoken of
  1631. AS_DWORD : oper.typesize:=4;
  1632. AS_WORD : oper.typesize:=2;
  1633. AS_BYTE : oper.typesize:=1;
  1634. AS_QWORD : oper.typesize:=8;
  1635. AS_DQWORD : oper.typesize:=16;
  1636. AS_TBYTE : oper.typesize:=10;
  1637. end;
  1638. Consume(actasmtoken);
  1639. if (actasmtoken=AS_LPAREN) then
  1640. begin
  1641. { Support Type([Reference]) }
  1642. Consume(AS_LPAREN);
  1643. BuildOperand(oper,true);
  1644. Consume(AS_RPAREN);
  1645. end;
  1646. end;
  1647. AS_SEPARATOR,
  1648. AS_END,
  1649. AS_COMMA,
  1650. AS_COLON:
  1651. begin
  1652. break;
  1653. end;
  1654. AS_RPAREN:
  1655. begin
  1656. if not istypecast then
  1657. begin
  1658. Message(asmr_e_syn_operand);
  1659. Consume(AS_RPAREN);
  1660. end
  1661. else
  1662. break;
  1663. end;
  1664. else
  1665. begin
  1666. Message(asmr_e_syn_operand);
  1667. RecoverConsume(true);
  1668. break;
  1669. end;
  1670. end;
  1671. until false;
  1672. { End of operand, update size if a typecast is forced }
  1673. if (oper.typesize<>0) and
  1674. (oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL]) then
  1675. oper.SetSize(oper.typesize,true);
  1676. end;
  1677. Procedure ti386intreader.BuildOpCode(instr : tx86instruction);
  1678. var
  1679. PrefixOp,OverrideOp: tasmop;
  1680. operandnum : longint;
  1681. is_far_const:boolean;
  1682. i:byte;
  1683. begin
  1684. PrefixOp:=A_None;
  1685. OverrideOp:=A_None;
  1686. is_far_const:=false;
  1687. { prefix seg opcode / prefix opcode }
  1688. repeat
  1689. if is_prefix(actopcode) then
  1690. with instr do
  1691. begin
  1692. OpOrder:=op_intel;
  1693. PrefixOp:=ActOpcode;
  1694. opcode:=ActOpcode;
  1695. condition:=ActCondition;
  1696. opsize:=ActOpsize;
  1697. ConcatInstruction(curlist);
  1698. consume(AS_OPCODE);
  1699. end
  1700. else
  1701. if is_override(actopcode) then
  1702. with instr do
  1703. begin
  1704. OpOrder:=op_intel;
  1705. OverrideOp:=ActOpcode;
  1706. opcode:=ActOpcode;
  1707. condition:=ActCondition;
  1708. opsize:=ActOpsize;
  1709. ConcatInstruction(curlist);
  1710. consume(AS_OPCODE);
  1711. end
  1712. else
  1713. break;
  1714. { allow for newline after prefix or override }
  1715. while actasmtoken=AS_SEPARATOR do
  1716. consume(AS_SEPARATOR);
  1717. until (actasmtoken<>AS_OPCODE);
  1718. { opcode }
  1719. if (actasmtoken <> AS_OPCODE) then
  1720. begin
  1721. Message(asmr_e_invalid_or_missing_opcode);
  1722. RecoverConsume(false);
  1723. exit;
  1724. end;
  1725. { Fill the instr object with the current state }
  1726. with instr do
  1727. begin
  1728. OpOrder:=op_intel;
  1729. Opcode:=ActOpcode;
  1730. condition:=ActCondition;
  1731. opsize:=ActOpsize;
  1732. { Valid combination of prefix/override and instruction ? }
  1733. if (prefixop<>A_NONE) and (NOT CheckPrefix(PrefixOp,actopcode)) then
  1734. Message1(asmr_e_invalid_prefix_and_opcode,actasmpattern);
  1735. if (overrideop<>A_NONE) and (NOT CheckOverride(OverrideOp,ActOpcode)) then
  1736. Message1(asmr_e_invalid_override_and_opcode,actasmpattern);
  1737. end;
  1738. { We are reading operands, so opcode will be an AS_ID }
  1739. operandnum:=1;
  1740. is_far_const:=false;
  1741. Consume(AS_OPCODE);
  1742. { Zero operand opcode ? }
  1743. if actasmtoken in [AS_SEPARATOR,AS_END] then
  1744. begin
  1745. operandnum:=0;
  1746. exit;
  1747. end;
  1748. { Read Operands }
  1749. repeat
  1750. case actasmtoken of
  1751. { End of asm operands for this opcode }
  1752. AS_END,
  1753. AS_SEPARATOR :
  1754. break;
  1755. { Operand delimiter }
  1756. AS_COMMA :
  1757. begin
  1758. if operandnum > Max_Operands then
  1759. Message(asmr_e_too_many_operands)
  1760. else
  1761. Inc(operandnum);
  1762. Consume(AS_COMMA);
  1763. end;
  1764. {Far constant, i.e. jmp $0000:$11111111.}
  1765. AS_COLON:
  1766. begin
  1767. is_far_const:=true;
  1768. if operandnum>1 then
  1769. message(asmr_e_too_many_operands)
  1770. else
  1771. inc(operandnum);
  1772. consume(AS_COLON);
  1773. end;
  1774. { Type specifier }
  1775. AS_NEAR,
  1776. AS_FAR :
  1777. begin
  1778. if actasmtoken = AS_NEAR then
  1779. begin
  1780. Message(asmr_w_near_ignored);
  1781. instr.opsize:=S_NEAR;
  1782. end
  1783. else
  1784. begin
  1785. Message(asmr_w_far_ignored);
  1786. instr.opsize:=S_FAR;
  1787. end;
  1788. Consume(actasmtoken);
  1789. if actasmtoken=AS_PTR then
  1790. begin
  1791. Consume(AS_PTR);
  1792. instr.Operands[operandnum].InitRef;
  1793. end;
  1794. BuildOperand(instr.Operands[operandnum] as tx86operand,false);
  1795. end;
  1796. else
  1797. BuildOperand(instr.Operands[operandnum] as tx86operand,false);
  1798. end; { end case }
  1799. until false;
  1800. instr.ops:=operandnum;
  1801. { Check operands }
  1802. for i:=1 to operandnum do
  1803. begin
  1804. if is_far_const and
  1805. (instr.operands[i].opr.typ<>OPR_CONSTANT) then
  1806. message(asmr_e_expr_illegal)
  1807. else
  1808. if instr.operands[i].opr.typ=OPR_NONE then
  1809. Message(asmr_e_syntax_error);
  1810. end;
  1811. end;
  1812. Procedure ti386intreader.BuildConstant(constsize: byte);
  1813. var
  1814. asmsymtyp : tasmsymtype;
  1815. asmsym,
  1816. expr: string;
  1817. value : aint;
  1818. Begin
  1819. Repeat
  1820. Case actasmtoken of
  1821. AS_STRING:
  1822. Begin
  1823. { DD and DW cases }
  1824. if constsize <> 1 then
  1825. Begin
  1826. if Not PadZero(actasmpattern,constsize) then
  1827. Message(scan_f_string_exceeds_line);
  1828. end;
  1829. expr:=actasmpattern;
  1830. Consume(AS_STRING);
  1831. Case actasmtoken of
  1832. AS_COMMA:
  1833. Consume(AS_COMMA);
  1834. AS_END,
  1835. AS_SEPARATOR: ;
  1836. else
  1837. Message(asmr_e_invalid_string_expression);
  1838. end;
  1839. ConcatString(curlist,expr);
  1840. end;
  1841. AS_PLUS,
  1842. AS_MINUS,
  1843. AS_LPAREN,
  1844. AS_NOT,
  1845. AS_INTNUM,
  1846. AS_ID :
  1847. Begin
  1848. BuildConstSymbolExpression(false,false,value,asmsym,asmsymtyp);
  1849. if asmsym<>'' then
  1850. begin
  1851. if constsize<>sizeof(aint) then
  1852. Message1(asmr_w_const32bit_for_address,asmsym);
  1853. ConcatConstSymbol(curlist,asmsym,asmsymtyp,value)
  1854. end
  1855. else
  1856. ConcatConstant(curlist,value,constsize);
  1857. end;
  1858. AS_COMMA:
  1859. Consume(AS_COMMA);
  1860. AS_END,
  1861. AS_SEPARATOR:
  1862. break;
  1863. else
  1864. begin
  1865. Message(asmr_e_syn_constant);
  1866. RecoverConsume(false);
  1867. end
  1868. end;
  1869. Until false;
  1870. end;
  1871. function ti386intreader.Assemble: tlinkedlist;
  1872. Var
  1873. hl : tasmlabel;
  1874. instr : Tx86Instruction;
  1875. Begin
  1876. Message1(asmr_d_start_reading,'intel');
  1877. inexpression:=FALSE;
  1878. firsttoken:=TRUE;
  1879. { sets up all opcode and register tables in uppercase
  1880. done in the construtor now
  1881. if not _asmsorted then
  1882. Begin
  1883. SetupTables;
  1884. _asmsorted:=TRUE;
  1885. end;
  1886. }
  1887. curlist:=TAAsmoutput.Create;
  1888. { setup label linked list }
  1889. LocalLabelList:=TLocalLabelList.Create;
  1890. { start tokenizer }
  1891. c:=current_scanner.asmgetcharstart;
  1892. gettoken;
  1893. { main loop }
  1894. repeat
  1895. case actasmtoken of
  1896. AS_LLABEL:
  1897. Begin
  1898. if CreateLocalLabel(actasmpattern,hl,true) then
  1899. ConcatLabel(curlist,hl);
  1900. Consume(AS_LLABEL);
  1901. end;
  1902. AS_LABEL:
  1903. Begin
  1904. if SearchLabel(upper(actasmpattern),hl,true) then
  1905. ConcatLabel(curlist,hl)
  1906. else
  1907. Message1(asmr_e_unknown_label_identifier,actasmpattern);
  1908. Consume(AS_LABEL);
  1909. end;
  1910. AS_DW :
  1911. Begin
  1912. inexpression:=true;
  1913. Consume(AS_DW);
  1914. BuildConstant(2);
  1915. inexpression:=false;
  1916. end;
  1917. AS_DB :
  1918. Begin
  1919. inexpression:=true;
  1920. Consume(AS_DB);
  1921. BuildConstant(1);
  1922. inexpression:=false;
  1923. end;
  1924. AS_DD :
  1925. Begin
  1926. inexpression:=true;
  1927. Consume(AS_DD);
  1928. BuildConstant(4);
  1929. inexpression:=false;
  1930. end;
  1931. AS_ALIGN:
  1932. Begin
  1933. Consume(AS_ALIGN);
  1934. ConcatAlign(curlist,BuildConstExpression);
  1935. if actasmtoken<>AS_SEPARATOR then
  1936. Consume(AS_SEPARATOR);
  1937. end;
  1938. AS_OPCODE :
  1939. Begin
  1940. instr:=Tx86Instruction.Create(Tx86Operand);
  1941. BuildOpcode(instr);
  1942. with instr do
  1943. begin
  1944. { We need AT&T style operands }
  1945. Swapoperands;
  1946. { Must be done with args in ATT order }
  1947. CheckNonCommutativeOpcodes;
  1948. AddReferenceSizes;
  1949. SetInstructionOpsize;
  1950. CheckOperandSizes;
  1951. ConcatInstruction(curlist);
  1952. end;
  1953. instr.Free;
  1954. end;
  1955. AS_SEPARATOR :
  1956. Begin
  1957. Consume(AS_SEPARATOR);
  1958. end;
  1959. AS_END :
  1960. break; { end assembly block }
  1961. else
  1962. Begin
  1963. Message(asmr_e_syntax_error);
  1964. RecoverConsume(false);
  1965. end;
  1966. end; { end case }
  1967. until false;
  1968. { Check LocalLabelList }
  1969. LocalLabelList.CheckEmitted;
  1970. LocalLabelList.Free;
  1971. { Return the list in an asmnode }
  1972. assemble:=curlist;
  1973. Message1(asmr_d_finish_reading,'intel');
  1974. end;
  1975. {*****************************************************************************
  1976. Initialize
  1977. *****************************************************************************}
  1978. const
  1979. asmmode_i386_intel_info : tasmmodeinfo =
  1980. (
  1981. id : asmmode_i386_intel;
  1982. idtxt : 'INTEL';
  1983. casmreader : ti386intreader;
  1984. );
  1985. begin
  1986. RegisterAsmMode(asmmode_i386_intel_info);
  1987. end.