ra386att.pas 58 KB

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