ra386att.pas 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Carl Eric Codere and Peter Vreman
  4. Does the parsing for the AT&T 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. {$ifdef TP}
  19. {$N+,E+}
  20. {$endif TP}
  21. Unit Ra386att;
  22. Interface
  23. uses
  24. tree;
  25. function assemble: ptree;
  26. Implementation
  27. Uses
  28. globtype,
  29. strings,cobjects,systems,verbose,globals,
  30. files,aasm,types,symconst,symtable,scanner,cpubase,
  31. {$ifdef NEWCG}
  32. cgbase,
  33. {$else}
  34. hcodegen,
  35. {$endif}
  36. rautils,ra386;
  37. type
  38. tasmtoken = (
  39. AS_NONE,AS_LABEL,AS_LLABEL,AS_STRING,AS_INTNUM,
  40. AS_REALNUM,AS_COMMA,AS_LPAREN,
  41. AS_RPAREN,AS_COLON,AS_DOT,AS_PLUS,AS_MINUS,AS_STAR,
  42. AS_SEPARATOR,AS_ID,AS_REGISTER,AS_OPCODE,AS_SLASH,AS_DOLLAR,
  43. {------------------ Assembler directives --------------------}
  44. AS_DB,AS_DW,AS_DD,AS_DQ,AS_GLOBAL,
  45. AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII,
  46. AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,
  47. AS_DATA,AS_TEXT,AS_END,
  48. {------------------ Assembler Operators --------------------}
  49. AS_TYPE,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR);
  50. tasmkeyword = string[10];
  51. const
  52. { These tokens should be modified accordingly to the modifications }
  53. { in the different enumerations. }
  54. firstdirective = AS_DB;
  55. lastdirective = AS_END;
  56. _count_asmprefixes = 5;
  57. _count_asmspecialops = 25;
  58. _count_asmoverrides = 3;
  59. token2str : array[tasmtoken] of tasmkeyword=(
  60. '','Label','LLabel','string','integer',
  61. 'float',',','(',
  62. ')',':','.','+','-','*',
  63. ';','identifier','register','opcode','/','$',
  64. '.byte','.word','.long','.quad','.globl',
  65. '.align','.balign','.p2align','.ascii',
  66. '.asciz','.lcomm','.comm','.single','.double','.tfloat',
  67. '.data','.text','END',
  68. 'TYPE','%','<<','>>','!','&','|','^','~');
  69. const
  70. newline = #10;
  71. firsttoken : boolean = TRUE;
  72. var
  73. _asmsorted : boolean;
  74. curlist : paasmoutput;
  75. c : char;
  76. actasmtoken : tasmtoken;
  77. prevasmtoken : tasmtoken;
  78. actasmpattern : string;
  79. actopcode : tasmop;
  80. actasmregister : tregister;
  81. actopsize : topsize;
  82. actcondition : tasmcond;
  83. iasmops : Pdictionary;
  84. iasmregs : ^reg2strtable;
  85. Procedure SetupTables;
  86. { creates uppercased symbol tables for speed access }
  87. var
  88. i : tasmop;
  89. j : tregister;
  90. str2opentry: pstr2opentry;
  91. Begin
  92. { opcodes }
  93. new(iasmops,init);
  94. for i:=firstop to lastop do
  95. begin
  96. new(str2opentry,initname(upper(att_op2str[i])));
  97. str2opentry^.op:=i;
  98. iasmops^.insert(str2opentry);
  99. end;
  100. { registers }
  101. new(iasmregs);
  102. for j:=firstreg to lastreg do
  103. iasmregs^[j] := upper(att_reg2str[j]);
  104. end;
  105. {---------------------------------------------------------------------}
  106. { Routines for the tokenizing }
  107. {---------------------------------------------------------------------}
  108. function is_asmopcode(const s: string):boolean;
  109. const
  110. { We need first to check the long prefixes, else we get probs
  111. with things like movsbl }
  112. att_sizesuffixstr : array[0..9] of string[2] = (
  113. '','BW','BL','WL','B','W','L','S','Q','T'
  114. );
  115. att_sizesuffix : array[0..9] of topsize = (
  116. S_NO,S_BW,S_BL,S_WL,S_B,S_W,S_L,S_FS,S_IQ,S_FX
  117. );
  118. att_sizefpusuffix : array[0..9] of topsize = (
  119. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_FL,S_FS,S_IQ,S_FX
  120. );
  121. att_sizefpuintsuffix : array[0..9] of topsize = (
  122. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
  123. );
  124. var
  125. str2opentry: pstr2opentry;
  126. cond : string[4];
  127. cnd : tasmcond;
  128. len,
  129. j,
  130. sufidx : longint;
  131. Begin
  132. is_asmopcode:=FALSE;
  133. actopcode:=A_None;
  134. actcondition:=C_None;
  135. actopsize:=S_NO;
  136. { search for all possible suffixes }
  137. for sufidx:=low(att_sizesuffixstr) to high(att_sizesuffixstr) do
  138. begin
  139. len:=length(s)-length(att_sizesuffixstr[sufidx]);
  140. if copy(s,len+1,length(att_sizesuffixstr[sufidx]))=att_sizesuffixstr[sufidx] then
  141. begin
  142. { here we search the entire table... }
  143. str2opentry:=nil;
  144. if {(length(s)>0) and} (len>0) then
  145. str2opentry:=pstr2opentry(iasmops^.search(copy(s,1,len)));
  146. if assigned(str2opentry) then
  147. begin
  148. actopcode:=str2opentry^.op;
  149. if att_needsuffix[actopcode]=attsufFPU then
  150. actopsize:=att_sizefpusuffix[sufidx]
  151. else if att_needsuffix[actopcode]=attsufFPUint then
  152. actopsize:=att_sizefpuintsuffix[sufidx]
  153. else
  154. actopsize:=att_sizesuffix[sufidx];
  155. actasmtoken:=AS_OPCODE;
  156. is_asmopcode:=TRUE;
  157. exit;
  158. end;
  159. { not found, check condition opcodes }
  160. j:=0;
  161. while (j<CondAsmOps) do
  162. begin
  163. if Copy(s,1,Length(CondAsmOpStr[j]))=CondAsmOpStr[j] then
  164. begin
  165. cond:=Copy(s,Length(CondAsmOpStr[j])+1,len-Length(CondAsmOpStr[j]));
  166. if cond<>'' then
  167. begin
  168. for cnd:=low(TasmCond) to high(TasmCond) do
  169. if Cond=Upper(cond2str[cnd]) then
  170. begin
  171. actopcode:=CondASmOp[j];
  172. if att_needsuffix[actopcode]=attsufFPU then
  173. actopsize:=att_sizefpusuffix[sufidx]
  174. else if att_needsuffix[actopcode]=attsufFPUint then
  175. actopsize:=att_sizefpuintsuffix[sufidx]
  176. else
  177. actopsize:=att_sizesuffix[sufidx];
  178. actcondition:=cnd;
  179. actasmtoken:=AS_OPCODE;
  180. is_asmopcode:=TRUE;
  181. exit;
  182. end;
  183. end;
  184. end;
  185. inc(j);
  186. end;
  187. end;
  188. end;
  189. end;
  190. Function is_asmdirective(const s: string):boolean;
  191. var
  192. i : tasmtoken;
  193. hs : string;
  194. Begin
  195. { GNU as is also not casesensitive with this }
  196. hs:=lower(s);
  197. for i:=firstdirective to lastdirective do
  198. if hs=token2str[i] then
  199. begin
  200. actasmtoken:=i;
  201. is_asmdirective:=true;
  202. exit;
  203. end;
  204. is_asmdirective:=false;
  205. end;
  206. Function is_register(const s: string):boolean;
  207. Var
  208. i : tregister;
  209. Begin
  210. actasmregister:=R_NO;
  211. for i:=firstreg to lastreg do
  212. if s=iasmregs^[i] then
  213. begin
  214. actasmtoken:=AS_REGISTER;
  215. actasmregister:=i;
  216. is_register:=true;
  217. exit;
  218. end;
  219. is_register:=false;
  220. end;
  221. Function is_locallabel(const s: string):boolean;
  222. begin
  223. is_locallabel:=(length(s)>=2) and (s[1]='.') and (s[2]='L');
  224. end;
  225. Procedure GetToken;
  226. var
  227. len : longint;
  228. begin
  229. { save old token and reset new token }
  230. prevasmtoken:=actasmtoken;
  231. actasmtoken:=AS_NONE;
  232. { reset }
  233. actasmpattern:='';
  234. { while space and tab , continue scan... }
  235. while c in [' ',#9] do
  236. c:=current_scanner^.asmgetchar;
  237. { get token pos }
  238. if not (c in [newline,#13,'{',';']) then
  239. current_scanner^.gettokenpos;
  240. { Local Label, Label, Directive, Prefix or Opcode }
  241. if firsttoken and not(c in [newline,#13,'{',';']) then
  242. begin
  243. firsttoken:=FALSE;
  244. len:=0;
  245. { directive or local label }
  246. if c = '.' then
  247. begin
  248. inc(len);
  249. actasmpattern[len]:=c;
  250. { Let us point to the next character }
  251. c:=current_scanner^.asmgetchar;
  252. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  253. begin
  254. inc(len);
  255. actasmpattern[len]:=c;
  256. c:=current_scanner^.asmgetchar;
  257. end;
  258. actasmpattern[0]:=chr(len);
  259. { this is a local label... }
  260. if (c=':') and is_locallabel(actasmpattern) then
  261. Begin
  262. { local variables are case sensitive }
  263. actasmtoken:=AS_LLABEL;
  264. c:=current_scanner^.asmgetchar;
  265. firsttoken:=true;
  266. exit;
  267. end
  268. { must be a directive }
  269. else
  270. Begin
  271. { directives are case sensitive!! }
  272. if is_asmdirective(actasmpattern) then
  273. exit;
  274. Message1(asmr_e_not_directive_or_local_symbol,actasmpattern);
  275. end;
  276. end;
  277. { only opcodes and global labels are allowed now. }
  278. while c in ['A'..'Z','a'..'z','0'..'9','_'] do
  279. begin
  280. inc(len);
  281. actasmpattern[len]:=c;
  282. c:=current_scanner^.asmgetchar;
  283. end;
  284. actasmpattern[0]:=chr(len);
  285. { Label ? }
  286. if c = ':' then
  287. begin
  288. actasmtoken:=AS_LABEL;
  289. { let us point to the next character }
  290. c:=current_scanner^.asmgetchar;
  291. firsttoken:=true;
  292. exit;
  293. end;
  294. { Opcode ? }
  295. If is_asmopcode(upper(actasmpattern)) then
  296. Begin
  297. uppervar(actasmpattern);
  298. exit;
  299. end;
  300. { End of assemblerblock ? }
  301. if upper(actasmpattern) = 'END' then
  302. begin
  303. actasmtoken:=AS_END;
  304. exit;
  305. end;
  306. message1(asmr_e_unknown_opcode,actasmpattern);
  307. actasmtoken:=AS_NONE;
  308. end
  309. else { else firsttoken }
  310. { Here we must handle all possible cases }
  311. begin
  312. case c of
  313. '.' : { possiblities : - local label reference , such as in jmp @local1 }
  314. { - field of object/record }
  315. { - directive. }
  316. begin
  317. if (prevasmtoken in [AS_ID,AS_RPAREN]) then
  318. begin
  319. c:=current_scanner^.asmgetchar;
  320. actasmtoken:=AS_DOT;
  321. exit;
  322. end;
  323. actasmpattern:=c;
  324. c:=current_scanner^.asmgetchar;
  325. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  326. begin
  327. actasmpattern:=actasmpattern + c;
  328. c:=current_scanner^.asmgetchar;
  329. end;
  330. if is_asmdirective(actasmpattern) then
  331. exit;
  332. { local label references and directives }
  333. { are case sensitive }
  334. actasmtoken:=AS_ID;
  335. exit;
  336. end;
  337. { identifier, register, prefix or directive }
  338. '_','A'..'Z','a'..'z':
  339. begin
  340. len:=0;
  341. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  342. begin
  343. inc(len);
  344. actasmpattern[len]:=c;
  345. c:=current_scanner^.asmgetchar;
  346. end;
  347. actasmpattern[0]:=chr(len);
  348. uppervar(actasmpattern);
  349. { Opcode, can only be when the previous was a prefix }
  350. If is_prefix(actopcode) and is_asmopcode(upper(actasmpattern)) then
  351. Begin
  352. uppervar(actasmpattern);
  353. exit;
  354. end;
  355. { check for end which is a reserved word unlike the opcodes }
  356. if actasmpattern = 'END' then
  357. Begin
  358. actasmtoken:=AS_END;
  359. exit;
  360. end;
  361. if actasmpattern = 'TYPE' then
  362. Begin
  363. actasmtoken:=AS_TYPE;
  364. exit;
  365. end;
  366. actasmtoken:=AS_ID;
  367. exit;
  368. end;
  369. '%' : { register or modulo }
  370. begin
  371. len:=1;
  372. actasmpattern[len]:='%';
  373. c:=current_scanner^.asmgetchar;
  374. { to be a register there must be a letter and not a number }
  375. if c in ['0'..'9'] then
  376. begin
  377. actasmtoken:=AS_MOD;
  378. {Message(asmr_w_modulo_not_supported);}
  379. end
  380. else
  381. begin
  382. while c in ['a'..'z','A'..'Z','0'..'9'] do
  383. Begin
  384. inc(len);
  385. actasmpattern[len]:=c;
  386. c:=current_scanner^.asmgetchar;
  387. end;
  388. actasmpattern[0]:=chr(len);
  389. uppervar(actasmpattern);
  390. if (actasmpattern = '%ST') and (c='(') then
  391. Begin
  392. actasmpattern:=actasmpattern+c;
  393. c:=current_scanner^.asmgetchar;
  394. if c in ['0'..'9'] then
  395. actasmpattern:=actasmpattern + c
  396. else
  397. Message(asmr_e_invalid_fpu_register);
  398. c:=current_scanner^.asmgetchar;
  399. if c <> ')' then
  400. Message(asmr_e_invalid_fpu_register)
  401. else
  402. Begin
  403. actasmpattern:=actasmpattern + c;
  404. c:=current_scanner^.asmgetchar; { let us point to next character. }
  405. end;
  406. end;
  407. if is_register(actasmpattern) then
  408. exit;
  409. Message(asmr_e_invalid_register);
  410. actasmtoken:=AS_NONE;
  411. end;
  412. end;
  413. '1'..'9': { integer number }
  414. begin
  415. len:=0;
  416. while c in ['0'..'9'] do
  417. Begin
  418. inc(len);
  419. actasmpattern[len]:=c;
  420. c:=current_scanner^.asmgetchar;
  421. end;
  422. actasmpattern[0]:=chr(len);
  423. actasmpattern:=tostr(ValDecimal(actasmpattern));
  424. actasmtoken:=AS_INTNUM;
  425. exit;
  426. end;
  427. '0' : { octal,hexa,real or binary number. }
  428. begin
  429. actasmpattern:=c;
  430. c:=current_scanner^.asmgetchar;
  431. case upcase(c) of
  432. 'B': { binary }
  433. Begin
  434. c:=current_scanner^.asmgetchar;
  435. while c in ['0','1'] do
  436. Begin
  437. actasmpattern:=actasmpattern + c;
  438. c:=current_scanner^.asmgetchar;
  439. end;
  440. actasmpattern:=tostr(ValBinary(actasmpattern));
  441. actasmtoken:=AS_INTNUM;
  442. exit;
  443. end;
  444. 'D': { real }
  445. Begin
  446. c:=current_scanner^.asmgetchar;
  447. { get ridd of the 0d }
  448. if (c in ['+','-']) then
  449. begin
  450. actasmpattern:=c;
  451. c:=current_scanner^.asmgetchar;
  452. end
  453. else
  454. actasmpattern:='';
  455. while c in ['0'..'9'] do
  456. Begin
  457. actasmpattern:=actasmpattern + c;
  458. c:=current_scanner^.asmgetchar;
  459. end;
  460. if c='.' then
  461. begin
  462. actasmpattern:=actasmpattern + c;
  463. c:=current_scanner^.asmgetchar;
  464. while c in ['0'..'9'] do
  465. Begin
  466. actasmpattern:=actasmpattern + c;
  467. c:=current_scanner^.asmgetchar;
  468. end;
  469. if upcase(c) = 'E' then
  470. begin
  471. actasmpattern:=actasmpattern + c;
  472. c:=current_scanner^.asmgetchar;
  473. if (c in ['+','-']) then
  474. begin
  475. actasmpattern:=actasmpattern + c;
  476. c:=current_scanner^.asmgetchar;
  477. end;
  478. while c in ['0'..'9'] do
  479. Begin
  480. actasmpattern:=actasmpattern + c;
  481. c:=current_scanner^.asmgetchar;
  482. end;
  483. end;
  484. actasmtoken:=AS_REALNUM;
  485. exit;
  486. end
  487. else
  488. begin
  489. Message1(asmr_e_invalid_float_const,actasmpattern+c);
  490. actasmtoken:=AS_NONE;
  491. end;
  492. end;
  493. 'X': { hexadecimal }
  494. Begin
  495. c:=current_scanner^.asmgetchar;
  496. while c in ['0'..'9','a'..'f','A'..'F'] do
  497. Begin
  498. actasmpattern:=actasmpattern + c;
  499. c:=current_scanner^.asmgetchar;
  500. end;
  501. actasmpattern:=tostr(ValHexaDecimal(actasmpattern));
  502. actasmtoken:=AS_INTNUM;
  503. exit;
  504. end;
  505. '1'..'7': { octal }
  506. begin
  507. actasmpattern:=actasmpattern + c;
  508. while c in ['0'..'7'] do
  509. Begin
  510. actasmpattern:=actasmpattern + c;
  511. c:=current_scanner^.asmgetchar;
  512. end;
  513. actasmpattern:=tostr(ValOctal(actasmpattern));
  514. actasmtoken:=AS_INTNUM;
  515. exit;
  516. end;
  517. else { octal number zero value...}
  518. Begin
  519. actasmpattern:=tostr(ValOctal(actasmpattern));
  520. actasmtoken:=AS_INTNUM;
  521. exit;
  522. end;
  523. end; { end case }
  524. end;
  525. '&' :
  526. begin
  527. c:=current_scanner^.asmgetchar;
  528. actasmtoken:=AS_AND;
  529. end;
  530. '''' : { char }
  531. begin
  532. actasmpattern:='';
  533. repeat
  534. c:=current_scanner^.asmgetchar;
  535. case c of
  536. '\' :
  537. begin
  538. { copy also the next char so \" is parsed correctly }
  539. c:=current_scanner^.asmgetchar;
  540. actasmpattern:=actasmpattern+c;
  541. end;
  542. '''' :
  543. begin
  544. c:=current_scanner^.asmgetchar;
  545. break;
  546. end;
  547. newline:
  548. Message(scan_f_string_exceeds_line);
  549. else
  550. actasmpattern:=actasmpattern+c;
  551. end;
  552. until false;
  553. actasmpattern:=EscapeToPascal(actasmpattern);
  554. actasmtoken:=AS_STRING;
  555. exit;
  556. end;
  557. '"' : { string }
  558. begin
  559. actasmpattern:='';
  560. repeat
  561. c:=current_scanner^.asmgetchar;
  562. case c of
  563. '\' :
  564. begin
  565. { copy also the next char so \" is parsed correctly }
  566. c:=current_scanner^.asmgetchar;
  567. actasmpattern:=actasmpattern+c;
  568. end;
  569. '"' :
  570. begin
  571. c:=current_scanner^.asmgetchar;
  572. break;
  573. end;
  574. newline:
  575. Message(scan_f_string_exceeds_line);
  576. else
  577. actasmpattern:=actasmpattern+c;
  578. end;
  579. until false;
  580. actasmpattern:=EscapeToPascal(actasmpattern);
  581. actasmtoken:=AS_STRING;
  582. exit;
  583. end;
  584. '$' :
  585. begin
  586. actasmtoken:=AS_DOLLAR;
  587. c:=current_scanner^.asmgetchar;
  588. exit;
  589. end;
  590. ',' :
  591. begin
  592. actasmtoken:=AS_COMMA;
  593. c:=current_scanner^.asmgetchar;
  594. exit;
  595. end;
  596. '<' :
  597. begin
  598. actasmtoken:=AS_SHL;
  599. c:=current_scanner^.asmgetchar;
  600. if c = '<' then
  601. c:=current_scanner^.asmgetchar;
  602. exit;
  603. end;
  604. '>' :
  605. begin
  606. actasmtoken:=AS_SHL;
  607. c:=current_scanner^.asmgetchar;
  608. if c = '>' then
  609. c:=current_scanner^.asmgetchar;
  610. exit;
  611. end;
  612. '|' :
  613. begin
  614. actasmtoken:=AS_OR;
  615. c:=current_scanner^.asmgetchar;
  616. exit;
  617. end;
  618. '^' :
  619. begin
  620. actasmtoken:=AS_XOR;
  621. c:=current_scanner^.asmgetchar;
  622. exit;
  623. end;
  624. '!' :
  625. begin
  626. Message(asmr_e_nor_not_supported);
  627. c:=current_scanner^.asmgetchar;
  628. actasmtoken:=AS_NONE;
  629. exit;
  630. end;
  631. '(' :
  632. begin
  633. actasmtoken:=AS_LPAREN;
  634. c:=current_scanner^.asmgetchar;
  635. exit;
  636. end;
  637. ')' :
  638. begin
  639. actasmtoken:=AS_RPAREN;
  640. c:=current_scanner^.asmgetchar;
  641. exit;
  642. end;
  643. ':' :
  644. begin
  645. actasmtoken:=AS_COLON;
  646. c:=current_scanner^.asmgetchar;
  647. exit;
  648. end;
  649. '+' :
  650. begin
  651. actasmtoken:=AS_PLUS;
  652. c:=current_scanner^.asmgetchar;
  653. exit;
  654. end;
  655. '-' :
  656. begin
  657. actasmtoken:=AS_MINUS;
  658. c:=current_scanner^.asmgetchar;
  659. exit;
  660. end;
  661. '*' :
  662. begin
  663. actasmtoken:=AS_STAR;
  664. c:=current_scanner^.asmgetchar;
  665. exit;
  666. end;
  667. '/' :
  668. begin
  669. c:=current_scanner^.asmgetchar;
  670. actasmtoken:=AS_SLASH;
  671. exit;
  672. end;
  673. '{',#13,newline,';' :
  674. begin
  675. { the comment is read by asmgetchar }
  676. c:=current_scanner^.asmgetchar;
  677. firsttoken:=TRUE;
  678. actasmtoken:=AS_SEPARATOR;
  679. exit;
  680. end;
  681. else
  682. current_scanner^.illegal_char(c);
  683. end;
  684. end;
  685. end;
  686. function consume(t : tasmtoken):boolean;
  687. begin
  688. Consume:=true;
  689. if t<>actasmtoken then
  690. begin
  691. Message2(scan_f_syn_expected,token2str[t],token2str[actasmtoken]);
  692. Consume:=false;
  693. end;
  694. repeat
  695. gettoken;
  696. until actasmtoken<>AS_NONE;
  697. end;
  698. procedure RecoverConsume(allowcomma:boolean);
  699. begin
  700. While not (actasmtoken in [AS_SEPARATOR,AS_END]) do
  701. begin
  702. if allowcomma and (actasmtoken=AS_COMMA) then
  703. break;
  704. Consume(actasmtoken);
  705. end;
  706. end;
  707. {*****************************************************************************
  708. Parsing Helpers
  709. *****************************************************************************}
  710. Procedure BuildRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
  711. { Description: This routine builds up a record offset after a AS_DOT }
  712. { token is encountered. }
  713. { On entry actasmtoken should be equal to AS_DOT }
  714. var
  715. s : string;
  716. Begin
  717. offset:=0;
  718. size:=0;
  719. s:=expr;
  720. while (actasmtoken=AS_DOT) do
  721. begin
  722. Consume(AS_DOT);
  723. if actasmtoken=AS_ID then
  724. s:=s+'.'+actasmpattern;
  725. if not Consume(AS_ID) then
  726. begin
  727. RecoverConsume(true);
  728. break;
  729. end;
  730. end;
  731. if not GetRecordOffsetSize(s,offset,size) then
  732. Message(asmr_e_building_record_offset);
  733. end;
  734. Procedure BuildConstSymbolExpression(allowref,betweenbracket,needofs:boolean;var value:longint;var asmsym:string);
  735. var
  736. hs,tempstr,expr : string;
  737. parenlevel,l,k : longint;
  738. errorflag : boolean;
  739. prevtok : tasmtoken;
  740. sym : psym;
  741. hl : PAsmLabel;
  742. Begin
  743. asmsym:='';
  744. value:=0;
  745. errorflag:=FALSE;
  746. tempstr:='';
  747. expr:='';
  748. parenlevel:=0;
  749. Repeat
  750. Case actasmtoken of
  751. AS_LPAREN:
  752. Begin
  753. { Exit if ref? }
  754. if allowref and (prevasmtoken in [AS_INTNUM,AS_ID]) then
  755. break;
  756. Consume(AS_LPAREN);
  757. expr:=expr + '(';
  758. inc(parenlevel);
  759. end;
  760. AS_RPAREN:
  761. Begin
  762. { end of ref ? }
  763. if (parenlevel=0) and betweenbracket then
  764. break;
  765. Consume(AS_RPAREN);
  766. expr:=expr + ')';
  767. dec(parenlevel);
  768. end;
  769. AS_SHL:
  770. Begin
  771. Consume(AS_SHL);
  772. expr:=expr + '<';
  773. end;
  774. AS_SHR:
  775. Begin
  776. Consume(AS_SHR);
  777. expr:=expr + '>';
  778. end;
  779. AS_SLASH:
  780. Begin
  781. Consume(AS_SLASH);
  782. expr:=expr + '/';
  783. end;
  784. AS_MOD:
  785. Begin
  786. Consume(AS_MOD);
  787. expr:=expr + '%';
  788. end;
  789. AS_STAR:
  790. Begin
  791. Consume(AS_STAR);
  792. expr:=expr + '*';
  793. end;
  794. AS_PLUS:
  795. Begin
  796. Consume(AS_PLUS);
  797. expr:=expr + '+';
  798. end;
  799. AS_MINUS:
  800. Begin
  801. Consume(AS_MINUS);
  802. expr:=expr + '-';
  803. end;
  804. AS_AND:
  805. Begin
  806. Consume(AS_AND);
  807. expr:=expr + '&';
  808. end;
  809. AS_NOT:
  810. Begin
  811. Consume(AS_NOT);
  812. expr:=expr + '~';
  813. end;
  814. AS_XOR:
  815. Begin
  816. Consume(AS_XOR);
  817. expr:=expr + '^';
  818. end;
  819. AS_OR:
  820. Begin
  821. Consume(AS_OR);
  822. expr:=expr + '|';
  823. end;
  824. AS_INTNUM:
  825. Begin
  826. expr:=expr + actasmpattern;
  827. Consume(AS_INTNUM);
  828. end;
  829. AS_DOLLAR:
  830. begin
  831. Consume(AS_DOLLAR);
  832. if actasmtoken<>AS_ID then
  833. Message(asmr_e_dollar_without_identifier);
  834. end;
  835. AS_STRING:
  836. Begin
  837. l:=0;
  838. case Length(actasmpattern) of
  839. 1 :
  840. l:=ord(actasmpattern[1]);
  841. 2 :
  842. l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
  843. 3 :
  844. l:=ord(actasmpattern[3]) +
  845. Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
  846. 4 :
  847. l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
  848. Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
  849. else
  850. Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
  851. end;
  852. str(l, tempstr);
  853. expr:=expr + tempstr;
  854. Consume(AS_STRING);
  855. end;
  856. AS_TYPE:
  857. begin
  858. l:=0;
  859. Consume(AS_TYPE);
  860. if actasmtoken<>AS_ID then
  861. Message(asmr_e_type_without_identifier)
  862. else
  863. begin
  864. tempstr:=actasmpattern;
  865. Consume(AS_ID);
  866. if actasmtoken=AS_DOT then
  867. BuildRecordOffsetSize(tempstr,k,l)
  868. else
  869. begin
  870. getsym(tempstr,false);
  871. if assigned(srsym) then
  872. begin
  873. case srsym^.typ of
  874. varsym :
  875. l:=pvarsym(srsym)^.getsize;
  876. typedconstsym :
  877. l:=ptypedconstsym(srsym)^.getsize;
  878. typesym :
  879. l:=ptypesym(srsym)^.restype.def^.size;
  880. else
  881. Message(asmr_e_wrong_sym_type);
  882. end;
  883. end
  884. else
  885. Message1(sym_e_unknown_id,tempstr);
  886. end;
  887. end;
  888. str(l, tempstr);
  889. expr:=expr + tempstr;
  890. end;
  891. AS_ID:
  892. Begin
  893. hs:='';
  894. tempstr:=actasmpattern;
  895. prevtok:=prevasmtoken;
  896. consume(AS_ID);
  897. if SearchIConstant(tempstr,l) then
  898. begin
  899. str(l, tempstr);
  900. expr:=expr + tempstr;
  901. end
  902. else
  903. begin
  904. if is_locallabel(tempstr) then
  905. begin
  906. CreateLocalLabel(tempstr,hl,false);
  907. hs:=hl^.name
  908. end
  909. else
  910. if SearchLabel(tempstr,hl,false) then
  911. hs:=hl^.name
  912. else
  913. begin
  914. getsym(tempstr,false);
  915. sym:=srsym;
  916. if assigned(sym) then
  917. begin
  918. case srsym^.typ of
  919. varsym :
  920. begin
  921. if sym^.owner^.symtabletype in [localsymtable,parasymtable] then
  922. Message(asmr_e_no_local_or_para_allowed);
  923. hs:=pvarsym(srsym)^.mangledname;
  924. end;
  925. typedconstsym :
  926. hs:=ptypedconstsym(srsym)^.mangledname;
  927. procsym :
  928. hs:=pprocsym(srsym)^.mangledname;
  929. else
  930. Message(asmr_e_wrong_sym_type);
  931. end;
  932. end
  933. else
  934. Message1(sym_e_unknown_id,tempstr);
  935. end;
  936. { symbol found? }
  937. if hs<>'' then
  938. begin
  939. if needofs and (prevtok<>AS_DOLLAR) then
  940. Message(asmr_e_need_dollar);
  941. if asmsym='' then
  942. asmsym:=hs
  943. else
  944. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  945. if (expr='') or (expr[length(expr)]='+') then
  946. begin
  947. { don't remove the + if there could be a record field }
  948. if actasmtoken<>AS_DOT then
  949. delete(expr,length(expr),1);
  950. end
  951. else
  952. Message(asmr_e_only_add_relocatable_symbol);
  953. end;
  954. if actasmtoken=AS_DOT then
  955. begin
  956. BuildRecordOffsetSize(tempstr,l,k);
  957. str(l, tempstr);
  958. expr:=expr + tempstr;
  959. end
  960. else
  961. begin
  962. if (expr='') or (expr[length(expr)] in ['+','-','/','*']) then
  963. delete(expr,length(expr),1);
  964. end;
  965. end;
  966. { check if there are wrong operator used like / or mod etc. }
  967. if (hs<>'') and not(actasmtoken in [AS_MINUS,AS_PLUS,AS_COMMA,AS_SEPARATOR,AS_LPAREN,AS_END]) then
  968. Message(asmr_e_only_add_relocatable_symbol);
  969. end;
  970. AS_END,
  971. AS_SEPARATOR,
  972. AS_COMMA:
  973. Begin
  974. break;
  975. end;
  976. else
  977. Begin
  978. { write error only once. }
  979. if not errorflag then
  980. Message(asmr_e_invalid_constant_expression);
  981. { consume tokens until we find COMMA or SEPARATOR }
  982. Consume(actasmtoken);
  983. errorflag:=TRUE;
  984. end;
  985. end;
  986. Until false;
  987. { calculate expression }
  988. if not ErrorFlag then
  989. value:=CalculateExpression(expr)
  990. else
  991. value:=0;
  992. end;
  993. Function BuildConstExpression(allowref,betweenbracket:boolean): longint;
  994. var
  995. l : longint;
  996. hs : string;
  997. begin
  998. BuildConstSymbolExpression(allowref,betweenbracket,false,l,hs);
  999. if hs<>'' then
  1000. Message(asmr_e_relocatable_symbol_not_allowed);
  1001. BuildConstExpression:=l;
  1002. end;
  1003. {****************************************************************************
  1004. T386ATTOperand
  1005. ****************************************************************************}
  1006. type
  1007. P386ATTOperand=^T386ATTOperand;
  1008. T386ATTOperand=object(T386Operand)
  1009. Procedure BuildOperand;virtual;
  1010. private
  1011. Procedure BuildReference;
  1012. Procedure BuildConstant;
  1013. end;
  1014. Procedure T386ATTOperand.BuildReference;
  1015. procedure Consume_RParen;
  1016. begin
  1017. if actasmtoken <> AS_RPAREN then
  1018. Begin
  1019. Message(asmr_e_invalid_reference_syntax);
  1020. RecoverConsume(true);
  1021. end
  1022. else
  1023. begin
  1024. Consume(AS_RPAREN);
  1025. if not (actasmtoken in [AS_COMMA,AS_SEPARATOR,AS_END]) then
  1026. Begin
  1027. Message(asmr_e_invalid_reference_syntax);
  1028. RecoverConsume(true);
  1029. end;
  1030. end;
  1031. end;
  1032. procedure Consume_Scale;
  1033. var
  1034. l : longint;
  1035. begin
  1036. { we have to process the scaling }
  1037. l:=BuildConstExpression(false,true);
  1038. if ((l = 2) or (l = 4) or (l = 8) or (l = 1)) then
  1039. opr.ref.scalefactor:=l
  1040. else
  1041. Begin
  1042. Message(asmr_e_wrong_scale_factor);
  1043. opr.ref.scalefactor:=0;
  1044. end;
  1045. end;
  1046. Begin
  1047. Consume(AS_LPAREN);
  1048. Case actasmtoken of
  1049. AS_INTNUM,
  1050. AS_MINUS,
  1051. AS_PLUS: { absolute offset, such as fs:(0x046c) }
  1052. Begin
  1053. { offset(offset) is invalid }
  1054. If opr.Ref.Offset <> 0 Then
  1055. Begin
  1056. Message(asmr_e_invalid_reference_syntax);
  1057. RecoverConsume(true);
  1058. End
  1059. Else
  1060. Begin
  1061. opr.Ref.Offset:=BuildConstExpression(false,true);
  1062. Consume_RParen;
  1063. end;
  1064. exit;
  1065. End;
  1066. AS_REGISTER: { (reg ... }
  1067. Begin
  1068. { Check if there is already a base (mostly ebp,esp) than this is
  1069. not allowed,becuase it will give crashing code }
  1070. if opr.ref.base<>R_NO then
  1071. Message(asmr_e_cannot_index_relative_var);
  1072. opr.ref.base:=actasmregister;
  1073. Consume(AS_REGISTER);
  1074. { can either be a register or a right parenthesis }
  1075. { (reg) }
  1076. if actasmtoken=AS_RPAREN then
  1077. Begin
  1078. Consume_RParen;
  1079. exit;
  1080. end;
  1081. { (reg,reg .. }
  1082. Consume(AS_COMMA);
  1083. if actasmtoken=AS_REGISTER then
  1084. Begin
  1085. opr.ref.index:=actasmregister;
  1086. Consume(AS_REGISTER);
  1087. { check for scaling ... }
  1088. case actasmtoken of
  1089. AS_RPAREN:
  1090. Begin
  1091. Consume_RParen;
  1092. exit;
  1093. end;
  1094. AS_COMMA:
  1095. Begin
  1096. Consume(AS_COMMA);
  1097. Consume_Scale;
  1098. Consume_RParen;
  1099. end;
  1100. else
  1101. Begin
  1102. Message(asmr_e_invalid_reference_syntax);
  1103. RecoverConsume(false);
  1104. end;
  1105. end; { end case }
  1106. end
  1107. else
  1108. Begin
  1109. Message(asmr_e_invalid_reference_syntax);
  1110. RecoverConsume(false);
  1111. end;
  1112. end; {end case }
  1113. AS_COMMA: { (, ... can either be scaling, or index }
  1114. Begin
  1115. Consume(AS_COMMA);
  1116. { Index }
  1117. if (actasmtoken=AS_REGISTER) then
  1118. Begin
  1119. opr.ref.index:=actasmregister;
  1120. Consume(AS_REGISTER);
  1121. { check for scaling ... }
  1122. case actasmtoken of
  1123. AS_RPAREN:
  1124. Begin
  1125. Consume_RParen;
  1126. exit;
  1127. end;
  1128. AS_COMMA:
  1129. Begin
  1130. Consume(AS_COMMA);
  1131. Consume_Scale;
  1132. Consume_RParen;
  1133. end;
  1134. else
  1135. Begin
  1136. Message(asmr_e_invalid_reference_syntax);
  1137. RecoverConsume(false);
  1138. end;
  1139. end; {end case }
  1140. end
  1141. { Scaling }
  1142. else
  1143. Begin
  1144. Consume_Scale;
  1145. Consume_RParen;
  1146. exit;
  1147. end;
  1148. end;
  1149. else
  1150. Begin
  1151. Message(asmr_e_invalid_reference_syntax);
  1152. RecoverConsume(false);
  1153. end;
  1154. end;
  1155. end;
  1156. Procedure T386ATTOperand.BuildConstant;
  1157. var
  1158. l : longint;
  1159. tempstr : string;
  1160. begin
  1161. BuildConstSymbolExpression(false,false,true,l,tempstr);
  1162. if tempstr<>'' then
  1163. begin
  1164. opr.typ:=OPR_SYMBOL;
  1165. opr.symofs:=l;
  1166. opr.symbol:=newasmsymbol(tempstr);
  1167. end
  1168. else
  1169. begin
  1170. opr.typ:=OPR_CONSTANT;
  1171. opr.val:=l;
  1172. end;
  1173. end;
  1174. Procedure T386ATTOperand.BuildOperand;
  1175. var
  1176. tempstr,tempstr2,
  1177. expr : string;
  1178. l,k : longint;
  1179. procedure AddLabelOperand(hl:pasmlabel);
  1180. begin
  1181. if not(actasmtoken in [AS_PLUS,AS_MINUS,AS_LPAREN]) and
  1182. is_calljmp(actopcode) then
  1183. begin
  1184. opr.typ:=OPR_SYMBOL;
  1185. opr.symbol:=hl;
  1186. end
  1187. else
  1188. begin
  1189. InitRef;
  1190. opr.ref.symbol:=hl;
  1191. end;
  1192. end;
  1193. procedure MaybeRecordOffset;
  1194. var
  1195. hasdot : boolean;
  1196. l,
  1197. toffset,
  1198. tsize : longint;
  1199. begin
  1200. if not(actasmtoken in [AS_DOT,AS_PLUS,AS_MINUS]) then
  1201. exit;
  1202. l:=0;
  1203. hasdot:=(actasmtoken=AS_DOT);
  1204. if hasdot then
  1205. begin
  1206. if expr<>'' then
  1207. begin
  1208. BuildRecordOffsetSize(expr,toffset,tsize);
  1209. inc(l,toffset);
  1210. SetSize(tsize,true);
  1211. end;
  1212. end;
  1213. if actasmtoken in [AS_PLUS,AS_MINUS] then
  1214. inc(l,BuildConstExpression(true,false));
  1215. if opr.typ=OPR_REFERENCE then
  1216. begin
  1217. if hasdot and (not hastype) and (opr.ref.options=ref_parafixup) then
  1218. Message(asmr_e_cannot_access_field_directly_for_parameters);
  1219. inc(opr.ref.offset,l)
  1220. end
  1221. else
  1222. inc(opr.val,l);
  1223. end;
  1224. function MaybeBuildReference:boolean;
  1225. { Try to create a reference, if not a reference is found then false
  1226. is returned }
  1227. begin
  1228. MaybeBuildReference:=true;
  1229. case actasmtoken of
  1230. AS_INTNUM,
  1231. AS_MINUS,
  1232. AS_PLUS:
  1233. Begin
  1234. opr.ref.offset:=BuildConstExpression(True,False);
  1235. if actasmtoken<>AS_LPAREN then
  1236. Message(asmr_e_invalid_reference_syntax)
  1237. else
  1238. BuildReference;
  1239. end;
  1240. AS_LPAREN:
  1241. BuildReference;
  1242. AS_ID: { only a variable is allowed ... }
  1243. Begin
  1244. tempstr:=actasmpattern;
  1245. Consume(AS_ID);
  1246. { typecasting? }
  1247. if (actasmtoken=AS_LPAREN) and
  1248. SearchType(tempstr) then
  1249. begin
  1250. hastype:=true;
  1251. Consume(AS_LPAREN);
  1252. tempstr2:=actasmpattern;
  1253. Consume(AS_ID);
  1254. Consume(AS_RPAREN);
  1255. if not SetupVar(tempstr2,false) then
  1256. Message1(sym_e_unknown_id,tempstr2);
  1257. end
  1258. else
  1259. if not SetupVar(tempstr,false) then
  1260. Message1(sym_e_unknown_id,tempstr);
  1261. { record.field ? }
  1262. if actasmtoken=AS_DOT then
  1263. begin
  1264. BuildRecordOffsetSize(tempstr,l,k);
  1265. inc(opr.ref.offset,l);
  1266. end;
  1267. case actasmtoken of
  1268. AS_END,
  1269. AS_SEPARATOR,
  1270. AS_COMMA: ;
  1271. AS_LPAREN: BuildReference;
  1272. else
  1273. Begin
  1274. Message(asmr_e_invalid_reference_syntax);
  1275. Consume(actasmtoken);
  1276. end;
  1277. end; {end case }
  1278. end;
  1279. else
  1280. MaybeBuildReference:=false;
  1281. end; { end case }
  1282. end;
  1283. var
  1284. tempreg : tregister;
  1285. hl : PAsmLabel;
  1286. Begin
  1287. expr:='';
  1288. case actasmtoken of
  1289. AS_LPAREN: { Memory reference or constant expression }
  1290. Begin
  1291. InitRef;
  1292. BuildReference;
  1293. end;
  1294. AS_DOLLAR: { Constant expression }
  1295. Begin
  1296. Consume(AS_DOLLAR);
  1297. BuildConstant;
  1298. end;
  1299. AS_INTNUM,
  1300. AS_MINUS,
  1301. AS_PLUS:
  1302. Begin
  1303. { Constant memory offset }
  1304. { This must absolutely be followed by ( }
  1305. InitRef;
  1306. opr.ref.offset:=BuildConstExpression(True,False);
  1307. if actasmtoken<>AS_LPAREN then
  1308. Message(asmr_e_invalid_reference_syntax)
  1309. else
  1310. BuildReference;
  1311. end;
  1312. AS_STAR: { Call from memory address }
  1313. Begin
  1314. Consume(AS_STAR);
  1315. if actasmtoken=AS_REGISTER then
  1316. begin
  1317. opr.typ:=OPR_REGISTER;
  1318. opr.reg:=actasmregister;
  1319. size:=reg_2_opsize[actasmregister];
  1320. Consume(AS_REGISTER);
  1321. end
  1322. else
  1323. begin
  1324. InitRef;
  1325. if not MaybeBuildReference then
  1326. Message(asmr_e_syn_operand);
  1327. end;
  1328. { this is only allowed for call's and jmp's }
  1329. if not is_calljmp(actopcode) then
  1330. Message(asmr_e_syn_operand);
  1331. end;
  1332. AS_ID: { A constant expression, or a Variable ref. }
  1333. Begin
  1334. { Local Label ? }
  1335. if is_locallabel(actasmpattern) then
  1336. begin
  1337. CreateLocalLabel(actasmpattern,hl,false);
  1338. Consume(AS_ID);
  1339. AddLabelOperand(hl);
  1340. end
  1341. else
  1342. { Check for label }
  1343. if SearchLabel(actasmpattern,hl,false) then
  1344. begin
  1345. Consume(AS_ID);
  1346. AddLabelOperand(hl);
  1347. end
  1348. else
  1349. { probably a variable or normal expression }
  1350. { or a procedure (such as in CALL ID) }
  1351. Begin
  1352. { is it a constant ? }
  1353. if SearchIConstant(actasmpattern,l) then
  1354. Begin
  1355. if not (opr.typ in [OPR_NONE,OPR_CONSTANT]) then
  1356. Message(asmr_e_invalid_operand_type);
  1357. BuildConstant;
  1358. end
  1359. else
  1360. begin
  1361. InitRef;
  1362. expr:=actasmpattern;
  1363. Consume(AS_ID);
  1364. { typecasting? }
  1365. if (actasmtoken=AS_LPAREN) and
  1366. SearchType(expr) then
  1367. begin
  1368. hastype:=true;
  1369. Consume(AS_LPAREN);
  1370. tempstr:=actasmpattern;
  1371. Consume(AS_ID);
  1372. Consume(AS_RPAREN);
  1373. if SetupVar(tempstr,false) then
  1374. begin
  1375. MaybeRecordOffset;
  1376. { add a constant expression? }
  1377. if (actasmtoken=AS_PLUS) then
  1378. begin
  1379. l:=BuildConstExpression(true,false);
  1380. if opr.typ=OPR_CONSTANT then
  1381. inc(opr.val,l)
  1382. else
  1383. inc(opr.ref.offset,l);
  1384. end
  1385. end
  1386. else
  1387. Message1(sym_e_unknown_id,tempstr);
  1388. end
  1389. else
  1390. begin
  1391. if SetupVar(expr,false) then
  1392. begin
  1393. MaybeRecordOffset;
  1394. { add a constant expression? }
  1395. if (actasmtoken=AS_PLUS) then
  1396. begin
  1397. l:=BuildConstExpression(true,false);
  1398. if opr.typ=OPR_CONSTANT then
  1399. inc(opr.val,l)
  1400. else
  1401. inc(opr.ref.offset,l);
  1402. end
  1403. end
  1404. else
  1405. Begin
  1406. { look for special symbols ... }
  1407. if expr = '__RESULT' then
  1408. SetUpResult
  1409. else
  1410. if expr = '__SELF' then
  1411. SetupSelf
  1412. else
  1413. if expr = '__OLDEBP' then
  1414. SetupOldEBP
  1415. else
  1416. { check for direct symbolic names }
  1417. { only if compiling the system unit }
  1418. if (cs_compilesystem in aktmoduleswitches) then
  1419. begin
  1420. if not SetupDirectVar(expr) then
  1421. Begin
  1422. { not found, finally ... add it anyways ... }
  1423. Message1(asmr_w_id_supposed_external,expr);
  1424. opr.ref.symbol:=newasmsymbol(expr);
  1425. end;
  1426. end
  1427. else
  1428. Message1(sym_e_unknown_id,expr);
  1429. end;
  1430. end;
  1431. end;
  1432. end;
  1433. { Do we have a indexing reference, then parse it also }
  1434. if actasmtoken=AS_LPAREN then
  1435. begin
  1436. if (opr.typ=OPR_CONSTANT) then
  1437. begin
  1438. l:=opr.val;
  1439. opr.typ:=OPR_REFERENCE;
  1440. reset_reference(opr.Ref);
  1441. opr.Ref.Offset:=l;
  1442. end;
  1443. BuildReference;
  1444. end;
  1445. end;
  1446. AS_REGISTER: { Register, a variable reference or a constant reference }
  1447. Begin
  1448. { save the type of register used. }
  1449. tempreg:=actasmregister;
  1450. Consume(AS_REGISTER);
  1451. if actasmtoken = AS_COLON then
  1452. Begin
  1453. Consume(AS_COLON);
  1454. InitRef;
  1455. opr.ref.segment:=tempreg;
  1456. { This must absolutely be followed by a reference }
  1457. if not MaybeBuildReference then
  1458. Begin
  1459. Message(asmr_e_invalid_seg_override);
  1460. Consume(actasmtoken);
  1461. end;
  1462. end
  1463. { Simple register }
  1464. else if (actasmtoken in [AS_END,AS_SEPARATOR,AS_COMMA]) then
  1465. Begin
  1466. if not (opr.typ in [OPR_NONE,OPR_REGISTER]) then
  1467. Message(asmr_e_invalid_operand_type);
  1468. opr.typ:=OPR_REGISTER;
  1469. opr.reg:=tempreg;
  1470. size:=reg_2_opsize[tempreg];
  1471. end
  1472. else
  1473. Message(asmr_e_syn_operand);
  1474. end;
  1475. AS_END,
  1476. AS_SEPARATOR,
  1477. AS_COMMA: ;
  1478. else
  1479. Begin
  1480. Message(asmr_e_syn_operand);
  1481. Consume(actasmtoken);
  1482. end;
  1483. end; { end case }
  1484. end;
  1485. {*****************************************************************************
  1486. T386ATTInstruction
  1487. *****************************************************************************}
  1488. type
  1489. P386AttInstruction=^T386AttInstruction;
  1490. T386AttInstruction=object(T386Instruction)
  1491. procedure InitOperands;virtual;
  1492. procedure BuildOpcode;virtual;
  1493. end;
  1494. procedure T386AttInstruction.InitOperands;
  1495. var
  1496. i : longint;
  1497. begin
  1498. for i:=1to 3 do
  1499. Operands[i]:=new(P386AttOperand,Init);
  1500. end;
  1501. Procedure T386AttInstruction.BuildOpCode;
  1502. var
  1503. operandnum : longint;
  1504. PrefixOp,OverrideOp: tasmop;
  1505. Begin
  1506. PrefixOp:=A_None;
  1507. OverrideOp:=A_None;
  1508. { prefix seg opcode / prefix opcode }
  1509. repeat
  1510. if is_prefix(actopcode) then
  1511. begin
  1512. PrefixOp:=ActOpcode;
  1513. opcode:=ActOpcode;
  1514. condition:=ActCondition;
  1515. opsize:=ActOpsize;
  1516. ConcatInstruction(curlist);
  1517. Consume(AS_OPCODE);
  1518. end
  1519. else
  1520. if is_override(actopcode) then
  1521. begin
  1522. OverrideOp:=ActOpcode;
  1523. opcode:=ActOpcode;
  1524. condition:=ActCondition;
  1525. opsize:=ActOpsize;
  1526. ConcatInstruction(curlist);
  1527. Consume(AS_OPCODE);
  1528. end
  1529. else
  1530. break;
  1531. { allow for newline as in gas styled syntax }
  1532. while actasmtoken=AS_SEPARATOR do
  1533. Consume(AS_SEPARATOR);
  1534. until (actasmtoken<>AS_OPCODE);
  1535. { opcode }
  1536. if (actasmtoken <> AS_OPCODE) then
  1537. Begin
  1538. Message(asmr_e_invalid_or_missing_opcode);
  1539. RecoverConsume(true);
  1540. exit;
  1541. end;
  1542. { Fill the instr object with the current state }
  1543. Opcode:=ActOpcode;
  1544. condition:=ActCondition;
  1545. opsize:=ActOpsize;
  1546. { Valid combination of prefix/override and instruction ? }
  1547. if (prefixop<>A_NONE) and (NOT CheckPrefix(PrefixOp,actopcode)) then
  1548. Message1(asmr_e_invalid_prefix_and_opcode,actasmpattern);
  1549. if (overrideop<>A_NONE) and (NOT CheckOverride(OverrideOp,ActOpcode)) then
  1550. Message1(asmr_e_invalid_override_and_opcode,actasmpattern);
  1551. { We are reading operands, so opcode will be an AS_ID }
  1552. operandnum:=1;
  1553. Consume(AS_OPCODE);
  1554. { Zero operand opcode ? }
  1555. if actasmtoken in [AS_SEPARATOR,AS_END] then
  1556. begin
  1557. operandnum:=0;
  1558. exit;
  1559. end;
  1560. { Read the operands }
  1561. repeat
  1562. case actasmtoken of
  1563. AS_COMMA: { Operand delimiter }
  1564. Begin
  1565. if operandnum > MaxOperands then
  1566. Message(asmr_e_too_many_operands)
  1567. else
  1568. Inc(operandnum);
  1569. Consume(AS_COMMA);
  1570. end;
  1571. AS_SEPARATOR,
  1572. AS_END : { End of asm operands for this opcode }
  1573. begin
  1574. break;
  1575. end;
  1576. else
  1577. Operands[operandnum]^.BuildOperand;
  1578. end; { end case }
  1579. until false;
  1580. Ops:=operandnum;
  1581. end;
  1582. Procedure BuildConstant(maxvalue: longint);
  1583. var
  1584. asmsym,
  1585. expr: string;
  1586. value : longint;
  1587. Begin
  1588. Repeat
  1589. Case actasmtoken of
  1590. AS_STRING:
  1591. Begin
  1592. expr:=actasmpattern;
  1593. if length(expr) > 1 then
  1594. Message(asmr_e_string_not_allowed_as_const);
  1595. Consume(AS_STRING);
  1596. Case actasmtoken of
  1597. AS_COMMA: Consume(AS_COMMA);
  1598. AS_END,
  1599. AS_SEPARATOR: ;
  1600. else
  1601. Message(asmr_e_invalid_string_expression);
  1602. end; { end case }
  1603. ConcatString(curlist,expr);
  1604. end;
  1605. AS_INTNUM,
  1606. AS_PLUS,
  1607. AS_MINUS,
  1608. AS_LPAREN,
  1609. AS_NOT,
  1610. AS_ID :
  1611. Begin
  1612. BuildConstSymbolExpression(false,false,false,value,asmsym);
  1613. if asmsym<>'' then
  1614. begin
  1615. if maxvalue<>longint($ffffffff) then
  1616. Message(asmr_w_32bit_const_for_address);
  1617. ConcatConstSymbol(curlist,asmsym,value)
  1618. end
  1619. else
  1620. ConcatConstant(curlist,value,maxvalue);
  1621. end;
  1622. AS_COMMA:
  1623. Consume(AS_COMMA);
  1624. AS_END,
  1625. AS_SEPARATOR:
  1626. break;
  1627. else
  1628. begin
  1629. Message(asmr_e_syn_constant);
  1630. RecoverConsume(false);
  1631. end
  1632. end; { end case }
  1633. Until false;
  1634. end;
  1635. Procedure BuildRealConstant(typ : tfloattype);
  1636. var
  1637. expr : string;
  1638. r : bestreal;
  1639. code : integer;
  1640. negativ : boolean;
  1641. errorflag: boolean;
  1642. Begin
  1643. errorflag:=FALSE;
  1644. Repeat
  1645. negativ:=false;
  1646. expr:='';
  1647. if actasmtoken=AS_PLUS then
  1648. Consume(AS_PLUS)
  1649. else
  1650. if actasmtoken=AS_MINUS then
  1651. begin
  1652. negativ:=true;
  1653. consume(AS_MINUS);
  1654. end;
  1655. Case actasmtoken of
  1656. AS_INTNUM:
  1657. Begin
  1658. expr:=actasmpattern;
  1659. Consume(AS_INTNUM);
  1660. if negativ then
  1661. expr:='-'+expr;
  1662. val(expr,r,code);
  1663. if code<>0 then
  1664. Begin
  1665. r:=0;
  1666. Message(asmr_e_invalid_float_expr);
  1667. End;
  1668. ConcatRealConstant(curlist,r,typ);
  1669. end;
  1670. AS_REALNUM:
  1671. Begin
  1672. expr:=actasmpattern;
  1673. Consume(AS_REALNUM);
  1674. { in ATT syntax you have 0d in front of the real }
  1675. { should this be forced ? yes i think so, as to }
  1676. { conform to gas as much as possible. }
  1677. if (expr[1]='0') and (upper(expr[2])='D') then
  1678. Delete(expr,1,2);
  1679. if negativ then
  1680. expr:='-'+expr;
  1681. val(expr,r,code);
  1682. if code<>0 then
  1683. Begin
  1684. r:=0;
  1685. Message(asmr_e_invalid_float_expr);
  1686. End;
  1687. ConcatRealConstant(curlist,r,typ);
  1688. end;
  1689. AS_COMMA:
  1690. begin
  1691. Consume(AS_COMMA);
  1692. end;
  1693. AS_END,
  1694. AS_SEPARATOR:
  1695. begin
  1696. break;
  1697. end;
  1698. else
  1699. Begin
  1700. Consume(actasmtoken);
  1701. if not errorflag then
  1702. Message(asmr_e_invalid_float_expr);
  1703. errorflag:=TRUE;
  1704. end;
  1705. end;
  1706. Until false;
  1707. end;
  1708. Procedure BuildStringConstant(asciiz: boolean);
  1709. var
  1710. expr: string;
  1711. errorflag : boolean;
  1712. Begin
  1713. errorflag:=FALSE;
  1714. Repeat
  1715. Case actasmtoken of
  1716. AS_STRING:
  1717. Begin
  1718. expr:=actasmpattern;
  1719. if asciiz then
  1720. expr:=expr+#0;
  1721. ConcatPasString(curlist,expr);
  1722. Consume(AS_STRING);
  1723. end;
  1724. AS_COMMA:
  1725. begin
  1726. Consume(AS_COMMA);
  1727. end;
  1728. AS_END,
  1729. AS_SEPARATOR:
  1730. begin
  1731. break;
  1732. end;
  1733. else
  1734. Begin
  1735. Consume(actasmtoken);
  1736. if not errorflag then
  1737. Message(asmr_e_invalid_string_expression);
  1738. errorflag:=TRUE;
  1739. end;
  1740. end;
  1741. Until false;
  1742. end;
  1743. Function Assemble: Ptree;
  1744. Var
  1745. hl : PAsmLabel;
  1746. commname : string;
  1747. lastsec : tsection;
  1748. l1,l2 : longint;
  1749. instr : T386ATTInstruction;
  1750. Begin
  1751. Message1(asmr_d_start_reading,'AT&T');
  1752. firsttoken:=TRUE;
  1753. if assigned(procinfo^.returntype.def) and
  1754. (is_fpu(procinfo^.returntype.def) or
  1755. ret_in_acc(procinfo^.returntype.def)) then
  1756. procinfo^.funcret_state:=vs_assigned;
  1757. { sets up all opcode and register tables in uppercase }
  1758. if not _asmsorted then
  1759. Begin
  1760. SetupTables;
  1761. _asmsorted:=TRUE;
  1762. end;
  1763. curlist:=new(paasmoutput,init);
  1764. lastsec:=sec_code;
  1765. { setup label linked list }
  1766. new(LocalLabelList,Init);
  1767. { start tokenizer }
  1768. c:=current_scanner^.asmgetchar;
  1769. gettoken;
  1770. { main loop }
  1771. repeat
  1772. case actasmtoken of
  1773. AS_LLABEL:
  1774. Begin
  1775. if CreateLocalLabel(actasmpattern,hl,true) then
  1776. ConcatLabel(curlist,hl);
  1777. Consume(AS_LLABEL);
  1778. end;
  1779. AS_LABEL:
  1780. Begin
  1781. if SearchLabel(upper(actasmpattern),hl,true) then
  1782. ConcatLabel(curlist,hl)
  1783. else
  1784. Message1(asmr_e_unknown_label_identifier,actasmpattern);
  1785. Consume(AS_LABEL);
  1786. end;
  1787. AS_DW:
  1788. Begin
  1789. Consume(AS_DW);
  1790. BuildConstant($ffff);
  1791. end;
  1792. AS_DATA:
  1793. Begin
  1794. curlist^.Concat(new(pai_section,init(sec_data)));
  1795. lastsec:=sec_data;
  1796. Consume(AS_DATA);
  1797. end;
  1798. AS_TEXT:
  1799. Begin
  1800. curlist^.Concat(new(pai_section,init(sec_code)));
  1801. lastsec:=sec_code;
  1802. Consume(AS_TEXT);
  1803. end;
  1804. AS_DB:
  1805. Begin
  1806. Consume(AS_DB);
  1807. BuildConstant($ff);
  1808. end;
  1809. AS_DD:
  1810. Begin
  1811. Consume(AS_DD);
  1812. BuildConstant($ffffffff);
  1813. end;
  1814. AS_DQ:
  1815. Begin
  1816. Consume(AS_DQ);
  1817. BuildRealConstant(s64comp);
  1818. end;
  1819. AS_SINGLE:
  1820. Begin
  1821. Consume(AS_SINGLE);
  1822. BuildRealConstant(s32real);
  1823. end;
  1824. AS_DOUBLE:
  1825. Begin
  1826. Consume(AS_DOUBLE);
  1827. BuildRealConstant(s64real);
  1828. end;
  1829. AS_EXTENDED:
  1830. Begin
  1831. Consume(AS_EXTENDED);
  1832. BuildRealConstant(s80real);
  1833. end;
  1834. AS_GLOBAL:
  1835. Begin
  1836. Consume(AS_GLOBAL);
  1837. if actasmtoken=AS_ID then
  1838. ConcatPublic(curlist,actasmpattern);
  1839. Consume(AS_ID);
  1840. if actasmtoken<>AS_SEPARATOR then
  1841. Consume(AS_SEPARATOR);
  1842. end;
  1843. AS_ALIGN:
  1844. Begin
  1845. Consume(AS_ALIGN);
  1846. l1:=BuildConstExpression(false,false);
  1847. if (target_info.target in [target_i386_GO32V1,target_i386_GO32V2]) then
  1848. begin
  1849. l2:=1;
  1850. if (l1>=0) and (l1<=16) then
  1851. while (l1>0) do
  1852. begin
  1853. l2:=2*l2;
  1854. dec(l1);
  1855. end;
  1856. l1:=l2;
  1857. end;
  1858. ConcatAlign(curlist,l1);
  1859. Message(asmr_n_align_is_target_specific);
  1860. if actasmtoken<>AS_SEPARATOR then
  1861. Consume(AS_SEPARATOR);
  1862. end;
  1863. AS_BALIGN:
  1864. Begin
  1865. Consume(AS_BALIGN);
  1866. ConcatAlign(curlist,BuildConstExpression(false,false));
  1867. if actasmtoken<>AS_SEPARATOR then
  1868. Consume(AS_SEPARATOR);
  1869. end;
  1870. AS_P2ALIGN:
  1871. Begin
  1872. Consume(AS_P2ALIGN);
  1873. l1:=BuildConstExpression(false,false);
  1874. l2:=1;
  1875. if (l1>=0) and (l1<=16) then
  1876. while (l1>0) do
  1877. begin
  1878. l2:=2*l2;
  1879. dec(l1);
  1880. end;
  1881. l1:=l2;
  1882. ConcatAlign(curlist,l1);
  1883. if actasmtoken<>AS_SEPARATOR then
  1884. Consume(AS_SEPARATOR);
  1885. end;
  1886. AS_ASCIIZ:
  1887. Begin
  1888. Consume(AS_ASCIIZ);
  1889. BuildStringConstant(TRUE);
  1890. end;
  1891. AS_ASCII:
  1892. Begin
  1893. Consume(AS_ASCII);
  1894. BuildStringConstant(FALSE);
  1895. end;
  1896. AS_LCOMM:
  1897. Begin
  1898. Consume(AS_LCOMM);
  1899. commname:=actasmpattern;
  1900. Consume(AS_ID);
  1901. Consume(AS_COMMA);
  1902. ConcatLocalBss(commname,BuildConstExpression(false,false));
  1903. if actasmtoken<>AS_SEPARATOR then
  1904. Consume(AS_SEPARATOR);
  1905. end;
  1906. AS_COMM:
  1907. Begin
  1908. Consume(AS_COMM);
  1909. commname:=actasmpattern;
  1910. Consume(AS_ID);
  1911. Consume(AS_COMMA);
  1912. ConcatGlobalBss(commname,BuildConstExpression(false,false));
  1913. if actasmtoken<>AS_SEPARATOR then
  1914. Consume(AS_SEPARATOR);
  1915. end;
  1916. AS_OPCODE:
  1917. Begin
  1918. instr.init;
  1919. instr.BuildOpcode;
  1920. instr.AddReferenceSizes;
  1921. instr.SetInstructionOpsize;
  1922. instr.CheckOperandSizes;
  1923. instr.ConcatInstruction(curlist);
  1924. instr.done;
  1925. end;
  1926. AS_SEPARATOR:
  1927. Begin
  1928. Consume(AS_SEPARATOR);
  1929. end;
  1930. AS_END:
  1931. begin
  1932. break; { end assembly block }
  1933. end;
  1934. else
  1935. Begin
  1936. Message(asmr_e_syntax_error);
  1937. RecoverConsume(false);
  1938. end;
  1939. end;
  1940. until false;
  1941. { Check LocalLabelList }
  1942. LocalLabelList^.CheckEmitted;
  1943. dispose(LocalLabelList,Done);
  1944. { are we back in the code section? }
  1945. if lastsec<>sec_code then
  1946. begin
  1947. Message(asmr_w_assembler_code_not_returned_to_text);
  1948. curlist^.Concat(new(pai_section,init(sec_code)));
  1949. end;
  1950. { Return the list in an asmnode }
  1951. assemble:=genasmnode(curlist);
  1952. Message1(asmr_d_finish_reading,'AT&T');
  1953. end;
  1954. {*****************************************************************************
  1955. Initialize
  1956. *****************************************************************************}
  1957. var
  1958. old_exit : pointer;
  1959. procedure ra386att_exit;{$ifndef FPC}far;{$endif}
  1960. begin
  1961. if assigned(iasmops) then
  1962. dispose(iasmops,done);
  1963. if assigned(iasmregs) then
  1964. dispose(iasmregs);
  1965. exitproc:=old_exit;
  1966. end;
  1967. begin
  1968. old_exit:=exitproc;
  1969. exitproc:=@ra386att_exit;
  1970. end.
  1971. {
  1972. $Log$
  1973. Revision 1.84 2000-06-18 18:07:06 peter
  1974. * use new illegal_char method
  1975. Revision 1.83 2000/06/15 18:07:07 peter
  1976. * fix constant parsing which gave an error when constants were used
  1977. Revision 1.82 2000/06/14 19:02:41 peter
  1978. * fixed TYPE with records and fields
  1979. * added TYPE support for ATT reader else it wouldn't be possible to
  1980. get the size of a type/variable
  1981. Revision 1.81 2000/05/26 18:23:11 peter
  1982. * fixed % parsing and added modulo support
  1983. * changed some evaulator errors to more generic illegal expresion
  1984. Revision 1.80 2000/05/23 20:36:28 peter
  1985. + typecasting support for variables, but be carefull as word,byte can't
  1986. be used because they are reserved assembler keywords
  1987. Revision 1.79 2000/05/18 17:05:16 peter
  1988. * fixed size of const parameters in asm readers
  1989. Revision 1.78 2000/05/12 21:57:02 pierre
  1990. + use of a dictionary object
  1991. for faster opcode searching in assembler readers
  1992. implemented by Kovacs Attila Zoltan
  1993. Revision 1.77 2000/05/11 09:56:21 pierre
  1994. * fixed several compare problems between longints and
  1995. const > $80000000 that are treated as int64 constanst
  1996. by Delphi reported by Kovacs Attila Zoltan
  1997. Revision 1.76 2000/05/09 11:56:25 pierre
  1998. * Issue an error if opcode is not found
  1999. Revision 1.75 2000/05/08 13:23:03 peter
  2000. * fixed reference parsing
  2001. Revision 1.74 2000/04/29 12:51:33 peter
  2002. * fixed offset support intel reader, the gotoffset variable was not
  2003. always reset
  2004. * moved check for local/para to be only used for varsym
  2005. Revision 1.73 2000/04/04 13:48:44 pierre
  2006. + TOperand.SetCorrectSize virtual method added
  2007. to be able to change the suffix according to the instruction
  2008. (FIADD word ptr w need a s as ATT suffix
  2009. wheras FILD word ptr w need a w suffix :( )
  2010. Revision 1.72 2000/03/15 23:10:01 pierre
  2011. * fix for bug 848 (that still genrated wrong code)
  2012. + better testing for variables used in assembler
  2013. (gives an error if variable is not directly reachable !)
  2014. Revision 1.71 2000/02/09 13:23:01 peter
  2015. * log truncated
  2016. Revision 1.70 2000/01/28 09:41:39 peter
  2017. * fixed fpu suffix parsing for att reader
  2018. Revision 1.69 2000/01/21 10:10:25 daniel
  2019. * should work on linux also
  2020. Revision 1.68 2000/01/21 00:46:47 peter
  2021. * ifdef'd my previous fix as it broken a make cycle sometimes
  2022. Revision 1.67 2000/01/20 23:35:01 peter
  2023. * fixed fldl where suffix would get S_L instead of S_FL
  2024. Revision 1.66 2000/01/07 01:14:34 peter
  2025. * updated copyright to 2000
  2026. Revision 1.65 1999/12/12 12:57:59 peter
  2027. * allow para+offset
  2028. Revision 1.64 1999/11/30 10:40:52 peter
  2029. + ttype, tsymlist
  2030. Revision 1.63 1999/11/17 17:05:03 pierre
  2031. * Notes/hints changes
  2032. Revision 1.62 1999/11/09 23:06:46 peter
  2033. * esi_offset -> selfpointer_offset to be newcg compatible
  2034. * hcogegen -> cgbase fixes for newcg
  2035. Revision 1.61 1999/11/06 14:34:23 peter
  2036. * truncated log to 20 revs
  2037. Revision 1.60 1999/10/01 07:59:20 peter
  2038. * fixed object field parsing
  2039. Revision 1.59 1999/09/27 23:44:57 peter
  2040. * procinfo is now a pointer
  2041. * support for result setting in sub procedure
  2042. Revision 1.58 1999/09/08 16:04:01 peter
  2043. * better support for object fields and more error checks for
  2044. field accesses which create buggy code
  2045. Revision 1.57 1999/08/05 16:53:08 peter
  2046. * V_Fatal=1, all other V_ are also increased
  2047. * Check for local procedure when assigning procvar
  2048. * fixed comment parsing because directives
  2049. * oldtp mode directives better supported
  2050. * added some messages to errore.msg
  2051. Revision 1.56 1999/08/04 00:23:25 florian
  2052. * renamed i386asm and i386base to cpuasm and cpubase
  2053. Revision 1.55 1999/08/03 22:03:09 peter
  2054. * moved bitmask constants to sets
  2055. * some other type/const renamings
  2056. Revision 1.54 1999/07/24 11:17:12 peter
  2057. * suffix parsing for at&t fixed for things like movsbl
  2058. * string constants are now handle correctly and also allowed in
  2059. constant expressions
  2060. }