ra386int.pas 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095
  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);
  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. Case actasmtoken of
  691. AS_LPAREN:
  692. Begin
  693. Consume(AS_LPAREN);
  694. expr:=expr + '(';
  695. inc(parenlevel);
  696. end;
  697. AS_RPAREN:
  698. Begin
  699. { Keep the AS_PAREN in actasmtoken, it is maybe a typecast }
  700. if parenlevel=0 then
  701. break;
  702. Consume(AS_RPAREN);
  703. expr:=expr + ')';
  704. dec(parenlevel);
  705. end;
  706. AS_SHL:
  707. Begin
  708. Consume(AS_SHL);
  709. expr:=expr + '<';
  710. end;
  711. AS_SHR:
  712. Begin
  713. Consume(AS_SHR);
  714. expr:=expr + '>';
  715. end;
  716. AS_SLASH:
  717. Begin
  718. Consume(AS_SLASH);
  719. expr:=expr + '/';
  720. end;
  721. AS_MOD:
  722. Begin
  723. Consume(AS_MOD);
  724. expr:=expr + '%';
  725. end;
  726. AS_STAR:
  727. Begin
  728. Consume(AS_STAR);
  729. if isref and (actasmtoken=AS_REGISTER) then
  730. break;
  731. expr:=expr + '*';
  732. end;
  733. AS_PLUS:
  734. Begin
  735. Consume(AS_PLUS);
  736. if isref and (actasmtoken=AS_REGISTER) then
  737. break;
  738. expr:=expr + '+';
  739. end;
  740. AS_LBRACKET:
  741. begin
  742. { Support ugly delphi constructs like: [ECX].1+2[EDX] }
  743. if isref then
  744. break;
  745. end;
  746. AS_MINUS:
  747. Begin
  748. Consume(AS_MINUS);
  749. expr:=expr + '-';
  750. end;
  751. AS_AND:
  752. Begin
  753. Consume(AS_AND);
  754. expr:=expr + '&';
  755. end;
  756. AS_NOT:
  757. Begin
  758. Consume(AS_NOT);
  759. expr:=expr + '~';
  760. end;
  761. AS_XOR:
  762. Begin
  763. Consume(AS_XOR);
  764. expr:=expr + '^';
  765. end;
  766. AS_OR:
  767. Begin
  768. Consume(AS_OR);
  769. expr:=expr + '|';
  770. end;
  771. AS_INTNUM:
  772. Begin
  773. expr:=expr + actasmpattern;
  774. Consume(AS_INTNUM);
  775. end;
  776. AS_OFFSET:
  777. begin
  778. Consume(AS_OFFSET);
  779. needofs:=true;
  780. if actasmtoken<>AS_ID then
  781. Message(asmr_e_offset_without_identifier);
  782. end;
  783. AS_SIZEOF,
  784. AS_TYPE:
  785. begin
  786. l:=0;
  787. hasparen:=false;
  788. Consume(actasmtoken);
  789. if actasmtoken=AS_LPAREN then
  790. begin
  791. hasparen:=true;
  792. Consume(AS_LPAREN);
  793. end;
  794. if actasmtoken<>AS_ID then
  795. Message(asmr_e_type_without_identifier)
  796. else
  797. begin
  798. tempstr:=actasmpattern;
  799. Consume(AS_ID);
  800. if actasmtoken=AS_DOT then
  801. BuildRecordOffsetSize(tempstr,k,l)
  802. else
  803. begin
  804. searchsym(tempstr,sym,srsymtable);
  805. if assigned(sym) then
  806. begin
  807. case sym.typ of
  808. globalvarsym,
  809. localvarsym,
  810. paravarsym :
  811. l:=tabstractvarsym(sym).getsize;
  812. typedconstsym :
  813. l:=ttypedconstsym(sym).getsize;
  814. typesym :
  815. l:=ttypesym(sym).restype.def.size;
  816. else
  817. Message(asmr_e_wrong_sym_type);
  818. end;
  819. end
  820. else
  821. Message1(sym_e_unknown_id,tempstr);
  822. end;
  823. end;
  824. str(l, tempstr);
  825. expr:=expr + tempstr;
  826. if hasparen then
  827. Consume(AS_RPAREN);
  828. end;
  829. AS_STRING:
  830. begin
  831. l:=0;
  832. case Length(actasmpattern) of
  833. 1 :
  834. l:=ord(actasmpattern[1]);
  835. 2 :
  836. l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
  837. 3 :
  838. l:=ord(actasmpattern[3]) +
  839. Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
  840. 4 :
  841. l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
  842. Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
  843. else
  844. Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
  845. end;
  846. str(l, tempstr);
  847. expr:=expr + tempstr;
  848. Consume(AS_STRING);
  849. end;
  850. AS_ID:
  851. begin
  852. hs:='';
  853. hssymtyp:=AT_DATA;
  854. def:=nil;
  855. tempstr:=actasmpattern;
  856. prevtok:=prevasmtoken;
  857. consume(AS_ID);
  858. if SearchIConstant(tempstr,l) then
  859. begin
  860. str(l, tempstr);
  861. expr:=expr + tempstr;
  862. end
  863. else
  864. begin
  865. if is_locallabel(tempstr) then
  866. begin
  867. CreateLocalLabel(tempstr,hl,false);
  868. hs:=hl.name;
  869. hssymtyp:=AT_FUNCTION;
  870. end
  871. else
  872. if SearchLabel(tempstr,hl,false) then
  873. begin
  874. hs:=hl.name;
  875. hssymtyp:=AT_FUNCTION;
  876. end
  877. else
  878. begin
  879. searchsym(tempstr,sym,srsymtable);
  880. if assigned(sym) then
  881. begin
  882. case sym.typ of
  883. globalvarsym :
  884. begin
  885. hs:=tglobalvarsym(sym).mangledname;
  886. def:=tglobalvarsym(sym).vartype.def;
  887. end;
  888. localvarsym,
  889. paravarsym :
  890. begin
  891. Message(asmr_e_no_local_or_para_allowed);
  892. end;
  893. typedconstsym :
  894. begin
  895. hs:=ttypedconstsym(sym).mangledname;
  896. def:=ttypedconstsym(sym).typedconsttype.def;
  897. end;
  898. procsym :
  899. begin
  900. if Tprocsym(sym).procdef_count>1 then
  901. Message(asmr_w_calling_overload_func);
  902. hs:=tprocsym(sym).first_procdef.mangledname;
  903. hssymtyp:=AT_FUNCTION;
  904. end;
  905. typesym :
  906. begin
  907. if not(ttypesym(sym).restype.def.deftype in [recorddef,objectdef]) then
  908. Message(asmr_e_wrong_sym_type);
  909. end;
  910. else
  911. Message(asmr_e_wrong_sym_type);
  912. end;
  913. end
  914. else
  915. Message1(sym_e_unknown_id,tempstr);
  916. end;
  917. { symbol found? }
  918. if hs<>'' then
  919. begin
  920. if asmsym='' then
  921. begin
  922. asmsym:=hs;
  923. asmsymtyp:=hssymtyp;
  924. end
  925. else
  926. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  927. if (expr='') or (expr[length(expr)]='+') then
  928. begin
  929. { don't remove the + if there could be a record field }
  930. if actasmtoken<>AS_DOT then
  931. delete(expr,length(expr),1);
  932. end
  933. else
  934. if needofs then
  935. begin
  936. if (prevtok<>AS_OFFSET) then
  937. Message(asmr_e_need_offset);
  938. end
  939. else
  940. Message(asmr_e_only_add_relocatable_symbol);
  941. end;
  942. if actasmtoken=AS_DOT then
  943. begin
  944. BuildRecordOffsetSize(tempstr,l,k);
  945. str(l, tempstr);
  946. expr:=expr + tempstr;
  947. end
  948. else
  949. begin
  950. if (expr='') or (expr[length(expr)] in ['+','-','/','*']) then
  951. delete(expr,length(expr),1);
  952. end;
  953. if (actasmtoken=AS_LBRACKET) and
  954. assigned(def) and
  955. (def.deftype=arraydef) then
  956. begin
  957. consume(AS_LBRACKET);
  958. l:=BuildConstExpression;
  959. if l<tarraydef(def).lowrange then
  960. begin
  961. Message(asmr_e_constant_out_of_bounds);
  962. l:=0;
  963. end
  964. else
  965. l:=(l-tarraydef(def).lowrange)*tarraydef(def).elesize;
  966. str(l, tempstr);
  967. expr:=expr + '+' + tempstr;
  968. consume(AS_RBRACKET);
  969. end;
  970. end;
  971. { check if there are wrong operator used like / or mod etc. }
  972. if (hs<>'') and not(actasmtoken in [AS_MINUS,AS_PLUS,AS_COMMA,AS_SEPARATOR,AS_END,AS_RBRACKET]) then
  973. Message(asmr_e_only_add_relocatable_symbol);
  974. end;
  975. AS_END,
  976. AS_RBRACKET,
  977. AS_SEPARATOR,
  978. AS_COMMA,
  979. AS_COLON:
  980. break;
  981. else
  982. begin
  983. { write error only once. }
  984. if not errorflag then
  985. Message(asmr_e_invalid_constant_expression);
  986. { consume tokens until we find COMMA or SEPARATOR }
  987. Consume(actasmtoken);
  988. errorflag:=TRUE;
  989. end;
  990. end;
  991. Until false;
  992. { calculate expression }
  993. if not ErrorFlag then
  994. value:=CalculateExpression(expr)
  995. else
  996. value:=0;
  997. { no longer in an expression }
  998. inexpression:=FALSE;
  999. end;
  1000. Function ti386intreader.BuildConstExpression:aint;
  1001. var
  1002. l : aint;
  1003. hs : string;
  1004. hssymtyp : TAsmsymtype;
  1005. begin
  1006. BuildConstSymbolExpression(false,false,l,hs,hssymtyp);
  1007. if hs<>'' then
  1008. Message(asmr_e_relocatable_symbol_not_allowed);
  1009. BuildConstExpression:=l;
  1010. end;
  1011. Function ti386intreader.BuildRefConstExpression:aint;
  1012. var
  1013. l : aint;
  1014. hs : string;
  1015. hssymtyp : TAsmsymtype;
  1016. begin
  1017. BuildConstSymbolExpression(false,true,l,hs,hssymtyp);
  1018. if hs<>'' then
  1019. Message(asmr_e_relocatable_symbol_not_allowed);
  1020. BuildRefConstExpression:=l;
  1021. end;
  1022. procedure ti386intreader.BuildReference(oper : tx86operand);
  1023. var
  1024. k,l,scale : aint;
  1025. tempstr,hs : string;
  1026. tempsymtyp : tasmsymtype;
  1027. typesize : longint;
  1028. code : integer;
  1029. hreg : tregister;
  1030. GotStar,GotOffset,HadVar,
  1031. GotPlus,Negative : boolean;
  1032. hl : tasmlabel;
  1033. Begin
  1034. Consume(AS_LBRACKET);
  1035. if not(oper.opr.typ in [OPR_LOCAL,OPR_REFERENCE]) then
  1036. oper.InitRef;
  1037. GotStar:=false;
  1038. GotPlus:=true;
  1039. GotOffset:=false;
  1040. Negative:=false;
  1041. Scale:=0;
  1042. repeat
  1043. if GotOffset and (actasmtoken<>AS_ID) then
  1044. Message(asmr_e_invalid_reference_syntax);
  1045. Case actasmtoken of
  1046. AS_ID: { Constant reference expression OR variable reference expression }
  1047. Begin
  1048. if not GotPlus then
  1049. Message(asmr_e_invalid_reference_syntax);
  1050. GotStar:=false;
  1051. GotPlus:=false;
  1052. if SearchIConstant(actasmpattern,l) or
  1053. SearchRecordType(actasmpattern) then
  1054. begin
  1055. l:=BuildRefConstExpression;
  1056. GotPlus:=(prevasmtoken=AS_PLUS);
  1057. GotStar:=(prevasmtoken=AS_STAR);
  1058. case oper.opr.typ of
  1059. OPR_LOCAL :
  1060. begin
  1061. if GotStar then
  1062. Message(asmr_e_invalid_reference_syntax);
  1063. if negative then
  1064. Dec(oper.opr.localsymofs,l)
  1065. else
  1066. Inc(oper.opr.localsymofs,l);
  1067. end;
  1068. OPR_REFERENCE :
  1069. begin
  1070. if GotStar then
  1071. oper.opr.ref.scalefactor:=l
  1072. else
  1073. begin
  1074. if negative then
  1075. Dec(oper.opr.ref.offset,l)
  1076. else
  1077. Inc(oper.opr.ref.offset,l);
  1078. end;
  1079. end;
  1080. end;
  1081. end
  1082. else
  1083. Begin
  1084. if oper.hasvar and not GotOffset then
  1085. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1086. HadVar:=oper.hasvar and GotOffset;
  1087. if negative then
  1088. Message(asmr_e_only_add_relocatable_symbol);
  1089. tempstr:=actasmpattern;
  1090. Consume(AS_ID);
  1091. { typecasting? }
  1092. if (actasmtoken=AS_LPAREN) and
  1093. SearchType(tempstr,typesize) then
  1094. begin
  1095. oper.hastype:=true;
  1096. Consume(AS_LPAREN);
  1097. BuildOperand(oper);
  1098. Consume(AS_RPAREN);
  1099. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  1100. oper.SetSize(typesize,true);
  1101. end
  1102. else
  1103. if is_locallabel(tempstr) then
  1104. begin
  1105. CreateLocalLabel(tempstr,hl,false);
  1106. oper.InitRef;
  1107. oper.opr.ref.symbol:=hl;
  1108. oper.hasvar:=true;
  1109. end
  1110. else
  1111. if oper.SetupVar(tempstr,GotOffset) then
  1112. begin
  1113. { force OPR_LOCAL to be a reference }
  1114. if oper.opr.typ=OPR_LOCAL then
  1115. oper.opr.localforceref:=true;
  1116. end
  1117. else
  1118. Message1(sym_e_unknown_id,tempstr);
  1119. { record.field ? }
  1120. if actasmtoken=AS_DOT then
  1121. begin
  1122. BuildRecordOffsetSize(tempstr,l,k);
  1123. case oper.opr.typ of
  1124. OPR_LOCAL :
  1125. inc(oper.opr.localsymofs,l);
  1126. OPR_REFERENCE :
  1127. inc(oper.opr.ref.offset,l);
  1128. end;
  1129. end;
  1130. if GotOffset then
  1131. begin
  1132. if oper.hasvar and (oper.opr.ref.base=current_procinfo.framepointer) then
  1133. begin
  1134. if (oper.opr.typ=OPR_REFERENCE) then
  1135. oper.opr.ref.base:=NR_NO;
  1136. oper.hasvar:=hadvar;
  1137. end
  1138. else
  1139. begin
  1140. if oper.hasvar and hadvar then
  1141. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1142. { should we allow ?? }
  1143. end;
  1144. end;
  1145. end;
  1146. GotOffset:=false;
  1147. end;
  1148. AS_PLUS :
  1149. Begin
  1150. Consume(AS_PLUS);
  1151. Negative:=false;
  1152. GotPlus:=true;
  1153. GotStar:=false;
  1154. Scale:=0;
  1155. end;
  1156. AS_MINUS :
  1157. begin
  1158. Consume(AS_MINUS);
  1159. Negative:=true;
  1160. GotPlus:=true;
  1161. GotStar:=false;
  1162. Scale:=0;
  1163. end;
  1164. AS_STAR : { Scaling, with eax*4 order }
  1165. begin
  1166. Consume(AS_STAR);
  1167. hs:='';
  1168. l:=0;
  1169. case actasmtoken of
  1170. AS_LPAREN :
  1171. l:=BuildConstExpression;
  1172. AS_INTNUM:
  1173. Begin
  1174. hs:=actasmpattern;
  1175. Consume(AS_INTNUM);
  1176. end;
  1177. AS_REGISTER :
  1178. begin
  1179. case oper.opr.typ of
  1180. OPR_REFERENCE :
  1181. begin
  1182. if oper.opr.ref.scalefactor=0 then
  1183. begin
  1184. if scale<>0 then
  1185. begin
  1186. oper.opr.ref.scalefactor:=scale;
  1187. scale:=0;
  1188. end
  1189. else
  1190. Message(asmr_e_wrong_scale_factor);
  1191. end
  1192. else
  1193. Message(asmr_e_invalid_reference_syntax);
  1194. end;
  1195. OPR_LOCAL :
  1196. begin
  1197. if oper.opr.localscale=0 then
  1198. begin
  1199. if scale<>0 then
  1200. begin
  1201. oper.opr.localscale:=scale;
  1202. scale:=0;
  1203. end
  1204. else
  1205. Message(asmr_e_wrong_scale_factor);
  1206. end
  1207. else
  1208. Message(asmr_e_invalid_reference_syntax);
  1209. end;
  1210. end;
  1211. end;
  1212. else
  1213. Message(asmr_e_invalid_reference_syntax);
  1214. end;
  1215. if actasmtoken<>AS_REGISTER then
  1216. begin
  1217. if hs<>'' then
  1218. val(hs,l,code);
  1219. case oper.opr.typ of
  1220. OPR_REFERENCE :
  1221. oper.opr.ref.scalefactor:=l;
  1222. OPR_LOCAL :
  1223. oper.opr.localscale:=l;
  1224. end;
  1225. if l>9 then
  1226. Message(asmr_e_wrong_scale_factor);
  1227. end;
  1228. GotPlus:=false;
  1229. GotStar:=false;
  1230. end;
  1231. AS_REGISTER :
  1232. begin
  1233. if not((GotPlus and (not Negative)) or
  1234. GotStar) then
  1235. Message(asmr_e_invalid_reference_syntax);
  1236. hreg:=actasmregister;
  1237. Consume(AS_REGISTER);
  1238. { this register will be the index:
  1239. 1. just read a *
  1240. 2. next token is a *
  1241. 3. base register is already used }
  1242. case oper.opr.typ of
  1243. OPR_LOCAL :
  1244. begin
  1245. if (oper.opr.localindexreg<>NR_NO) then
  1246. Message(asmr_e_multiple_index);
  1247. oper.opr.localindexreg:=hreg;
  1248. if scale<>0 then
  1249. begin
  1250. oper.opr.localscale:=scale;
  1251. scale:=0;
  1252. end;
  1253. end;
  1254. OPR_REFERENCE :
  1255. begin
  1256. if (GotStar) or
  1257. (actasmtoken=AS_STAR) or
  1258. (oper.opr.ref.base<>NR_NO) then
  1259. begin
  1260. if (oper.opr.ref.index<>NR_NO) then
  1261. Message(asmr_e_multiple_index);
  1262. oper.opr.ref.index:=hreg;
  1263. if scale<>0 then
  1264. begin
  1265. oper.opr.ref.scalefactor:=scale;
  1266. scale:=0;
  1267. end;
  1268. end
  1269. else
  1270. oper.opr.ref.base:=hreg;
  1271. end;
  1272. end;
  1273. GotPlus:=false;
  1274. GotStar:=false;
  1275. end;
  1276. AS_OFFSET :
  1277. begin
  1278. Consume(AS_OFFSET);
  1279. GotOffset:=true;
  1280. end;
  1281. AS_TYPE,
  1282. AS_NOT,
  1283. AS_STRING,
  1284. AS_INTNUM,
  1285. AS_LPAREN : { Constant reference expression }
  1286. begin
  1287. if not GotPlus and not GotStar then
  1288. Message(asmr_e_invalid_reference_syntax);
  1289. BuildConstSymbolExpression(true,true,l,tempstr,tempsymtyp);
  1290. if tempstr<>'' then
  1291. begin
  1292. if GotStar then
  1293. Message(asmr_e_only_add_relocatable_symbol);
  1294. if not assigned(oper.opr.ref.symbol) then
  1295. oper.opr.ref.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp)
  1296. else
  1297. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1298. end;
  1299. case oper.opr.typ of
  1300. OPR_REFERENCE :
  1301. begin
  1302. if GotStar then
  1303. oper.opr.ref.scalefactor:=l
  1304. else if (prevasmtoken = AS_STAR) then
  1305. begin
  1306. if scale<>0 then
  1307. scale:=l*scale
  1308. else
  1309. scale:=l;
  1310. end
  1311. else
  1312. begin
  1313. if negative then
  1314. Dec(oper.opr.ref.offset,l)
  1315. else
  1316. Inc(oper.opr.ref.offset,l);
  1317. end;
  1318. end;
  1319. OPR_LOCAL :
  1320. begin
  1321. if GotStar then
  1322. oper.opr.localscale:=l
  1323. else if (prevasmtoken = AS_STAR) then
  1324. begin
  1325. if scale<>0 then
  1326. scale:=l*scale
  1327. else
  1328. scale:=l;
  1329. end
  1330. else
  1331. begin
  1332. if negative then
  1333. Dec(oper.opr.localsymofs,l)
  1334. else
  1335. Inc(oper.opr.localsymofs,l);
  1336. end;
  1337. end;
  1338. end;
  1339. GotPlus:=(prevasmtoken=AS_PLUS) or
  1340. (prevasmtoken=AS_MINUS);
  1341. if GotPlus then
  1342. negative := prevasmtoken = AS_MINUS;
  1343. GotStar:=(prevasmtoken=AS_STAR);
  1344. end;
  1345. AS_RBRACKET :
  1346. begin
  1347. if GotPlus or GotStar then
  1348. Message(asmr_e_invalid_reference_syntax);
  1349. Consume(AS_RBRACKET);
  1350. break;
  1351. end;
  1352. else
  1353. Begin
  1354. Message(asmr_e_invalid_reference_syntax);
  1355. RecoverConsume(true);
  1356. break;
  1357. end;
  1358. end;
  1359. until false;
  1360. end;
  1361. Procedure ti386intreader.BuildConstantOperand(oper: tx86operand);
  1362. var
  1363. l : aint;
  1364. tempstr : string;
  1365. tempsymtyp : tasmsymtype;
  1366. begin
  1367. if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
  1368. Message(asmr_e_invalid_operand_type);
  1369. BuildConstSymbolExpression(true,false,l,tempstr,tempsymtyp);
  1370. if tempstr<>'' then
  1371. begin
  1372. oper.opr.typ:=OPR_SYMBOL;
  1373. oper.opr.symofs:=l;
  1374. oper.opr.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp);
  1375. end
  1376. else
  1377. if oper.opr.typ=OPR_NONE then
  1378. begin
  1379. oper.opr.typ:=OPR_CONSTANT;
  1380. oper.opr.val:=l;
  1381. end
  1382. else
  1383. inc(oper.opr.val,l);
  1384. end;
  1385. Procedure ti386intreader.BuildOperand(oper: tx86operand);
  1386. procedure AddLabelOperand(hl:tasmlabel);
  1387. begin
  1388. if (oper.opr.typ=OPR_NONE) and
  1389. is_calljmp(actopcode) then
  1390. begin
  1391. oper.opr.typ:=OPR_SYMBOL;
  1392. oper.opr.symbol:=hl;
  1393. end
  1394. else
  1395. begin
  1396. oper.InitRef;
  1397. oper.opr.ref.symbol:=hl;
  1398. end;
  1399. end;
  1400. var
  1401. expr : string;
  1402. tempreg : tregister;
  1403. typesize,
  1404. l,k : aint;
  1405. hl : tasmlabel;
  1406. toffset,
  1407. tsize : aint;
  1408. tempstr : string;
  1409. begin
  1410. expr:='';
  1411. repeat
  1412. if actasmtoken=AS_DOT then
  1413. begin
  1414. if expr<>'' then
  1415. begin
  1416. BuildRecordOffsetSize(expr,toffset,tsize);
  1417. oper.SetSize(tsize,true);
  1418. case oper.opr.typ of
  1419. OPR_LOCAL :
  1420. begin
  1421. { don't allow direct access to fields of parameters, becuase that
  1422. will generate buggy code. Allow it only for explicit typecasting
  1423. and when the parameter is in a register (delphi compatible) }
  1424. if (not oper.hastype) and
  1425. (oper.opr.localsym.owner.symtabletype=parasymtable) and
  1426. (current_procinfo.procdef.proccalloption<>pocall_register) then
  1427. Message(asmr_e_cannot_access_field_directly_for_parameters);
  1428. inc(oper.opr.localsymofs,toffset)
  1429. end;
  1430. OPR_CONSTANT :
  1431. inc(oper.opr.val,toffset);
  1432. OPR_REFERENCE :
  1433. inc(oper.opr.ref.offset,toffset);
  1434. OPR_NONE :
  1435. begin
  1436. oper.opr.typ:=OPR_CONSTANT;
  1437. oper.opr.val:=toffset;
  1438. end;
  1439. else
  1440. internalerror(200309222);
  1441. end;
  1442. expr:='';
  1443. end
  1444. else
  1445. begin
  1446. { See it as a separator }
  1447. Consume(AS_DOT);
  1448. end;
  1449. end;
  1450. { Word,Dword,etc shall now be seen as normal (pascal) typename identifiers }
  1451. case actasmtoken of
  1452. AS_DWORD,
  1453. AS_BYTE,
  1454. AS_WORD,
  1455. AS_QWORD :
  1456. actasmtoken:=AS_ID;
  1457. end;
  1458. case actasmtoken of
  1459. AS_OFFSET,
  1460. AS_SIZEOF,
  1461. AS_TYPE,
  1462. AS_NOT,
  1463. AS_STRING,
  1464. AS_PLUS,
  1465. AS_MINUS,
  1466. AS_LPAREN,
  1467. AS_INTNUM :
  1468. begin
  1469. case oper.opr.typ of
  1470. OPR_REFERENCE :
  1471. inc(oper.opr.ref.offset,BuildRefConstExpression);
  1472. OPR_LOCAL :
  1473. inc(oper.opr.localsymofs,BuildConstExpression);
  1474. OPR_NONE,
  1475. OPR_CONSTANT :
  1476. BuildConstantOperand(oper);
  1477. else
  1478. Message(asmr_e_invalid_operand_type);
  1479. end;
  1480. end;
  1481. AS_ID : { A constant expression, or a Variable ref. }
  1482. Begin
  1483. { Label or Special symbol reference? }
  1484. if actasmpattern[1] = '@' then
  1485. Begin
  1486. if actasmpattern = '@RESULT' then
  1487. Begin
  1488. oper.SetupResult;
  1489. Consume(AS_ID);
  1490. end
  1491. else
  1492. if (actasmpattern = '@CODE') or (actasmpattern = '@DATA') then
  1493. begin
  1494. Message(asmr_w_CODE_and_DATA_not_supported);
  1495. Consume(AS_ID);
  1496. end
  1497. else
  1498. { Local Label }
  1499. begin
  1500. CreateLocalLabel(actasmpattern,hl,false);
  1501. Consume(AS_ID);
  1502. AddLabelOperand(hl);
  1503. end;
  1504. end
  1505. else
  1506. { support result for delphi modes }
  1507. if (m_objpas in aktmodeswitches) and (actasmpattern='RESULT') then
  1508. begin
  1509. oper.SetUpResult;
  1510. Consume(AS_ID);
  1511. end
  1512. { probably a variable or normal expression }
  1513. { or a procedure (such as in CALL ID) }
  1514. else
  1515. Begin
  1516. { is it a constant ? }
  1517. if SearchIConstant(actasmpattern,l) then
  1518. Begin
  1519. case oper.opr.typ of
  1520. OPR_REFERENCE :
  1521. inc(oper.opr.ref.offset,BuildRefConstExpression);
  1522. OPR_LOCAL :
  1523. inc(oper.opr.localsymofs,BuildRefConstExpression);
  1524. OPR_NONE,
  1525. OPR_CONSTANT :
  1526. BuildConstantOperand(oper);
  1527. else
  1528. Message(asmr_e_invalid_operand_type);
  1529. end;
  1530. end
  1531. else
  1532. { Check for pascal label }
  1533. if SearchLabel(actasmpattern,hl,false) then
  1534. begin
  1535. Consume(AS_ID);
  1536. AddLabelOperand(hl);
  1537. end
  1538. else
  1539. { is it a normal variable ? }
  1540. Begin
  1541. expr:=actasmpattern;
  1542. Consume(AS_ID);
  1543. { typecasting? }
  1544. if SearchType(expr,typesize) then
  1545. begin
  1546. oper.hastype:=true;
  1547. case actasmtoken of
  1548. AS_LPAREN :
  1549. begin
  1550. { Support Type([Reference]) }
  1551. Consume(AS_LPAREN);
  1552. BuildOperand(oper);
  1553. Consume(AS_RPAREN);
  1554. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  1555. oper.SetSize(typesize,true);
  1556. end;
  1557. AS_LBRACKET :
  1558. begin
  1559. { Support Var.Type[Index] }
  1560. { Convert @label.Byte[1] to reference }
  1561. if oper.opr.typ=OPR_SYMBOL then
  1562. oper.initref;
  1563. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  1564. oper.SetSize(typesize,true);
  1565. end;
  1566. else
  1567. oper.SetSize(typesize,true);
  1568. end;
  1569. end
  1570. else
  1571. begin
  1572. if not oper.SetupVar(expr,false) then
  1573. Begin
  1574. { not a variable, check special variables.. }
  1575. if expr = 'SELF' then
  1576. oper.SetupSelf
  1577. else
  1578. Message1(sym_e_unknown_id,expr);
  1579. expr:='';
  1580. end;
  1581. end;
  1582. end;
  1583. end;
  1584. end;
  1585. AS_REGISTER : { Register, a variable reference or a constant reference }
  1586. begin
  1587. { save the type of register used. }
  1588. tempreg:=actasmregister;
  1589. Consume(AS_REGISTER);
  1590. if actasmtoken = AS_COLON then
  1591. Begin
  1592. Consume(AS_COLON);
  1593. oper.InitRef;
  1594. oper.opr.ref.segment:=tempreg;
  1595. BuildReference(oper);
  1596. end
  1597. else
  1598. { Simple register }
  1599. begin
  1600. if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then
  1601. Message(asmr_e_invalid_operand_type);
  1602. oper.opr.typ:=OPR_REGISTER;
  1603. oper.opr.reg:=tempreg;
  1604. oper.SetSize(tcgsize2size[reg_cgsize(oper.opr.reg)],true);
  1605. end;
  1606. end;
  1607. AS_LBRACKET: { a variable reference, register ref. or a constant reference }
  1608. Begin
  1609. BuildReference(oper);
  1610. end;
  1611. AS_SEG :
  1612. Begin
  1613. Message(asmr_e_seg_not_supported);
  1614. Consume(actasmtoken);
  1615. end;
  1616. AS_SEPARATOR,
  1617. AS_END,
  1618. AS_COMMA,
  1619. AS_COLON:
  1620. break;
  1621. else
  1622. Message(asmr_e_syn_operand);
  1623. end;
  1624. until not(actasmtoken in [AS_DOT,AS_PLUS,AS_LBRACKET]);
  1625. if not((actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA,AS_COLON]) or
  1626. (oper.hastype and (actasmtoken=AS_RPAREN))) then
  1627. begin
  1628. Message(asmr_e_syntax_error);
  1629. RecoverConsume(true);
  1630. end;
  1631. end;
  1632. Procedure ti386intreader.BuildOpCode(instr : tx86instruction);
  1633. var
  1634. PrefixOp,OverrideOp: tasmop;
  1635. size,
  1636. operandnum : longint;
  1637. is_far_const:boolean;
  1638. i:byte;
  1639. begin
  1640. PrefixOp:=A_None;
  1641. OverrideOp:=A_None;
  1642. is_far_const:=false;
  1643. { prefix seg opcode / prefix opcode }
  1644. repeat
  1645. if is_prefix(actopcode) then
  1646. with instr do
  1647. begin
  1648. OpOrder:=op_intel;
  1649. PrefixOp:=ActOpcode;
  1650. opcode:=ActOpcode;
  1651. condition:=ActCondition;
  1652. opsize:=ActOpsize;
  1653. ConcatInstruction(curlist);
  1654. consume(AS_OPCODE);
  1655. end
  1656. else
  1657. if is_override(actopcode) then
  1658. with instr do
  1659. begin
  1660. OpOrder:=op_intel;
  1661. OverrideOp:=ActOpcode;
  1662. opcode:=ActOpcode;
  1663. condition:=ActCondition;
  1664. opsize:=ActOpsize;
  1665. ConcatInstruction(curlist);
  1666. consume(AS_OPCODE);
  1667. end
  1668. else
  1669. break;
  1670. { allow for newline after prefix or override }
  1671. while actasmtoken=AS_SEPARATOR do
  1672. consume(AS_SEPARATOR);
  1673. until (actasmtoken<>AS_OPCODE);
  1674. { opcode }
  1675. if (actasmtoken <> AS_OPCODE) then
  1676. begin
  1677. Message(asmr_e_invalid_or_missing_opcode);
  1678. RecoverConsume(false);
  1679. exit;
  1680. end;
  1681. { Fill the instr object with the current state }
  1682. with instr do
  1683. begin
  1684. OpOrder:=op_intel;
  1685. Opcode:=ActOpcode;
  1686. condition:=ActCondition;
  1687. opsize:=ActOpsize;
  1688. { Valid combination of prefix/override and instruction ? }
  1689. if (prefixop<>A_NONE) and (NOT CheckPrefix(PrefixOp,actopcode)) then
  1690. Message1(asmr_e_invalid_prefix_and_opcode,actasmpattern);
  1691. if (overrideop<>A_NONE) and (NOT CheckOverride(OverrideOp,ActOpcode)) then
  1692. Message1(asmr_e_invalid_override_and_opcode,actasmpattern);
  1693. end;
  1694. { We are reading operands, so opcode will be an AS_ID }
  1695. operandnum:=1;
  1696. is_far_const:=false;
  1697. Consume(AS_OPCODE);
  1698. { Zero operand opcode ? }
  1699. if actasmtoken in [AS_SEPARATOR,AS_END] then
  1700. begin
  1701. operandnum:=0;
  1702. exit;
  1703. end;
  1704. { Read Operands }
  1705. repeat
  1706. case actasmtoken of
  1707. { End of asm operands for this opcode }
  1708. AS_END,
  1709. AS_SEPARATOR :
  1710. break;
  1711. { Operand delimiter }
  1712. AS_COMMA :
  1713. begin
  1714. if operandnum > Max_Operands then
  1715. Message(asmr_e_too_many_operands)
  1716. else
  1717. Inc(operandnum);
  1718. Consume(AS_COMMA);
  1719. end;
  1720. {Far constant, i.e. jmp $0000:$11111111.}
  1721. AS_COLON:
  1722. begin
  1723. is_far_const:=true;
  1724. if operandnum>1 then
  1725. message(asmr_e_too_many_operands)
  1726. else
  1727. inc(operandnum);
  1728. consume(AS_COLON);
  1729. end;
  1730. { Typecast, Constant Expression, Type Specifier }
  1731. AS_DWORD,
  1732. AS_BYTE,
  1733. AS_WORD,
  1734. AS_TBYTE,
  1735. AS_DQWORD,
  1736. AS_QWORD :
  1737. begin
  1738. { load the size in a temp variable, so it can be set when the
  1739. operand is read }
  1740. size:=0;
  1741. case actasmtoken of
  1742. AS_DWORD : size:=4;
  1743. AS_WORD : size:=2;
  1744. AS_BYTE : size:=1;
  1745. AS_QWORD : size:=8;
  1746. AS_DQWORD : size:=16;
  1747. AS_TBYTE : size:=10;
  1748. end;
  1749. Consume(actasmtoken);
  1750. case actasmtoken of
  1751. AS_LPAREN :
  1752. begin
  1753. instr.Operands[operandnum].hastype:=true;
  1754. Consume(AS_LPAREN);
  1755. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1756. Consume(AS_RPAREN);
  1757. end;
  1758. AS_PTR :
  1759. begin
  1760. Consume(AS_PTR);
  1761. instr.Operands[operandnum].InitRef;
  1762. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1763. end;
  1764. else
  1765. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1766. end;
  1767. { now set the size which was specified by the override }
  1768. instr.Operands[operandnum].setsize(size,true);
  1769. end;
  1770. { Type specifier }
  1771. AS_NEAR,
  1772. AS_FAR :
  1773. begin
  1774. if actasmtoken = AS_NEAR then
  1775. begin
  1776. Message(asmr_w_near_ignored);
  1777. instr.opsize:=S_NEAR;
  1778. end
  1779. else
  1780. begin
  1781. Message(asmr_w_far_ignored);
  1782. instr.opsize:=S_FAR;
  1783. end;
  1784. Consume(actasmtoken);
  1785. if actasmtoken=AS_PTR then
  1786. begin
  1787. Consume(AS_PTR);
  1788. instr.Operands[operandnum].InitRef;
  1789. end;
  1790. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1791. end;
  1792. else
  1793. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1794. end; { end case }
  1795. until false;
  1796. instr.ops:=operandnum;
  1797. if is_far_const then
  1798. for i:=1 to operandnum do
  1799. if instr.operands[i].opr.typ<>OPR_CONSTANT then
  1800. message(asmr_e_expr_illegal);
  1801. end;
  1802. Procedure ti386intreader.BuildConstant(constsize: byte);
  1803. var
  1804. asmsymtyp : tasmsymtype;
  1805. asmsym,
  1806. expr: string;
  1807. value : aint;
  1808. Begin
  1809. Repeat
  1810. Case actasmtoken of
  1811. AS_STRING:
  1812. Begin
  1813. { DD and DW cases }
  1814. if constsize <> 1 then
  1815. Begin
  1816. if Not PadZero(actasmpattern,constsize) then
  1817. Message(scan_f_string_exceeds_line);
  1818. end;
  1819. expr:=actasmpattern;
  1820. Consume(AS_STRING);
  1821. Case actasmtoken of
  1822. AS_COMMA:
  1823. Consume(AS_COMMA);
  1824. AS_END,
  1825. AS_SEPARATOR: ;
  1826. else
  1827. Message(asmr_e_invalid_string_expression);
  1828. end;
  1829. ConcatString(curlist,expr);
  1830. end;
  1831. AS_PLUS,
  1832. AS_MINUS,
  1833. AS_LPAREN,
  1834. AS_NOT,
  1835. AS_INTNUM,
  1836. AS_ID :
  1837. Begin
  1838. BuildConstSymbolExpression(false,false,value,asmsym,asmsymtyp);
  1839. if asmsym<>'' then
  1840. begin
  1841. if constsize<>sizeof(aint) then
  1842. Message1(asmr_w_const32bit_for_address,asmsym);
  1843. ConcatConstSymbol(curlist,asmsym,asmsymtyp,value)
  1844. end
  1845. else
  1846. ConcatConstant(curlist,value,constsize);
  1847. end;
  1848. AS_COMMA:
  1849. Consume(AS_COMMA);
  1850. AS_END,
  1851. AS_SEPARATOR:
  1852. break;
  1853. else
  1854. begin
  1855. Message(asmr_e_syn_constant);
  1856. RecoverConsume(false);
  1857. end
  1858. end;
  1859. Until false;
  1860. end;
  1861. function ti386intreader.Assemble: tlinkedlist;
  1862. Var
  1863. hl : tasmlabel;
  1864. instr : Tx86Instruction;
  1865. Begin
  1866. Message1(asmr_d_start_reading,'intel');
  1867. inexpression:=FALSE;
  1868. firsttoken:=TRUE;
  1869. { sets up all opcode and register tables in uppercase
  1870. done in the construtor now
  1871. if not _asmsorted then
  1872. Begin
  1873. SetupTables;
  1874. _asmsorted:=TRUE;
  1875. end;
  1876. }
  1877. curlist:=TAAsmoutput.Create;
  1878. { setup label linked list }
  1879. LocalLabelList:=TLocalLabelList.Create;
  1880. { start tokenizer }
  1881. c:=current_scanner.asmgetcharstart;
  1882. gettoken;
  1883. { main loop }
  1884. repeat
  1885. case actasmtoken of
  1886. AS_LLABEL:
  1887. Begin
  1888. if CreateLocalLabel(actasmpattern,hl,true) then
  1889. ConcatLabel(curlist,hl);
  1890. Consume(AS_LLABEL);
  1891. end;
  1892. AS_LABEL:
  1893. Begin
  1894. if SearchLabel(upper(actasmpattern),hl,true) then
  1895. ConcatLabel(curlist,hl)
  1896. else
  1897. Message1(asmr_e_unknown_label_identifier,actasmpattern);
  1898. Consume(AS_LABEL);
  1899. end;
  1900. AS_DW :
  1901. Begin
  1902. inexpression:=true;
  1903. Consume(AS_DW);
  1904. BuildConstant(2);
  1905. inexpression:=false;
  1906. end;
  1907. AS_DB :
  1908. Begin
  1909. inexpression:=true;
  1910. Consume(AS_DB);
  1911. BuildConstant(1);
  1912. inexpression:=false;
  1913. end;
  1914. AS_DD :
  1915. Begin
  1916. inexpression:=true;
  1917. Consume(AS_DD);
  1918. BuildConstant(4);
  1919. inexpression:=false;
  1920. end;
  1921. AS_ALIGN:
  1922. Begin
  1923. Consume(AS_ALIGN);
  1924. ConcatAlign(curlist,BuildConstExpression);
  1925. if actasmtoken<>AS_SEPARATOR then
  1926. Consume(AS_SEPARATOR);
  1927. end;
  1928. AS_OPCODE :
  1929. Begin
  1930. instr:=Tx86Instruction.Create(Tx86Operand);
  1931. BuildOpcode(instr);
  1932. with instr do
  1933. begin
  1934. { We need AT&T style operands }
  1935. Swapoperands;
  1936. { Must be done with args in ATT order }
  1937. CheckNonCommutativeOpcodes;
  1938. AddReferenceSizes;
  1939. SetInstructionOpsize;
  1940. CheckOperandSizes;
  1941. ConcatInstruction(curlist);
  1942. end;
  1943. instr.Free;
  1944. end;
  1945. AS_SEPARATOR :
  1946. Begin
  1947. Consume(AS_SEPARATOR);
  1948. end;
  1949. AS_END :
  1950. break; { end assembly block }
  1951. else
  1952. Begin
  1953. Message(asmr_e_syntax_error);
  1954. RecoverConsume(false);
  1955. end;
  1956. end; { end case }
  1957. until false;
  1958. { Check LocalLabelList }
  1959. LocalLabelList.CheckEmitted;
  1960. LocalLabelList.Free;
  1961. { Return the list in an asmnode }
  1962. assemble:=curlist;
  1963. Message1(asmr_d_finish_reading,'intel');
  1964. end;
  1965. {*****************************************************************************
  1966. Initialize
  1967. *****************************************************************************}
  1968. const
  1969. asmmode_i386_intel_info : tasmmodeinfo =
  1970. (
  1971. id : asmmode_i386_intel;
  1972. idtxt : 'INTEL';
  1973. casmreader : ti386intreader;
  1974. );
  1975. begin
  1976. RegisterAsmMode(asmmode_i386_intel_info);
  1977. end.