ra386att.pas 58 KB

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