ra386int.pas 71 KB

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