ra386int.pas 70 KB

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