ra386int.pas 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093
  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.unitid=0) then
  352. begin
  353. { Add . to create System.Identifier }
  354. actasmpattern:=actasmpattern+c;
  355. c:=current_scanner.asmgetchar;
  356. { Delphi allows System.@Halt, just ignore the @ }
  357. if c='@' then
  358. c:=current_scanner.asmgetchar;
  359. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  360. begin
  361. actasmpattern:=actasmpattern + upcase(c);
  362. c:=current_scanner.asmgetchar;
  363. end;
  364. end;
  365. end;
  366. actasmtoken:=AS_ID;
  367. exit;
  368. end;
  369. '''' : { string or character }
  370. begin
  371. actasmpattern:='';
  372. current_scanner.in_asm_string:=true;
  373. repeat
  374. if c = '''' then
  375. begin
  376. c:=current_scanner.asmgetchar;
  377. if c in [#10,#13] then
  378. begin
  379. Message(scan_f_string_exceeds_line);
  380. break;
  381. end;
  382. repeat
  383. if c='''' then
  384. begin
  385. c:=current_scanner.asmgetchar;
  386. if c='''' then
  387. begin
  388. actasmpattern:=actasmpattern+'''';
  389. c:=current_scanner.asmgetchar;
  390. if c in [#10,#13] then
  391. begin
  392. Message(scan_f_string_exceeds_line);
  393. break;
  394. end;
  395. end
  396. else
  397. break;
  398. end
  399. else
  400. begin
  401. actasmpattern:=actasmpattern+c;
  402. c:=current_scanner.asmgetchar;
  403. if c in [#10,#13] then
  404. begin
  405. Message(scan_f_string_exceeds_line);
  406. break
  407. end;
  408. end;
  409. until false; { end repeat }
  410. end
  411. else
  412. break; { end if }
  413. until false;
  414. current_scanner.in_asm_string:=false;
  415. actasmtoken:=AS_STRING;
  416. exit;
  417. end;
  418. '"' : { string or character }
  419. begin
  420. current_scanner.in_asm_string:=true;
  421. actasmpattern:='';
  422. repeat
  423. if c = '"' then
  424. begin
  425. c:=current_scanner.asmgetchar;
  426. if c in [#10,#13] then
  427. begin
  428. Message(scan_f_string_exceeds_line);
  429. break;
  430. end;
  431. repeat
  432. if c='"' then
  433. begin
  434. c:=current_scanner.asmgetchar;
  435. if c='"' then
  436. begin
  437. actasmpattern:=actasmpattern+'"';
  438. c:=current_scanner.asmgetchar;
  439. if c in [#10,#13] then
  440. begin
  441. Message(scan_f_string_exceeds_line);
  442. break;
  443. end;
  444. end
  445. else
  446. break;
  447. end
  448. else
  449. begin
  450. actasmpattern:=actasmpattern+c;
  451. c:=current_scanner.asmgetchar;
  452. if c in [#10,#13] then
  453. begin
  454. Message(scan_f_string_exceeds_line);
  455. break
  456. end;
  457. end;
  458. until false; { end repeat }
  459. end
  460. else
  461. break; { end if }
  462. until false;
  463. current_scanner.in_asm_string:=false;
  464. actasmtoken:=AS_STRING;
  465. exit;
  466. end;
  467. '$' :
  468. begin
  469. c:=current_scanner.asmgetchar;
  470. while c in ['0'..'9','A'..'F','a'..'f'] do
  471. begin
  472. actasmpattern:=actasmpattern + c;
  473. c:=current_scanner.asmgetchar;
  474. end;
  475. actasmpattern:=tostr(ValHexaDecimal(actasmpattern));
  476. actasmtoken:=AS_INTNUM;
  477. exit;
  478. end;
  479. ',' :
  480. begin
  481. actasmtoken:=AS_COMMA;
  482. c:=current_scanner.asmgetchar;
  483. exit;
  484. end;
  485. '[' :
  486. begin
  487. actasmtoken:=AS_LBRACKET;
  488. c:=current_scanner.asmgetchar;
  489. exit;
  490. end;
  491. ']' :
  492. begin
  493. actasmtoken:=AS_RBRACKET;
  494. c:=current_scanner.asmgetchar;
  495. exit;
  496. end;
  497. '(' :
  498. begin
  499. actasmtoken:=AS_LPAREN;
  500. c:=current_scanner.asmgetchar;
  501. exit;
  502. end;
  503. ')' :
  504. begin
  505. actasmtoken:=AS_RPAREN;
  506. c:=current_scanner.asmgetchar;
  507. exit;
  508. end;
  509. ':' :
  510. begin
  511. actasmtoken:=AS_COLON;
  512. c:=current_scanner.asmgetchar;
  513. exit;
  514. end;
  515. '.' :
  516. begin
  517. actasmtoken:=AS_DOT;
  518. c:=current_scanner.asmgetchar;
  519. exit;
  520. end;
  521. '+' :
  522. begin
  523. actasmtoken:=AS_PLUS;
  524. c:=current_scanner.asmgetchar;
  525. exit;
  526. end;
  527. '-' :
  528. begin
  529. actasmtoken:=AS_MINUS;
  530. c:=current_scanner.asmgetchar;
  531. exit;
  532. end;
  533. '*' :
  534. begin
  535. actasmtoken:=AS_STAR;
  536. c:=current_scanner.asmgetchar;
  537. exit;
  538. end;
  539. '/' :
  540. begin
  541. actasmtoken:=AS_SLASH;
  542. c:=current_scanner.asmgetchar;
  543. exit;
  544. end;
  545. '0'..'9':
  546. begin
  547. actasmpattern:=c;
  548. c:=current_scanner.asmgetchar;
  549. { Get the possible characters }
  550. while c in ['0'..'9','A'..'F','a'..'f'] do
  551. begin
  552. actasmpattern:=actasmpattern + c;
  553. c:=current_scanner.asmgetchar;
  554. end;
  555. { Get ending character }
  556. uppervar(actasmpattern);
  557. c:=upcase(c);
  558. { possibly a binary number. }
  559. if (actasmpattern[length(actasmpattern)] = 'B') and (c <> 'H') then
  560. Begin
  561. { Delete the last binary specifier }
  562. delete(actasmpattern,length(actasmpattern),1);
  563. actasmpattern:=tostr(ValBinary(actasmpattern));
  564. actasmtoken:=AS_INTNUM;
  565. exit;
  566. end
  567. else
  568. Begin
  569. case c of
  570. 'O' :
  571. Begin
  572. actasmpattern:=tostr(ValOctal(actasmpattern));
  573. actasmtoken:=AS_INTNUM;
  574. c:=current_scanner.asmgetchar;
  575. exit;
  576. end;
  577. 'H' :
  578. Begin
  579. actasmpattern:=tostr(ValHexaDecimal(actasmpattern));
  580. actasmtoken:=AS_INTNUM;
  581. c:=current_scanner.asmgetchar;
  582. exit;
  583. end;
  584. else { must be an integer number }
  585. begin
  586. actasmpattern:=tostr(ValDecimal(actasmpattern));
  587. actasmtoken:=AS_INTNUM;
  588. exit;
  589. end;
  590. end;
  591. end;
  592. end;
  593. ';','{',#13,#10 :
  594. begin
  595. c:=current_scanner.asmgetchar;
  596. firsttoken:=TRUE;
  597. actasmtoken:=AS_SEPARATOR;
  598. exit;
  599. end;
  600. else
  601. current_scanner.illegal_char(c);
  602. end;
  603. end;
  604. end;
  605. function ti386intreader.consume(t : tasmtoken):boolean;
  606. begin
  607. Consume:=true;
  608. if t<>actasmtoken then
  609. begin
  610. Message2(scan_f_syn_expected,token2str[t],token2str[actasmtoken]);
  611. Consume:=false;
  612. end;
  613. repeat
  614. gettoken;
  615. until actasmtoken<>AS_NONE;
  616. end;
  617. procedure ti386intreader.RecoverConsume(allowcomma:boolean);
  618. begin
  619. While not (actasmtoken in [AS_SEPARATOR,AS_END]) do
  620. begin
  621. if allowcomma and (actasmtoken=AS_COMMA) then
  622. break;
  623. Consume(actasmtoken);
  624. end;
  625. end;
  626. {*****************************************************************************
  627. Parsing Helpers
  628. *****************************************************************************}
  629. { This routine builds up a record offset after a AS_DOT
  630. token is encountered.
  631. On entry actasmtoken should be equal to AS_DOT }
  632. Procedure ti386intreader.BuildRecordOffsetSize(const expr: string;var offset:aint;var size:aint);
  633. var
  634. s : string;
  635. Begin
  636. offset:=0;
  637. size:=0;
  638. s:=expr;
  639. while (actasmtoken=AS_DOT) do
  640. begin
  641. Consume(AS_DOT);
  642. if actasmtoken=AS_ID then
  643. s:=s+'.'+actasmpattern;
  644. if not Consume(AS_ID) then
  645. begin
  646. RecoverConsume(true);
  647. break;
  648. end;
  649. end;
  650. if not GetRecordOffsetSize(s,offset,size) then
  651. Message(asmr_e_building_record_offset);
  652. end;
  653. Procedure ti386intreader.BuildConstSymbolExpression(needofs,isref:boolean;var value:aint;var asmsym:string;var asmsymtyp:TAsmsymtype);
  654. var
  655. tempstr,expr,hs : string;
  656. parenlevel : longint;
  657. l,k : aint;
  658. hasparen,
  659. errorflag : boolean;
  660. prevtok : tasmtoken;
  661. hl : tasmlabel;
  662. hssymtyp : Tasmsymtype;
  663. def : tdef;
  664. sym : tsym;
  665. srsymtable : tsymtable;
  666. Begin
  667. { reset }
  668. value:=0;
  669. asmsym:='';
  670. asmsymtyp:=AT_DATA;
  671. errorflag:=FALSE;
  672. tempstr:='';
  673. expr:='';
  674. inexpression:=TRUE;
  675. parenlevel:=0;
  676. Repeat
  677. Case actasmtoken of
  678. AS_LPAREN:
  679. Begin
  680. Consume(AS_LPAREN);
  681. expr:=expr + '(';
  682. inc(parenlevel);
  683. end;
  684. AS_RPAREN:
  685. Begin
  686. { Keep the AS_PAREN in actasmtoken, it is maybe a typecast }
  687. if parenlevel=0 then
  688. break;
  689. Consume(AS_RPAREN);
  690. expr:=expr + ')';
  691. dec(parenlevel);
  692. end;
  693. AS_SHL:
  694. Begin
  695. Consume(AS_SHL);
  696. expr:=expr + '<';
  697. end;
  698. AS_SHR:
  699. Begin
  700. Consume(AS_SHR);
  701. expr:=expr + '>';
  702. end;
  703. AS_SLASH:
  704. Begin
  705. Consume(AS_SLASH);
  706. expr:=expr + '/';
  707. end;
  708. AS_MOD:
  709. Begin
  710. Consume(AS_MOD);
  711. expr:=expr + '%';
  712. end;
  713. AS_STAR:
  714. Begin
  715. Consume(AS_STAR);
  716. if isref and (actasmtoken=AS_REGISTER) then
  717. break;
  718. expr:=expr + '*';
  719. end;
  720. AS_PLUS:
  721. Begin
  722. Consume(AS_PLUS);
  723. if isref and (actasmtoken=AS_REGISTER) then
  724. break;
  725. expr:=expr + '+';
  726. end;
  727. AS_LBRACKET:
  728. begin
  729. { Support ugly delphi constructs like: [ECX].1+2[EDX] }
  730. if isref then
  731. break;
  732. end;
  733. AS_MINUS:
  734. Begin
  735. Consume(AS_MINUS);
  736. expr:=expr + '-';
  737. end;
  738. AS_AND:
  739. Begin
  740. Consume(AS_AND);
  741. expr:=expr + '&';
  742. end;
  743. AS_NOT:
  744. Begin
  745. Consume(AS_NOT);
  746. expr:=expr + '~';
  747. end;
  748. AS_XOR:
  749. Begin
  750. Consume(AS_XOR);
  751. expr:=expr + '^';
  752. end;
  753. AS_OR:
  754. Begin
  755. Consume(AS_OR);
  756. expr:=expr + '|';
  757. end;
  758. AS_INTNUM:
  759. Begin
  760. expr:=expr + actasmpattern;
  761. Consume(AS_INTNUM);
  762. end;
  763. AS_OFFSET:
  764. begin
  765. Consume(AS_OFFSET);
  766. needofs:=true;
  767. if actasmtoken<>AS_ID then
  768. Message(asmr_e_offset_without_identifier);
  769. end;
  770. AS_SIZEOF,
  771. AS_TYPE:
  772. begin
  773. l:=0;
  774. hasparen:=false;
  775. Consume(actasmtoken);
  776. if actasmtoken=AS_LPAREN then
  777. begin
  778. hasparen:=true;
  779. Consume(AS_LPAREN);
  780. end;
  781. if actasmtoken<>AS_ID then
  782. Message(asmr_e_type_without_identifier)
  783. else
  784. begin
  785. tempstr:=actasmpattern;
  786. Consume(AS_ID);
  787. if actasmtoken=AS_DOT then
  788. BuildRecordOffsetSize(tempstr,k,l)
  789. else
  790. begin
  791. searchsym(tempstr,sym,srsymtable);
  792. if assigned(sym) then
  793. begin
  794. case sym.typ of
  795. globalvarsym,
  796. localvarsym,
  797. paravarsym :
  798. l:=tabstractvarsym(sym).getsize;
  799. typedconstsym :
  800. l:=ttypedconstsym(sym).getsize;
  801. typesym :
  802. l:=ttypesym(sym).restype.def.size;
  803. else
  804. Message(asmr_e_wrong_sym_type);
  805. end;
  806. end
  807. else
  808. Message1(sym_e_unknown_id,tempstr);
  809. end;
  810. end;
  811. str(l, tempstr);
  812. expr:=expr + tempstr;
  813. if hasparen then
  814. Consume(AS_RPAREN);
  815. end;
  816. AS_STRING:
  817. Begin
  818. l:=0;
  819. case Length(actasmpattern) of
  820. 1 :
  821. l:=ord(actasmpattern[1]);
  822. 2 :
  823. l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
  824. 3 :
  825. l:=ord(actasmpattern[3]) +
  826. Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
  827. 4 :
  828. l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
  829. Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
  830. else
  831. Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
  832. end;
  833. str(l, tempstr);
  834. expr:=expr + tempstr;
  835. Consume(AS_STRING);
  836. end;
  837. AS_ID:
  838. Begin
  839. hs:='';
  840. hssymtyp:=AT_DATA;
  841. def:=nil;
  842. tempstr:=actasmpattern;
  843. prevtok:=prevasmtoken;
  844. consume(AS_ID);
  845. if SearchIConstant(tempstr,l) then
  846. begin
  847. str(l, tempstr);
  848. expr:=expr + tempstr;
  849. end
  850. else
  851. begin
  852. if is_locallabel(tempstr) then
  853. begin
  854. CreateLocalLabel(tempstr,hl,false);
  855. hs:=hl.name;
  856. hssymtyp:=AT_FUNCTION;
  857. end
  858. else
  859. if SearchLabel(tempstr,hl,false) then
  860. begin
  861. hs:=hl.name;
  862. hssymtyp:=AT_FUNCTION;
  863. end
  864. else
  865. begin
  866. searchsym(tempstr,sym,srsymtable);
  867. if assigned(sym) then
  868. begin
  869. case sym.typ of
  870. globalvarsym :
  871. begin
  872. hs:=tglobalvarsym(sym).mangledname;
  873. def:=tglobalvarsym(sym).vartype.def;
  874. end;
  875. localvarsym,
  876. paravarsym :
  877. begin
  878. Message(asmr_e_no_local_or_para_allowed);
  879. end;
  880. typedconstsym :
  881. begin
  882. hs:=ttypedconstsym(sym).mangledname;
  883. def:=ttypedconstsym(sym).typedconsttype.def;
  884. end;
  885. procsym :
  886. begin
  887. if Tprocsym(sym).procdef_count>1 then
  888. Message(asmr_w_calling_overload_func);
  889. hs:=tprocsym(sym).first_procdef.mangledname;
  890. hssymtyp:=AT_FUNCTION;
  891. end;
  892. typesym :
  893. begin
  894. if not(ttypesym(sym).restype.def.deftype in [recorddef,objectdef]) then
  895. Message(asmr_e_wrong_sym_type);
  896. end;
  897. else
  898. Message(asmr_e_wrong_sym_type);
  899. end;
  900. end
  901. else
  902. Message1(sym_e_unknown_id,tempstr);
  903. end;
  904. { symbol found? }
  905. if hs<>'' then
  906. begin
  907. if asmsym='' then
  908. begin
  909. asmsym:=hs;
  910. asmsymtyp:=hssymtyp;
  911. end
  912. else
  913. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  914. if (expr='') or (expr[length(expr)]='+') then
  915. begin
  916. { don't remove the + if there could be a record field }
  917. if actasmtoken<>AS_DOT then
  918. delete(expr,length(expr),1);
  919. end
  920. else
  921. if needofs then
  922. begin
  923. if (prevtok<>AS_OFFSET) then
  924. Message(asmr_e_need_offset);
  925. end
  926. else
  927. Message(asmr_e_only_add_relocatable_symbol);
  928. end;
  929. if actasmtoken=AS_DOT then
  930. begin
  931. BuildRecordOffsetSize(tempstr,l,k);
  932. str(l, tempstr);
  933. expr:=expr + tempstr;
  934. end
  935. else
  936. begin
  937. if (expr='') or (expr[length(expr)] in ['+','-','/','*']) then
  938. delete(expr,length(expr),1);
  939. end;
  940. if (actasmtoken=AS_LBRACKET) and
  941. assigned(def) and
  942. (def.deftype=arraydef) then
  943. begin
  944. consume(AS_LBRACKET);
  945. l:=BuildConstExpression;
  946. if l<tarraydef(def).lowrange then
  947. begin
  948. Message(asmr_e_constant_out_of_bounds);
  949. l:=0;
  950. end
  951. else
  952. l:=(l-tarraydef(def).lowrange)*tarraydef(def).elesize;
  953. str(l, tempstr);
  954. expr:=expr + '+' + tempstr;
  955. consume(AS_RBRACKET);
  956. end;
  957. end;
  958. { check if there are wrong operator used like / or mod etc. }
  959. if (hs<>'') and not(actasmtoken in [AS_MINUS,AS_PLUS,AS_COMMA,AS_SEPARATOR,AS_END,AS_RBRACKET]) then
  960. Message(asmr_e_only_add_relocatable_symbol);
  961. end;
  962. AS_END,
  963. AS_RBRACKET,
  964. AS_SEPARATOR,
  965. AS_COMMA:
  966. Begin
  967. break;
  968. end;
  969. else
  970. Begin
  971. { write error only once. }
  972. if not errorflag then
  973. Message(asmr_e_invalid_constant_expression);
  974. { consume tokens until we find COMMA or SEPARATOR }
  975. Consume(actasmtoken);
  976. errorflag:=TRUE;
  977. end;
  978. end;
  979. Until false;
  980. { calculate expression }
  981. if not ErrorFlag then
  982. value:=CalculateExpression(expr)
  983. else
  984. value:=0;
  985. { no longer in an expression }
  986. inexpression:=FALSE;
  987. end;
  988. Function ti386intreader.BuildConstExpression:aint;
  989. var
  990. l : aint;
  991. hs : string;
  992. hssymtyp : TAsmsymtype;
  993. begin
  994. BuildConstSymbolExpression(false,false,l,hs,hssymtyp);
  995. if hs<>'' then
  996. Message(asmr_e_relocatable_symbol_not_allowed);
  997. BuildConstExpression:=l;
  998. end;
  999. Function ti386intreader.BuildRefConstExpression:aint;
  1000. var
  1001. l : aint;
  1002. hs : string;
  1003. hssymtyp : TAsmsymtype;
  1004. begin
  1005. BuildConstSymbolExpression(false,true,l,hs,hssymtyp);
  1006. if hs<>'' then
  1007. Message(asmr_e_relocatable_symbol_not_allowed);
  1008. BuildRefConstExpression:=l;
  1009. end;
  1010. procedure ti386intreader.BuildReference(oper : tx86operand);
  1011. var
  1012. k,l,scale : aint;
  1013. tempstr,hs : string;
  1014. tempsymtyp : tasmsymtype;
  1015. typesize : longint;
  1016. code : integer;
  1017. hreg : tregister;
  1018. GotStar,GotOffset,HadVar,
  1019. GotPlus,Negative : boolean;
  1020. Begin
  1021. Consume(AS_LBRACKET);
  1022. if not(oper.opr.typ in [OPR_LOCAL,OPR_REFERENCE]) then
  1023. oper.InitRef;
  1024. GotStar:=false;
  1025. GotPlus:=true;
  1026. GotOffset:=false;
  1027. Negative:=false;
  1028. Scale:=0;
  1029. repeat
  1030. if GotOffset and (actasmtoken<>AS_ID) then
  1031. Message(asmr_e_invalid_reference_syntax);
  1032. Case actasmtoken of
  1033. AS_ID: { Constant reference expression OR variable reference expression }
  1034. Begin
  1035. if not GotPlus then
  1036. Message(asmr_e_invalid_reference_syntax);
  1037. if actasmpattern[1] = '@' then
  1038. Message(asmr_e_local_label_not_allowed_as_ref);
  1039. GotStar:=false;
  1040. GotPlus:=false;
  1041. if SearchIConstant(actasmpattern,l) or
  1042. SearchRecordType(actasmpattern) then
  1043. begin
  1044. l:=BuildRefConstExpression;
  1045. GotPlus:=(prevasmtoken=AS_PLUS);
  1046. GotStar:=(prevasmtoken=AS_STAR);
  1047. case oper.opr.typ of
  1048. OPR_LOCAL :
  1049. begin
  1050. if GotStar then
  1051. Message(asmr_e_invalid_reference_syntax);
  1052. if negative then
  1053. Dec(oper.opr.localsymofs,l)
  1054. else
  1055. Inc(oper.opr.localsymofs,l);
  1056. end;
  1057. OPR_REFERENCE :
  1058. begin
  1059. if GotStar then
  1060. oper.opr.ref.scalefactor:=l
  1061. else
  1062. begin
  1063. if negative then
  1064. Dec(oper.opr.ref.offset,l)
  1065. else
  1066. Inc(oper.opr.ref.offset,l);
  1067. end;
  1068. end;
  1069. end;
  1070. end
  1071. else
  1072. Begin
  1073. if oper.hasvar and not GotOffset then
  1074. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1075. HadVar:=oper.hasvar and GotOffset;
  1076. if negative then
  1077. Message(asmr_e_only_add_relocatable_symbol);
  1078. tempstr:=actasmpattern;
  1079. Consume(AS_ID);
  1080. { typecasting? }
  1081. if (actasmtoken=AS_LPAREN) and
  1082. SearchType(tempstr,typesize) then
  1083. begin
  1084. oper.hastype:=true;
  1085. Consume(AS_LPAREN);
  1086. BuildOperand(oper);
  1087. Consume(AS_RPAREN);
  1088. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  1089. oper.SetSize(typesize,true);
  1090. end
  1091. else
  1092. if not oper.SetupVar(tempstr,GotOffset) then
  1093. Message1(sym_e_unknown_id,tempstr);
  1094. { record.field ? }
  1095. if actasmtoken=AS_DOT then
  1096. begin
  1097. BuildRecordOffsetSize(tempstr,l,k);
  1098. case oper.opr.typ of
  1099. OPR_LOCAL :
  1100. inc(oper.opr.localsymofs,l);
  1101. OPR_REFERENCE :
  1102. inc(oper.opr.ref.offset,l);
  1103. end;
  1104. end;
  1105. if GotOffset then
  1106. begin
  1107. if oper.hasvar and (oper.opr.ref.base=current_procinfo.framepointer) then
  1108. begin
  1109. if (oper.opr.typ=OPR_REFERENCE) then
  1110. oper.opr.ref.base:=NR_NO;
  1111. oper.hasvar:=hadvar;
  1112. end
  1113. else
  1114. begin
  1115. if oper.hasvar and hadvar then
  1116. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1117. { should we allow ?? }
  1118. end;
  1119. end;
  1120. end;
  1121. GotOffset:=false;
  1122. end;
  1123. AS_PLUS :
  1124. Begin
  1125. Consume(AS_PLUS);
  1126. Negative:=false;
  1127. GotPlus:=true;
  1128. GotStar:=false;
  1129. Scale:=0;
  1130. end;
  1131. AS_MINUS :
  1132. begin
  1133. Consume(AS_MINUS);
  1134. Negative:=true;
  1135. GotPlus:=true;
  1136. GotStar:=false;
  1137. Scale:=0;
  1138. end;
  1139. AS_STAR : { Scaling, with eax*4 order }
  1140. begin
  1141. Consume(AS_STAR);
  1142. hs:='';
  1143. l:=0;
  1144. case actasmtoken of
  1145. AS_LPAREN :
  1146. l:=BuildConstExpression;
  1147. AS_INTNUM:
  1148. Begin
  1149. hs:=actasmpattern;
  1150. Consume(AS_INTNUM);
  1151. end;
  1152. AS_REGISTER :
  1153. begin
  1154. case oper.opr.typ of
  1155. OPR_REFERENCE :
  1156. begin
  1157. if oper.opr.ref.scalefactor=0 then
  1158. begin
  1159. if scale<>0 then
  1160. begin
  1161. oper.opr.ref.scalefactor:=scale;
  1162. scale:=0;
  1163. end
  1164. else
  1165. Message(asmr_e_wrong_scale_factor);
  1166. end
  1167. else
  1168. Message(asmr_e_invalid_reference_syntax);
  1169. end;
  1170. OPR_LOCAL :
  1171. begin
  1172. if oper.opr.localscale=0 then
  1173. begin
  1174. if scale<>0 then
  1175. begin
  1176. oper.opr.localscale:=scale;
  1177. scale:=0;
  1178. end
  1179. else
  1180. Message(asmr_e_wrong_scale_factor);
  1181. end
  1182. else
  1183. Message(asmr_e_invalid_reference_syntax);
  1184. end;
  1185. end;
  1186. end;
  1187. else
  1188. Message(asmr_e_invalid_reference_syntax);
  1189. end;
  1190. if actasmtoken<>AS_REGISTER then
  1191. begin
  1192. if hs<>'' then
  1193. val(hs,l,code);
  1194. case oper.opr.typ of
  1195. OPR_REFERENCE :
  1196. oper.opr.ref.scalefactor:=l;
  1197. OPR_LOCAL :
  1198. oper.opr.localscale:=l;
  1199. end;
  1200. if l>9 then
  1201. Message(asmr_e_wrong_scale_factor);
  1202. end;
  1203. GotPlus:=false;
  1204. GotStar:=false;
  1205. end;
  1206. AS_REGISTER :
  1207. begin
  1208. if not((GotPlus and (not Negative)) or
  1209. GotStar) then
  1210. Message(asmr_e_invalid_reference_syntax);
  1211. hreg:=actasmregister;
  1212. Consume(AS_REGISTER);
  1213. { this register will be the index:
  1214. 1. just read a *
  1215. 2. next token is a *
  1216. 3. base register is already used }
  1217. case oper.opr.typ of
  1218. OPR_LOCAL :
  1219. begin
  1220. if (oper.opr.localindexreg<>NR_NO) then
  1221. Message(asmr_e_multiple_index);
  1222. oper.opr.localindexreg:=hreg;
  1223. if scale<>0 then
  1224. begin
  1225. oper.opr.localscale:=scale;
  1226. scale:=0;
  1227. end;
  1228. end;
  1229. OPR_REFERENCE :
  1230. begin
  1231. if (GotStar) or
  1232. (actasmtoken=AS_STAR) or
  1233. (oper.opr.ref.base<>NR_NO) then
  1234. begin
  1235. if (oper.opr.ref.index<>NR_NO) then
  1236. Message(asmr_e_multiple_index);
  1237. oper.opr.ref.index:=hreg;
  1238. if scale<>0 then
  1239. begin
  1240. oper.opr.ref.scalefactor:=scale;
  1241. scale:=0;
  1242. end;
  1243. end
  1244. else
  1245. oper.opr.ref.base:=hreg;
  1246. end;
  1247. end;
  1248. GotPlus:=false;
  1249. GotStar:=false;
  1250. end;
  1251. AS_OFFSET :
  1252. begin
  1253. Consume(AS_OFFSET);
  1254. GotOffset:=true;
  1255. end;
  1256. AS_TYPE,
  1257. AS_NOT,
  1258. AS_STRING,
  1259. AS_INTNUM,
  1260. AS_LPAREN : { Constant reference expression }
  1261. begin
  1262. if not GotPlus and not GotStar then
  1263. Message(asmr_e_invalid_reference_syntax);
  1264. BuildConstSymbolExpression(true,true,l,tempstr,tempsymtyp);
  1265. if tempstr<>'' then
  1266. begin
  1267. if GotStar then
  1268. Message(asmr_e_only_add_relocatable_symbol);
  1269. if not assigned(oper.opr.ref.symbol) then
  1270. oper.opr.ref.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp)
  1271. else
  1272. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1273. end;
  1274. case oper.opr.typ of
  1275. OPR_REFERENCE :
  1276. begin
  1277. if GotStar then
  1278. oper.opr.ref.scalefactor:=l
  1279. else if (prevasmtoken = AS_STAR) then
  1280. begin
  1281. if scale<>0 then
  1282. scale:=l*scale
  1283. else
  1284. scale:=l;
  1285. end
  1286. else
  1287. begin
  1288. if negative then
  1289. Dec(oper.opr.ref.offset,l)
  1290. else
  1291. Inc(oper.opr.ref.offset,l);
  1292. end;
  1293. end;
  1294. OPR_LOCAL :
  1295. begin
  1296. if GotStar then
  1297. oper.opr.localscale:=l
  1298. else if (prevasmtoken = AS_STAR) then
  1299. begin
  1300. if scale<>0 then
  1301. scale:=l*scale
  1302. else
  1303. scale:=l;
  1304. end
  1305. else
  1306. begin
  1307. if negative then
  1308. Dec(oper.opr.localsymofs,l)
  1309. else
  1310. Inc(oper.opr.localsymofs,l);
  1311. end;
  1312. end;
  1313. end;
  1314. GotPlus:=(prevasmtoken=AS_PLUS) or
  1315. (prevasmtoken=AS_MINUS);
  1316. if GotPlus then
  1317. negative := prevasmtoken = AS_MINUS;
  1318. GotStar:=(prevasmtoken=AS_STAR);
  1319. end;
  1320. AS_RBRACKET :
  1321. begin
  1322. if GotPlus or GotStar then
  1323. Message(asmr_e_invalid_reference_syntax);
  1324. Consume(AS_RBRACKET);
  1325. break;
  1326. end;
  1327. else
  1328. Begin
  1329. Message(asmr_e_invalid_reference_syntax);
  1330. RecoverConsume(true);
  1331. break;
  1332. end;
  1333. end;
  1334. until false;
  1335. end;
  1336. Procedure ti386intreader.BuildConstantOperand(oper: tx86operand);
  1337. var
  1338. l : aint;
  1339. tempstr : string;
  1340. tempsymtyp : tasmsymtype;
  1341. begin
  1342. if not (oper.opr.typ in [OPR_NONE,OPR_CONSTANT]) then
  1343. Message(asmr_e_invalid_operand_type);
  1344. BuildConstSymbolExpression(true,false,l,tempstr,tempsymtyp);
  1345. if tempstr<>'' then
  1346. begin
  1347. oper.opr.typ:=OPR_SYMBOL;
  1348. oper.opr.symofs:=l;
  1349. oper.opr.symbol:=objectlibrary.newasmsymbol(tempstr,AB_EXTERNAL,tempsymtyp);
  1350. end
  1351. else
  1352. begin
  1353. if oper.opr.typ=OPR_NONE then
  1354. begin
  1355. oper.opr.typ:=OPR_CONSTANT;
  1356. oper.opr.val:=l;
  1357. end
  1358. else
  1359. inc(oper.opr.val,l);
  1360. end;
  1361. end;
  1362. Procedure ti386intreader.BuildOperand(oper: tx86operand);
  1363. procedure AddLabelOperand(hl:tasmlabel);
  1364. begin
  1365. if is_calljmp(actopcode) then
  1366. begin
  1367. oper.opr.typ:=OPR_SYMBOL;
  1368. oper.opr.symbol:=hl;
  1369. end
  1370. else
  1371. begin
  1372. oper.InitRef;
  1373. oper.opr.ref.symbol:=hl;
  1374. end;
  1375. end;
  1376. var
  1377. expr : string;
  1378. tempreg : tregister;
  1379. typesize,
  1380. l : aint;
  1381. hl : tasmlabel;
  1382. toffset,
  1383. tsize : aint;
  1384. Begin
  1385. expr:='';
  1386. repeat
  1387. if actasmtoken=AS_DOT then
  1388. begin
  1389. if expr<>'' then
  1390. begin
  1391. BuildRecordOffsetSize(expr,toffset,tsize);
  1392. oper.SetSize(tsize,true);
  1393. case oper.opr.typ of
  1394. OPR_LOCAL :
  1395. begin
  1396. { don't allow direct access to fields of parameters, becuase that
  1397. will generate buggy code. Allow it only for explicit typecasting
  1398. and when the parameter is in a register (delphi compatible) }
  1399. if (not oper.hastype) and
  1400. (oper.opr.localsym.owner.symtabletype=parasymtable) and
  1401. (current_procinfo.procdef.proccalloption<>pocall_register) then
  1402. Message(asmr_e_cannot_access_field_directly_for_parameters);
  1403. inc(oper.opr.localsymofs,toffset)
  1404. end;
  1405. OPR_CONSTANT :
  1406. inc(oper.opr.val,toffset);
  1407. OPR_REFERENCE :
  1408. inc(oper.opr.ref.offset,toffset);
  1409. OPR_NONE :
  1410. begin
  1411. oper.opr.typ:=OPR_CONSTANT;
  1412. oper.opr.val:=toffset;
  1413. end;
  1414. else
  1415. internalerror(200309222);
  1416. end;
  1417. expr:='';
  1418. end
  1419. else
  1420. begin
  1421. { See it as a separator }
  1422. Consume(AS_DOT);
  1423. end;
  1424. end;
  1425. case actasmtoken of
  1426. AS_OFFSET,
  1427. AS_SIZEOF,
  1428. AS_TYPE,
  1429. AS_NOT,
  1430. AS_STRING,
  1431. AS_PLUS,
  1432. AS_MINUS,
  1433. AS_LPAREN,
  1434. AS_INTNUM :
  1435. begin
  1436. case oper.opr.typ of
  1437. OPR_REFERENCE :
  1438. inc(oper.opr.ref.offset,BuildRefConstExpression);
  1439. OPR_LOCAL :
  1440. inc(oper.opr.localsymofs,BuildConstExpression);
  1441. OPR_NONE,
  1442. OPR_CONSTANT :
  1443. BuildConstantOperand(oper);
  1444. else
  1445. Message(asmr_e_invalid_operand_type);
  1446. end;
  1447. end;
  1448. AS_ID : { A constant expression, or a Variable ref. }
  1449. Begin
  1450. { Label or Special symbol reference? }
  1451. if actasmpattern[1] = '@' then
  1452. Begin
  1453. if actasmpattern = '@RESULT' then
  1454. Begin
  1455. oper.SetupResult;
  1456. Consume(AS_ID);
  1457. end
  1458. else
  1459. if (actasmpattern = '@CODE') or (actasmpattern = '@DATA') then
  1460. begin
  1461. Message(asmr_w_CODE_and_DATA_not_supported);
  1462. Consume(AS_ID);
  1463. end
  1464. else
  1465. { Local Label }
  1466. begin
  1467. CreateLocalLabel(actasmpattern,hl,false);
  1468. Consume(AS_ID);
  1469. AddLabelOperand(hl);
  1470. if not (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then
  1471. Message(asmr_e_syntax_error);
  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. if not (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then
  1507. Message(asmr_e_syntax_error);
  1508. end
  1509. else
  1510. { is it a normal variable ? }
  1511. Begin
  1512. expr:=actasmpattern;
  1513. Consume(AS_ID);
  1514. { typecasting? }
  1515. if SearchType(expr,typesize) then
  1516. begin
  1517. oper.hastype:=true;
  1518. if (actasmtoken=AS_LPAREN) then
  1519. begin
  1520. Consume(AS_LPAREN);
  1521. BuildOperand(oper);
  1522. Consume(AS_RPAREN);
  1523. if oper.opr.typ in [OPR_REFERENCE,OPR_LOCAL] then
  1524. oper.SetSize(typesize,true);
  1525. end;
  1526. end
  1527. else
  1528. begin
  1529. if not oper.SetupVar(expr,false) then
  1530. Begin
  1531. { not a variable, check special variables.. }
  1532. if expr = 'SELF' then
  1533. oper.SetupSelf
  1534. else
  1535. Message1(sym_e_unknown_id,expr);
  1536. expr:='';
  1537. end;
  1538. end;
  1539. end;
  1540. end;
  1541. end;
  1542. AS_REGISTER : { Register, a variable reference or a constant reference }
  1543. begin
  1544. { save the type of register used. }
  1545. tempreg:=actasmregister;
  1546. Consume(AS_REGISTER);
  1547. if actasmtoken = AS_COLON then
  1548. Begin
  1549. Consume(AS_COLON);
  1550. oper.InitRef;
  1551. oper.opr.ref.segment:=tempreg;
  1552. BuildReference(oper);
  1553. end
  1554. else
  1555. { Simple register }
  1556. begin
  1557. if not (oper.opr.typ in [OPR_NONE,OPR_REGISTER]) then
  1558. Message(asmr_e_invalid_operand_type);
  1559. oper.opr.typ:=OPR_REGISTER;
  1560. oper.opr.reg:=tempreg;
  1561. oper.SetSize(tcgsize2size[reg_cgsize(oper.opr.reg)],true);
  1562. end;
  1563. end;
  1564. AS_LBRACKET: { a variable reference, register ref. or a constant reference }
  1565. Begin
  1566. BuildReference(oper);
  1567. end;
  1568. AS_SEG :
  1569. Begin
  1570. Message(asmr_e_seg_not_supported);
  1571. Consume(actasmtoken);
  1572. end;
  1573. AS_SEPARATOR,
  1574. AS_END,
  1575. AS_COMMA:
  1576. break;
  1577. else
  1578. Message(asmr_e_syn_operand);
  1579. end;
  1580. until not(actasmtoken in [AS_DOT,AS_PLUS,AS_LBRACKET]);
  1581. if not((actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) or
  1582. (oper.hastype and (actasmtoken=AS_RPAREN))) then
  1583. begin
  1584. Message(asmr_e_syntax_error);
  1585. RecoverConsume(true);
  1586. end;
  1587. end;
  1588. Procedure ti386intreader.BuildOpCode(instr : tx86instruction);
  1589. var
  1590. PrefixOp,OverrideOp: tasmop;
  1591. size,
  1592. operandnum : longint;
  1593. Begin
  1594. PrefixOp:=A_None;
  1595. OverrideOp:=A_None;
  1596. { prefix seg opcode / prefix opcode }
  1597. repeat
  1598. if is_prefix(actopcode) then
  1599. begin
  1600. with instr do
  1601. begin
  1602. OpOrder:=op_intel;
  1603. PrefixOp:=ActOpcode;
  1604. opcode:=ActOpcode;
  1605. condition:=ActCondition;
  1606. opsize:=ActOpsize;
  1607. ConcatInstruction(curlist);
  1608. end;
  1609. Consume(AS_OPCODE);
  1610. end
  1611. else
  1612. if is_override(actopcode) then
  1613. begin
  1614. with instr do
  1615. begin
  1616. OpOrder:=op_intel;
  1617. OverrideOp:=ActOpcode;
  1618. opcode:=ActOpcode;
  1619. condition:=ActCondition;
  1620. opsize:=ActOpsize;
  1621. ConcatInstruction(curlist);
  1622. end;
  1623. Consume(AS_OPCODE);
  1624. end
  1625. else
  1626. break;
  1627. { allow for newline after prefix or override }
  1628. while actasmtoken=AS_SEPARATOR do
  1629. Consume(AS_SEPARATOR);
  1630. until (actasmtoken<>AS_OPCODE);
  1631. { opcode }
  1632. if (actasmtoken <> AS_OPCODE) then
  1633. Begin
  1634. Message(asmr_e_invalid_or_missing_opcode);
  1635. RecoverConsume(false);
  1636. exit;
  1637. end;
  1638. { Fill the instr object with the current state }
  1639. with instr do
  1640. begin
  1641. OpOrder:=op_intel;
  1642. Opcode:=ActOpcode;
  1643. condition:=ActCondition;
  1644. opsize:=ActOpsize;
  1645. { Valid combination of prefix/override and instruction ? }
  1646. if (prefixop<>A_NONE) and (NOT CheckPrefix(PrefixOp,actopcode)) then
  1647. Message1(asmr_e_invalid_prefix_and_opcode,actasmpattern);
  1648. if (overrideop<>A_NONE) and (NOT CheckOverride(OverrideOp,ActOpcode)) then
  1649. Message1(asmr_e_invalid_override_and_opcode,actasmpattern);
  1650. end;
  1651. { We are reading operands, so opcode will be an AS_ID }
  1652. operandnum:=1;
  1653. Consume(AS_OPCODE);
  1654. { Zero operand opcode ? }
  1655. if actasmtoken in [AS_SEPARATOR,AS_END] then
  1656. begin
  1657. operandnum:=0;
  1658. exit;
  1659. end;
  1660. { Read Operands }
  1661. repeat
  1662. case actasmtoken of
  1663. { End of asm operands for this opcode }
  1664. AS_END,
  1665. AS_SEPARATOR :
  1666. break;
  1667. { Operand delimiter }
  1668. AS_COMMA :
  1669. Begin
  1670. if operandnum > Max_Operands then
  1671. Message(asmr_e_too_many_operands)
  1672. else
  1673. Inc(operandnum);
  1674. Consume(AS_COMMA);
  1675. end;
  1676. { Typecast, Constant Expression, Type Specifier }
  1677. AS_DWORD,
  1678. AS_BYTE,
  1679. AS_WORD,
  1680. AS_TBYTE,
  1681. AS_DQWORD,
  1682. AS_QWORD :
  1683. Begin
  1684. { load the size in a temp variable, so it can be set when the
  1685. operand is read }
  1686. size:=0;
  1687. Case actasmtoken of
  1688. AS_DWORD : size:=4;
  1689. AS_WORD : size:=2;
  1690. AS_BYTE : size:=1;
  1691. AS_QWORD : size:=8;
  1692. AS_DQWORD : size:=16;
  1693. AS_TBYTE : size:=10;
  1694. end;
  1695. Consume(actasmtoken);
  1696. case actasmtoken of
  1697. AS_LPAREN :
  1698. begin
  1699. instr.Operands[operandnum].hastype:=true;
  1700. Consume(AS_LPAREN);
  1701. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1702. Consume(AS_RPAREN);
  1703. end;
  1704. AS_PTR :
  1705. begin
  1706. Consume(AS_PTR);
  1707. instr.Operands[operandnum].InitRef;
  1708. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1709. end;
  1710. else
  1711. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1712. end;
  1713. { now set the size which was specified by the override }
  1714. instr.Operands[operandnum].setsize(size,true);
  1715. end;
  1716. { Type specifier }
  1717. AS_NEAR,
  1718. AS_FAR :
  1719. Begin
  1720. if actasmtoken = AS_NEAR then
  1721. begin
  1722. Message(asmr_w_near_ignored);
  1723. instr.opsize:=S_NEAR;
  1724. end
  1725. else
  1726. begin
  1727. Message(asmr_w_far_ignored);
  1728. instr.opsize:=S_FAR;
  1729. end;
  1730. Consume(actasmtoken);
  1731. if actasmtoken=AS_PTR then
  1732. begin
  1733. Consume(AS_PTR);
  1734. instr.Operands[operandnum].InitRef;
  1735. end;
  1736. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1737. end;
  1738. else
  1739. BuildOperand(instr.Operands[operandnum] as tx86operand);
  1740. end; { end case }
  1741. until false;
  1742. instr.Ops:=operandnum;
  1743. end;
  1744. Procedure ti386intreader.BuildConstant(constsize: byte);
  1745. var
  1746. asmsymtyp : tasmsymtype;
  1747. asmsym,
  1748. expr: string;
  1749. value : aint;
  1750. Begin
  1751. Repeat
  1752. Case actasmtoken of
  1753. AS_STRING:
  1754. Begin
  1755. { DD and DW cases }
  1756. if constsize <> 1 then
  1757. Begin
  1758. if Not PadZero(actasmpattern,constsize) then
  1759. Message(scan_f_string_exceeds_line);
  1760. end;
  1761. expr:=actasmpattern;
  1762. Consume(AS_STRING);
  1763. Case actasmtoken of
  1764. AS_COMMA:
  1765. Consume(AS_COMMA);
  1766. AS_END,
  1767. AS_SEPARATOR: ;
  1768. else
  1769. Message(asmr_e_invalid_string_expression);
  1770. end;
  1771. ConcatString(curlist,expr);
  1772. end;
  1773. AS_PLUS,
  1774. AS_MINUS,
  1775. AS_LPAREN,
  1776. AS_NOT,
  1777. AS_INTNUM,
  1778. AS_ID :
  1779. Begin
  1780. BuildConstSymbolExpression(false,false,value,asmsym,asmsymtyp);
  1781. if asmsym<>'' then
  1782. begin
  1783. if constsize<>sizeof(aint) then
  1784. Message1(asmr_w_const32bit_for_address,asmsym);
  1785. ConcatConstSymbol(curlist,asmsym,asmsymtyp,value)
  1786. end
  1787. else
  1788. ConcatConstant(curlist,value,constsize);
  1789. end;
  1790. AS_COMMA:
  1791. Consume(AS_COMMA);
  1792. AS_END,
  1793. AS_SEPARATOR:
  1794. break;
  1795. else
  1796. begin
  1797. Message(asmr_e_syn_constant);
  1798. RecoverConsume(false);
  1799. end
  1800. end;
  1801. Until false;
  1802. end;
  1803. function ti386intreader.Assemble: tlinkedlist;
  1804. Var
  1805. hl : tasmlabel;
  1806. instr : Tx86Instruction;
  1807. Begin
  1808. Message1(asmr_d_start_reading,'intel');
  1809. inexpression:=FALSE;
  1810. firsttoken:=TRUE;
  1811. { sets up all opcode and register tables in uppercase
  1812. done in the construtor now
  1813. if not _asmsorted then
  1814. Begin
  1815. SetupTables;
  1816. _asmsorted:=TRUE;
  1817. end;
  1818. }
  1819. curlist:=TAAsmoutput.Create;
  1820. { setup label linked list }
  1821. LocalLabelList:=TLocalLabelList.Create;
  1822. { start tokenizer }
  1823. c:=current_scanner.asmgetcharstart;
  1824. gettoken;
  1825. { main loop }
  1826. repeat
  1827. case actasmtoken of
  1828. AS_LLABEL:
  1829. Begin
  1830. if CreateLocalLabel(actasmpattern,hl,true) then
  1831. ConcatLabel(curlist,hl);
  1832. Consume(AS_LLABEL);
  1833. end;
  1834. AS_LABEL:
  1835. Begin
  1836. if SearchLabel(upper(actasmpattern),hl,true) then
  1837. ConcatLabel(curlist,hl)
  1838. else
  1839. Message1(asmr_e_unknown_label_identifier,actasmpattern);
  1840. Consume(AS_LABEL);
  1841. end;
  1842. AS_DW :
  1843. Begin
  1844. inexpression:=true;
  1845. Consume(AS_DW);
  1846. BuildConstant(2);
  1847. inexpression:=false;
  1848. end;
  1849. AS_DB :
  1850. Begin
  1851. inexpression:=true;
  1852. Consume(AS_DB);
  1853. BuildConstant(1);
  1854. inexpression:=false;
  1855. end;
  1856. AS_DD :
  1857. Begin
  1858. inexpression:=true;
  1859. Consume(AS_DD);
  1860. BuildConstant(4);
  1861. inexpression:=false;
  1862. end;
  1863. AS_ALIGN:
  1864. Begin
  1865. Consume(AS_ALIGN);
  1866. ConcatAlign(curlist,BuildConstExpression);
  1867. if actasmtoken<>AS_SEPARATOR then
  1868. Consume(AS_SEPARATOR);
  1869. end;
  1870. AS_OPCODE :
  1871. Begin
  1872. instr:=Tx86Instruction.Create(Tx86Operand);
  1873. BuildOpcode(instr);
  1874. with instr do
  1875. begin
  1876. { We need AT&T style operands }
  1877. Swapoperands;
  1878. { Must be done with args in ATT order }
  1879. CheckNonCommutativeOpcodes;
  1880. AddReferenceSizes;
  1881. SetInstructionOpsize;
  1882. CheckOperandSizes;
  1883. ConcatInstruction(curlist);
  1884. end;
  1885. instr.Free;
  1886. end;
  1887. AS_SEPARATOR :
  1888. Begin
  1889. Consume(AS_SEPARATOR);
  1890. end;
  1891. AS_END :
  1892. break; { end assembly block }
  1893. else
  1894. Begin
  1895. Message(asmr_e_syntax_error);
  1896. RecoverConsume(false);
  1897. end;
  1898. end; { end case }
  1899. until false;
  1900. { Check LocalLabelList }
  1901. LocalLabelList.CheckEmitted;
  1902. LocalLabelList.Free;
  1903. { Return the list in an asmnode }
  1904. assemble:=curlist;
  1905. Message1(asmr_d_finish_reading,'intel');
  1906. end;
  1907. {*****************************************************************************
  1908. Initialize
  1909. *****************************************************************************}
  1910. const
  1911. asmmode_i386_intel_info : tasmmodeinfo =
  1912. (
  1913. id : asmmode_i386_intel;
  1914. idtxt : 'INTEL';
  1915. casmreader : ti386intreader;
  1916. );
  1917. begin
  1918. RegisterAsmMode(asmmode_i386_intel_info);
  1919. end.
  1920. {
  1921. $Log$
  1922. Revision 1.83 2004-12-22 17:09:55 peter
  1923. * support sizeof()
  1924. * fix typecasting a constant like dword(4)
  1925. Revision 1.82 2004/11/29 18:50:15 peter
  1926. * os2 fixes for import
  1927. * asmsymtype support for intel reader
  1928. Revision 1.81 2004/11/21 21:36:13 peter
  1929. * allow spaces before : of a label
  1930. Revision 1.80 2004/11/09 22:32:59 peter
  1931. * small m68k updates to bring it up2date
  1932. * give better error for external local variable
  1933. Revision 1.79 2004/11/08 22:09:59 peter
  1934. * tvarsym splitted
  1935. Revision 1.78 2004/10/31 21:45:03 peter
  1936. * generic tlocation
  1937. * move tlocation to cgutils
  1938. Revision 1.77 2004/09/13 20:25:52 peter
  1939. * support byte() typecast
  1940. * support array index
  1941. Revision 1.76 2004/07/06 19:47:19 peter
  1942. * fixed parsing of strings in db
  1943. Revision 1.75 2004/06/23 14:54:46 peter
  1944. * align directive added
  1945. Revision 1.74 2004/06/20 08:55:31 florian
  1946. * logs truncated
  1947. Revision 1.73 2004/06/16 20:07:10 florian
  1948. * dwarf branch merged
  1949. Revision 1.72 2004/05/20 21:54:33 florian
  1950. + <pointer> - <pointer> result is divided by the pointer element size now
  1951. this is delphi compatible as well as resulting in the expected result for p1+(p2-p1)
  1952. Revision 1.71.2.3 2004/05/02 00:31:33 peter
  1953. * fixedi i386 compile
  1954. Revision 1.71.2.2 2004/05/01 23:36:47 peter
  1955. * assembler reader 64bit fixes
  1956. Revision 1.71.2.1 2004/05/01 16:02:10 peter
  1957. * POINTER_SIZE replaced with sizeof(aint)
  1958. * aint,aword,tconst*int moved to globtype
  1959. }