raatt.pas 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Carl Eric Codere and Peter Vreman
  4. Does the parsing for the GAS 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 raatt;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cutils,cclasses,
  24. { global }
  25. globtype,
  26. { aasm }
  27. cpubase,cpuinfo,aasmbase,aasmtai,aasmcpu,
  28. { assembler reader }
  29. rabase,
  30. rasm,
  31. rautils,
  32. { symtable }
  33. symconst,
  34. { cg }
  35. cgbase,node;
  36. type
  37. tasmtoken = (
  38. AS_NONE,AS_LABEL,AS_LLABEL,AS_STRING,AS_INTNUM,
  39. AS_REALNUM,AS_COMMA,AS_LPAREN,
  40. AS_RPAREN,AS_COLON,AS_DOT,AS_PLUS,AS_MINUS,AS_STAR,
  41. AS_SEPARATOR,AS_ID,AS_REGISTER,AS_OPCODE,AS_SLASH,AS_DOLLAR,
  42. AS_HASH,AS_LSBRACKET,AS_RSBRACKET,AS_LBRACKET,AS_RBRACKET,
  43. {------------------ Assembler directives --------------------}
  44. AS_DB,AS_DW,AS_DD,AS_DQ,AS_GLOBAL,
  45. AS_ALIGN,AS_BALIGN,AS_P2ALIGN,AS_ASCII,
  46. AS_ASCIIZ,AS_LCOMM,AS_COMM,AS_SINGLE,AS_DOUBLE,AS_EXTENDED,
  47. AS_DATA,AS_TEXT,AS_END,
  48. {------------------ Assembler Operators --------------------}
  49. AS_TYPE,AS_MOD,AS_SHL,AS_SHR,AS_NOT,AS_AND,AS_OR,AS_XOR,AS_NOR,AS_AT);
  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. token2str : array[tasmtoken] of tasmkeyword=(
  57. '','Label','LLabel','string','integer',
  58. 'float',',','(',
  59. ')',':','.','+','-','*',
  60. ';','identifier','register','opcode','/','$',
  61. '#','{','}','[',']',
  62. '.byte','.word','.long','.quad','.globl',
  63. '.align','.balign','.p2align','.ascii',
  64. '.asciz','.lcomm','.comm','.single','.double','.tfloat',
  65. '.data','.text','END',
  66. 'TYPE','%','<<','>>','!','&','|','^','~','@');
  67. type
  68. tattreader = class(tasmreader)
  69. actasmtoken : tasmtoken;
  70. prevasmtoken : tasmtoken;
  71. procedure SetupTables;
  72. procedure BuildConstant(maxvalue: longint);
  73. procedure BuildConstantOperand(oper : toperand);
  74. procedure BuildRealConstant(typ : tfloattype);
  75. procedure BuildStringConstant(asciiz: boolean);
  76. procedure BuildRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
  77. procedure BuildConstSymbolExpression(allowref,betweenbracket,needofs:boolean;var value:longint;var asmsym:string);
  78. function BuildConstExpression(allowref,betweenbracket:boolean): longint;
  79. function Assemble: tlinkedlist;override;
  80. procedure handleopcode;virtual;abstract;
  81. function is_asmopcode(const s: string) : boolean;virtual;abstract;
  82. Function is_asmdirective(const s: string):boolean;
  83. function is_register(const s:string):boolean;virtual;
  84. function is_locallabel(const s: string):boolean;
  85. procedure GetToken;
  86. function consume(t : tasmtoken):boolean;
  87. procedure RecoverConsume(allowcomma:boolean);
  88. procedure handlepercent;virtual;
  89. end;
  90. tcattreader = class of tattreader;
  91. var
  92. cattreader : tcattreader;
  93. implementation
  94. uses
  95. { globals }
  96. verbose,systems,
  97. { input }
  98. scanner,
  99. { symtable }
  100. symbase,symtype,symsym,symtable,
  101. {$ifdef x86}
  102. rax86,
  103. {$endif x86}
  104. itcpugas;
  105. procedure tattreader.SetupTables;
  106. { creates uppercased symbol tables for speed access }
  107. var
  108. i : tasmop;
  109. str2opentry: tstr2opentry;
  110. Begin
  111. { opcodes }
  112. iasmops:=TDictionary.Create;
  113. iasmops.delete_doubles:=true;
  114. for i:=firstop to lastop do
  115. begin
  116. str2opentry:=tstr2opentry.createname(upper(gas_op2str[i]));
  117. str2opentry.op:=i;
  118. iasmops.insert(str2opentry);
  119. end;
  120. end;
  121. function tattreader.is_asmdirective(const s: string):boolean;
  122. var
  123. i : tasmtoken;
  124. hs : string;
  125. Begin
  126. { GNU as is also not casesensitive with this }
  127. hs:=lower(s);
  128. for i:=firstdirective to lastdirective do
  129. if hs=token2str[i] then
  130. begin
  131. actasmtoken:=i;
  132. is_asmdirective:=true;
  133. exit;
  134. end;
  135. is_asmdirective:=false;
  136. end;
  137. function tattreader.is_register(const s:string):boolean;
  138. begin
  139. is_register:=false;
  140. actasmregister:=gas_regnum_search(lower(s));
  141. if actasmregister<>NR_NO then
  142. begin
  143. is_register:=true;
  144. actasmtoken:=AS_REGISTER;
  145. end;
  146. end;
  147. function tattreader.is_locallabel(const s: string):boolean;
  148. begin
  149. is_locallabel:=(length(s)>=2) and (s[1]='.') and (s[2]='L');
  150. end;
  151. procedure tattreader.handlepercent;
  152. begin
  153. actasmtoken:=AS_MOD;
  154. end;
  155. procedure tattreader.GetToken;
  156. var
  157. len : longint;
  158. srsym : tsym;
  159. srsymtable : tsymtable;
  160. begin
  161. { save old token and reset new token }
  162. prevasmtoken:=actasmtoken;
  163. actasmtoken:=AS_NONE;
  164. { reset }
  165. actasmpattern:='';
  166. { while space and tab , continue scan... }
  167. while c in [' ',#9] do
  168. c:=current_scanner.asmgetchar;
  169. { get token pos }
  170. {$ifdef arm}
  171. if not (c in [#10,#13,';']) then
  172. current_scanner.gettokenpos;
  173. {$else arm}
  174. if not (c in [#10,#13,'{',';']) then
  175. current_scanner.gettokenpos;
  176. {$endif arm}
  177. { Local Label, Label, Directive, Prefix or Opcode }
  178. {$ifdef arm}
  179. if firsttoken and not(c in [#10,#13,';']) then
  180. {$else arm}
  181. if firsttoken and not(c in [#10,#13,'{',';']) then
  182. {$endif arm}
  183. begin
  184. firsttoken:=FALSE;
  185. len:=0;
  186. { directive or local label }
  187. if c = '.' then
  188. begin
  189. inc(len);
  190. actasmpattern[len]:=c;
  191. { Let us point to the next character }
  192. c:=current_scanner.asmgetchar;
  193. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  194. begin
  195. inc(len);
  196. actasmpattern[len]:=c;
  197. c:=current_scanner.asmgetchar;
  198. end;
  199. actasmpattern[0]:=chr(len);
  200. { this is a local label... }
  201. if (c=':') and is_locallabel(actasmpattern) then
  202. Begin
  203. { local variables are case sensitive }
  204. actasmtoken:=AS_LLABEL;
  205. c:=current_scanner.asmgetchar;
  206. firsttoken:=true;
  207. exit;
  208. end
  209. { must be a directive }
  210. else
  211. Begin
  212. { directives are case sensitive!! }
  213. if is_asmdirective(actasmpattern) then
  214. exit;
  215. Message1(asmr_e_not_directive_or_local_symbol,actasmpattern);
  216. end;
  217. end;
  218. { only opcodes and global labels are allowed now. }
  219. while c in ['A'..'Z','a'..'z','0'..'9','_'] do
  220. begin
  221. inc(len);
  222. actasmpattern[len]:=c;
  223. c:=current_scanner.asmgetchar;
  224. end;
  225. actasmpattern[0]:=chr(len);
  226. { Label ? }
  227. if c = ':' then
  228. begin
  229. actasmtoken:=AS_LABEL;
  230. { let us point to the next character }
  231. c:=current_scanner.asmgetchar;
  232. firsttoken:=true;
  233. exit;
  234. end;
  235. {$ifdef POWERPC}
  236. { some PowerPC instructions can have the postfix -, + or .
  237. this code could be moved to is_asmopcode but I think
  238. it's better to ifdef it here (FK)
  239. }
  240. case c of
  241. '.', '-', '+':
  242. begin
  243. actasmpattern:=actasmpattern+c;
  244. c:=current_scanner.asmgetchar;
  245. end
  246. end;
  247. {$endif POWERPC}
  248. { Opcode ? }
  249. If is_asmopcode(upper(actasmpattern)) then
  250. Begin
  251. uppervar(actasmpattern);
  252. exit;
  253. end;
  254. { End of assemblerblock ? }
  255. if upper(actasmpattern) = 'END' then
  256. begin
  257. actasmtoken:=AS_END;
  258. exit;
  259. end;
  260. message1(asmr_e_unknown_opcode,actasmpattern);
  261. actasmtoken:=AS_NONE;
  262. end
  263. else { else firsttoken }
  264. { Here we must handle all possible cases }
  265. begin
  266. case c of
  267. '.' : { possiblities : - local label reference , such as in jmp @local1 }
  268. { - field of object/record }
  269. { - directive. }
  270. begin
  271. if (prevasmtoken in [AS_ID,AS_RPAREN]) then
  272. begin
  273. c:=current_scanner.asmgetchar;
  274. actasmtoken:=AS_DOT;
  275. exit;
  276. end;
  277. actasmpattern:=c;
  278. c:=current_scanner.asmgetchar;
  279. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  280. begin
  281. actasmpattern:=actasmpattern + c;
  282. c:=current_scanner.asmgetchar;
  283. end;
  284. if is_asmdirective(actasmpattern) then
  285. exit;
  286. { local label references and directives }
  287. { are case sensitive }
  288. actasmtoken:=AS_ID;
  289. exit;
  290. end;
  291. { identifier, register, prefix or directive }
  292. '_','A'..'Z','a'..'z':
  293. begin
  294. len:=0;
  295. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  296. begin
  297. inc(len);
  298. actasmpattern[len]:=c;
  299. c:=current_scanner.asmgetchar;
  300. end;
  301. actasmpattern[0]:=chr(len);
  302. uppervar(actasmpattern);
  303. {$ifdef x86}
  304. { only x86 architectures have instruction prefixes }
  305. { Opcode, can only be when the previous was a prefix }
  306. If is_prefix(actopcode) and is_asmopcode(actasmpattern) then
  307. Begin
  308. uppervar(actasmpattern);
  309. exit;
  310. end;
  311. {$endif x86}
  312. { check for end which is a reserved word unlike the opcodes }
  313. if actasmpattern = 'END' then
  314. Begin
  315. actasmtoken:=AS_END;
  316. exit;
  317. end;
  318. if actasmpattern = 'TYPE' then
  319. Begin
  320. actasmtoken:=AS_TYPE;
  321. exit;
  322. end;
  323. if is_register(actasmpattern) then
  324. begin
  325. actasmtoken:=AS_REGISTER;
  326. exit;
  327. end;
  328. { if next is a '.' and this is a unitsym then we also need to
  329. parse the identifier }
  330. if (c='.') then
  331. begin
  332. searchsym(actasmpattern,srsym,srsymtable);
  333. if assigned(srsym) and
  334. (srsym.typ=unitsym) and
  335. (srsym.owner.unitid=0) then
  336. begin
  337. actasmpattern:=actasmpattern+c;
  338. c:=current_scanner.asmgetchar;
  339. while c in ['A'..'Z','a'..'z','0'..'9','_','$'] do
  340. begin
  341. actasmpattern:=actasmpattern + upcase(c);
  342. c:=current_scanner.asmgetchar;
  343. end;
  344. end;
  345. end;
  346. actasmtoken:=AS_ID;
  347. exit;
  348. end;
  349. '%' : { register or modulo }
  350. handlepercent;
  351. '1'..'9': { integer number }
  352. begin
  353. len:=0;
  354. while c in ['0'..'9'] do
  355. Begin
  356. inc(len);
  357. actasmpattern[len]:=c;
  358. c:=current_scanner.asmgetchar;
  359. end;
  360. actasmpattern[0]:=chr(len);
  361. actasmpattern:=tostr(ValDecimal(actasmpattern));
  362. actasmtoken:=AS_INTNUM;
  363. exit;
  364. end;
  365. '0' : { octal,hexa,real or binary number. }
  366. begin
  367. actasmpattern:=c;
  368. c:=current_scanner.asmgetchar;
  369. case upcase(c) of
  370. 'B': { binary }
  371. Begin
  372. c:=current_scanner.asmgetchar;
  373. while c in ['0','1'] do
  374. Begin
  375. actasmpattern:=actasmpattern + c;
  376. c:=current_scanner.asmgetchar;
  377. end;
  378. actasmpattern:=tostr(ValBinary(actasmpattern));
  379. actasmtoken:=AS_INTNUM;
  380. exit;
  381. end;
  382. 'D': { real }
  383. Begin
  384. c:=current_scanner.asmgetchar;
  385. { get ridd of the 0d }
  386. if (c in ['+','-']) then
  387. begin
  388. actasmpattern:=c;
  389. c:=current_scanner.asmgetchar;
  390. end
  391. else
  392. actasmpattern:='';
  393. while c in ['0'..'9'] do
  394. Begin
  395. actasmpattern:=actasmpattern + c;
  396. c:=current_scanner.asmgetchar;
  397. end;
  398. if c='.' then
  399. begin
  400. actasmpattern:=actasmpattern + c;
  401. c:=current_scanner.asmgetchar;
  402. while c in ['0'..'9'] do
  403. Begin
  404. actasmpattern:=actasmpattern + c;
  405. c:=current_scanner.asmgetchar;
  406. end;
  407. if upcase(c) = 'E' then
  408. begin
  409. actasmpattern:=actasmpattern + c;
  410. c:=current_scanner.asmgetchar;
  411. if (c in ['+','-']) then
  412. begin
  413. actasmpattern:=actasmpattern + c;
  414. c:=current_scanner.asmgetchar;
  415. end;
  416. while c in ['0'..'9'] do
  417. Begin
  418. actasmpattern:=actasmpattern + c;
  419. c:=current_scanner.asmgetchar;
  420. end;
  421. end;
  422. actasmtoken:=AS_REALNUM;
  423. exit;
  424. end
  425. else
  426. begin
  427. Message1(asmr_e_invalid_float_const,actasmpattern+c);
  428. actasmtoken:=AS_NONE;
  429. end;
  430. end;
  431. 'X': { hexadecimal }
  432. Begin
  433. c:=current_scanner.asmgetchar;
  434. while c in ['0'..'9','a'..'f','A'..'F'] do
  435. Begin
  436. actasmpattern:=actasmpattern + c;
  437. c:=current_scanner.asmgetchar;
  438. end;
  439. actasmpattern:=tostr(ValHexaDecimal(actasmpattern));
  440. actasmtoken:=AS_INTNUM;
  441. exit;
  442. end;
  443. '1'..'7': { octal }
  444. begin
  445. actasmpattern:=actasmpattern + c;
  446. while c in ['0'..'7'] do
  447. Begin
  448. actasmpattern:=actasmpattern + c;
  449. c:=current_scanner.asmgetchar;
  450. end;
  451. actasmpattern:=tostr(ValOctal(actasmpattern));
  452. actasmtoken:=AS_INTNUM;
  453. exit;
  454. end;
  455. else { octal number zero value...}
  456. Begin
  457. actasmpattern:=tostr(ValOctal(actasmpattern));
  458. actasmtoken:=AS_INTNUM;
  459. exit;
  460. end;
  461. end; { end case }
  462. end;
  463. '&' :
  464. begin
  465. c:=current_scanner.asmgetchar;
  466. actasmtoken:=AS_AND;
  467. end;
  468. '''' : { char }
  469. begin
  470. current_scanner.in_asm_string:=true;
  471. actasmpattern:='';
  472. repeat
  473. c:=current_scanner.asmgetchar;
  474. case c of
  475. '\' :
  476. begin
  477. { copy also the next char so \" is parsed correctly }
  478. actasmpattern:=actasmpattern+c;
  479. c:=current_scanner.asmgetchar;
  480. actasmpattern:=actasmpattern+c;
  481. end;
  482. '''' :
  483. begin
  484. c:=current_scanner.asmgetchar;
  485. break;
  486. end;
  487. #10,#13:
  488. Message(scan_f_string_exceeds_line);
  489. else
  490. actasmpattern:=actasmpattern+c;
  491. end;
  492. until false;
  493. actasmpattern:=EscapeToPascal(actasmpattern);
  494. actasmtoken:=AS_STRING;
  495. current_scanner.in_asm_string:=false;
  496. exit;
  497. end;
  498. '"' : { string }
  499. begin
  500. current_scanner.in_asm_string:=true;
  501. actasmpattern:='';
  502. repeat
  503. c:=current_scanner.asmgetchar;
  504. case c of
  505. '\' :
  506. begin
  507. { copy also the next char so \" is parsed correctly }
  508. actasmpattern:=actasmpattern+c;
  509. c:=current_scanner.asmgetchar;
  510. actasmpattern:=actasmpattern+c;
  511. end;
  512. '"' :
  513. begin
  514. c:=current_scanner.asmgetchar;
  515. break;
  516. end;
  517. #10,#13:
  518. Message(scan_f_string_exceeds_line);
  519. else
  520. actasmpattern:=actasmpattern+c;
  521. end;
  522. until false;
  523. actasmpattern:=EscapeToPascal(actasmpattern);
  524. actasmtoken:=AS_STRING;
  525. current_scanner.in_asm_string:=false;
  526. exit;
  527. end;
  528. '$' :
  529. begin
  530. actasmtoken:=AS_DOLLAR;
  531. c:=current_scanner.asmgetchar;
  532. exit;
  533. end;
  534. '#' :
  535. begin
  536. actasmtoken:=AS_HASH;
  537. c:=current_scanner.asmgetchar;
  538. exit;
  539. end;
  540. '[' :
  541. begin
  542. actasmtoken:=AS_LBRACKET;
  543. c:=current_scanner.asmgetchar;
  544. exit;
  545. end;
  546. ']' :
  547. begin
  548. actasmtoken:=AS_RBRACKET;
  549. c:=current_scanner.asmgetchar;
  550. exit;
  551. end;
  552. {$ifdef arm}
  553. // the arm assembler uses { ... } for register sets
  554. '{' :
  555. begin
  556. actasmtoken:=AS_LSBRACKET;
  557. c:=current_scanner.asmgetchar;
  558. exit;
  559. end;
  560. '}' :
  561. begin
  562. actasmtoken:=AS_RSBRACKET;
  563. c:=current_scanner.asmgetchar;
  564. exit;
  565. end;
  566. {$endif arm}
  567. ',' :
  568. begin
  569. actasmtoken:=AS_COMMA;
  570. c:=current_scanner.asmgetchar;
  571. exit;
  572. end;
  573. '<' :
  574. begin
  575. actasmtoken:=AS_SHL;
  576. c:=current_scanner.asmgetchar;
  577. if c = '<' then
  578. c:=current_scanner.asmgetchar;
  579. exit;
  580. end;
  581. '>' :
  582. begin
  583. actasmtoken:=AS_SHL;
  584. c:=current_scanner.asmgetchar;
  585. if c = '>' then
  586. c:=current_scanner.asmgetchar;
  587. exit;
  588. end;
  589. '|' :
  590. begin
  591. actasmtoken:=AS_OR;
  592. c:=current_scanner.asmgetchar;
  593. exit;
  594. end;
  595. '^' :
  596. begin
  597. actasmtoken:=AS_XOR;
  598. c:=current_scanner.asmgetchar;
  599. exit;
  600. end;
  601. '(' :
  602. begin
  603. actasmtoken:=AS_LPAREN;
  604. c:=current_scanner.asmgetchar;
  605. exit;
  606. end;
  607. ')' :
  608. begin
  609. actasmtoken:=AS_RPAREN;
  610. c:=current_scanner.asmgetchar;
  611. exit;
  612. end;
  613. ':' :
  614. begin
  615. actasmtoken:=AS_COLON;
  616. c:=current_scanner.asmgetchar;
  617. exit;
  618. end;
  619. '+' :
  620. begin
  621. actasmtoken:=AS_PLUS;
  622. c:=current_scanner.asmgetchar;
  623. exit;
  624. end;
  625. '-' :
  626. begin
  627. actasmtoken:=AS_MINUS;
  628. c:=current_scanner.asmgetchar;
  629. exit;
  630. end;
  631. '*' :
  632. begin
  633. actasmtoken:=AS_STAR;
  634. c:=current_scanner.asmgetchar;
  635. exit;
  636. end;
  637. '/' :
  638. begin
  639. actasmtoken:=AS_SLASH;
  640. c:=current_scanner.asmgetchar;
  641. exit;
  642. end;
  643. '@' :
  644. begin
  645. actasmtoken:=AS_AT;
  646. c:=current_scanner.asmgetchar;
  647. exit;
  648. end;
  649. {$ifndef arm}
  650. '{',
  651. {$endif arm}
  652. #13,#10,';' :
  653. begin
  654. { the comment is read by asmgetchar }
  655. c:=current_scanner.asmgetchar;
  656. firsttoken:=TRUE;
  657. actasmtoken:=AS_SEPARATOR;
  658. exit;
  659. end;
  660. else
  661. current_scanner.illegal_char(c);
  662. end;
  663. end;
  664. end;
  665. function tattreader.consume(t : tasmtoken):boolean;
  666. begin
  667. Consume:=true;
  668. if t<>actasmtoken then
  669. begin
  670. Message2(scan_f_syn_expected,token2str[t],token2str[actasmtoken]);
  671. Consume:=false;
  672. end;
  673. repeat
  674. gettoken;
  675. until actasmtoken<>AS_NONE;
  676. end;
  677. procedure tattreader.RecoverConsume(allowcomma:boolean);
  678. begin
  679. While not (actasmtoken in [AS_SEPARATOR,AS_END]) do
  680. begin
  681. if allowcomma and (actasmtoken=AS_COMMA) then
  682. break;
  683. Consume(actasmtoken);
  684. end;
  685. end;
  686. Procedure tattreader.BuildConstant(maxvalue: longint);
  687. var
  688. asmsym,
  689. expr: string;
  690. value : longint;
  691. Begin
  692. Repeat
  693. Case actasmtoken of
  694. AS_STRING:
  695. Begin
  696. expr:=actasmpattern;
  697. if length(expr) > 1 then
  698. Message(asmr_e_string_not_allowed_as_const);
  699. Consume(AS_STRING);
  700. Case actasmtoken of
  701. AS_COMMA: Consume(AS_COMMA);
  702. AS_END,
  703. AS_SEPARATOR: ;
  704. else
  705. Message(asmr_e_invalid_string_expression);
  706. end; { end case }
  707. ConcatString(curlist,expr);
  708. end;
  709. AS_INTNUM,
  710. AS_PLUS,
  711. AS_MINUS,
  712. AS_LPAREN,
  713. AS_NOT,
  714. AS_ID :
  715. Begin
  716. BuildConstSymbolExpression(false,false,false,value,asmsym);
  717. if asmsym<>'' then
  718. begin
  719. if maxvalue<>longint($ffffffff) then
  720. Message(asmr_w_32bit_const_for_address);
  721. ConcatConstSymbol(curlist,asmsym,value)
  722. end
  723. else
  724. ConcatConstant(curlist,value,maxvalue);
  725. end;
  726. AS_COMMA:
  727. Consume(AS_COMMA);
  728. AS_END,
  729. AS_SEPARATOR:
  730. break;
  731. else
  732. begin
  733. Message(asmr_e_syn_constant);
  734. RecoverConsume(false);
  735. end
  736. end; { end case }
  737. Until false;
  738. end;
  739. Procedure tattreader.BuildRealConstant(typ : tfloattype);
  740. var
  741. expr : string;
  742. r : bestreal;
  743. code : integer;
  744. negativ : boolean;
  745. errorflag: boolean;
  746. Begin
  747. errorflag:=FALSE;
  748. Repeat
  749. negativ:=false;
  750. expr:='';
  751. if actasmtoken=AS_PLUS then
  752. Consume(AS_PLUS)
  753. else
  754. if actasmtoken=AS_MINUS then
  755. begin
  756. negativ:=true;
  757. consume(AS_MINUS);
  758. end;
  759. Case actasmtoken of
  760. AS_INTNUM:
  761. Begin
  762. expr:=actasmpattern;
  763. Consume(AS_INTNUM);
  764. if negativ then
  765. expr:='-'+expr;
  766. val(expr,r,code);
  767. if code<>0 then
  768. Begin
  769. r:=0;
  770. Message(asmr_e_invalid_float_expr);
  771. End;
  772. ConcatRealConstant(curlist,r,typ);
  773. end;
  774. AS_REALNUM:
  775. Begin
  776. expr:=actasmpattern;
  777. Consume(AS_REALNUM);
  778. { in ATT syntax you have 0d in front of the real }
  779. { should this be forced ? yes i think so, as to }
  780. { conform to gas as much as possible. }
  781. if (expr[1]='0') and (upper(expr[2])='D') then
  782. Delete(expr,1,2);
  783. if negativ then
  784. expr:='-'+expr;
  785. val(expr,r,code);
  786. if code<>0 then
  787. Begin
  788. r:=0;
  789. Message(asmr_e_invalid_float_expr);
  790. End;
  791. ConcatRealConstant(curlist,r,typ);
  792. end;
  793. AS_COMMA:
  794. begin
  795. Consume(AS_COMMA);
  796. end;
  797. AS_END,
  798. AS_SEPARATOR:
  799. begin
  800. break;
  801. end;
  802. else
  803. Begin
  804. Consume(actasmtoken);
  805. if not errorflag then
  806. Message(asmr_e_invalid_float_expr);
  807. errorflag:=TRUE;
  808. end;
  809. end;
  810. Until false;
  811. end;
  812. Procedure tattreader.BuildStringConstant(asciiz: boolean);
  813. var
  814. expr: string;
  815. errorflag : boolean;
  816. Begin
  817. errorflag:=FALSE;
  818. Repeat
  819. Case actasmtoken of
  820. AS_STRING:
  821. Begin
  822. expr:=actasmpattern;
  823. if asciiz then
  824. expr:=expr+#0;
  825. ConcatPasString(curlist,expr);
  826. Consume(AS_STRING);
  827. end;
  828. AS_COMMA:
  829. begin
  830. Consume(AS_COMMA);
  831. end;
  832. AS_END,
  833. AS_SEPARATOR:
  834. begin
  835. break;
  836. end;
  837. else
  838. Begin
  839. Consume(actasmtoken);
  840. if not errorflag then
  841. Message(asmr_e_invalid_string_expression);
  842. errorflag:=TRUE;
  843. end;
  844. end;
  845. Until false;
  846. end;
  847. Function tattreader.Assemble: tlinkedlist;
  848. Var
  849. hl : tasmlabel;
  850. commname : string;
  851. lasTSec : TSection;
  852. l1,l2 : longint;
  853. Begin
  854. Message1(asmr_d_start_reading,'GNU AS');
  855. firsttoken:=TRUE;
  856. { sets up all opcode and register tables in uppercase }
  857. if not _asmsorted then
  858. Begin
  859. SetupTables;
  860. _asmsorted:=TRUE;
  861. end;
  862. curlist:=TAAsmoutput.Create;
  863. lasTSec:=sec_code;
  864. { setup label linked list }
  865. LocalLabelList:=TLocalLabelList.Create;
  866. { start tokenizer }
  867. c:=current_scanner.asmgetcharstart;
  868. gettoken;
  869. { main loop }
  870. repeat
  871. case actasmtoken of
  872. AS_LLABEL:
  873. Begin
  874. if CreateLocalLabel(actasmpattern,hl,true) then
  875. ConcatLabel(curlist,hl);
  876. Consume(AS_LLABEL);
  877. end;
  878. AS_LABEL:
  879. Begin
  880. if SearchLabel(upper(actasmpattern),hl,true) then
  881. ConcatLabel(curlist,hl)
  882. else
  883. Message1(asmr_e_unknown_label_identifier,actasmpattern);
  884. Consume(AS_LABEL);
  885. end;
  886. AS_DW:
  887. Begin
  888. Consume(AS_DW);
  889. BuildConstant($ffff);
  890. end;
  891. AS_DATA:
  892. Begin
  893. curList.Concat(Tai_section.Create(sec_data));
  894. lasTSec:=sec_data;
  895. Consume(AS_DATA);
  896. end;
  897. AS_TEXT:
  898. Begin
  899. curList.Concat(Tai_section.Create(sec_code));
  900. lasTSec:=sec_code;
  901. Consume(AS_TEXT);
  902. end;
  903. AS_DB:
  904. Begin
  905. Consume(AS_DB);
  906. BuildConstant($ff);
  907. end;
  908. AS_DD:
  909. Begin
  910. Consume(AS_DD);
  911. BuildConstant(longint($ffffffff));
  912. end;
  913. AS_DQ:
  914. Begin
  915. Consume(AS_DQ);
  916. BuildRealConstant(s64comp);
  917. end;
  918. AS_SINGLE:
  919. Begin
  920. Consume(AS_SINGLE);
  921. BuildRealConstant(s32real);
  922. end;
  923. AS_DOUBLE:
  924. Begin
  925. Consume(AS_DOUBLE);
  926. BuildRealConstant(s64real);
  927. end;
  928. AS_EXTENDED:
  929. Begin
  930. Consume(AS_EXTENDED);
  931. BuildRealConstant(s80real);
  932. end;
  933. AS_GLOBAL:
  934. Begin
  935. Consume(AS_GLOBAL);
  936. if actasmtoken=AS_ID then
  937. ConcatPublic(curlist,actasmpattern);
  938. Consume(AS_ID);
  939. if actasmtoken<>AS_SEPARATOR then
  940. Consume(AS_SEPARATOR);
  941. end;
  942. AS_ALIGN:
  943. Begin
  944. Consume(AS_ALIGN);
  945. l1:=BuildConstExpression(false,false);
  946. if (target_info.system in [system_i386_GO32V2]) then
  947. begin
  948. l2:=1;
  949. if (l1>=0) and (l1<=16) then
  950. while (l1>0) do
  951. begin
  952. l2:=2*l2;
  953. dec(l1);
  954. end;
  955. l1:=l2;
  956. end;
  957. ConcatAlign(curlist,l1);
  958. Message(asmr_n_align_is_target_specific);
  959. if actasmtoken<>AS_SEPARATOR then
  960. Consume(AS_SEPARATOR);
  961. end;
  962. AS_BALIGN:
  963. Begin
  964. Consume(AS_BALIGN);
  965. ConcatAlign(curlist,BuildConstExpression(false,false));
  966. if actasmtoken<>AS_SEPARATOR then
  967. Consume(AS_SEPARATOR);
  968. end;
  969. AS_P2ALIGN:
  970. Begin
  971. Consume(AS_P2ALIGN);
  972. l1:=BuildConstExpression(false,false);
  973. l2:=1;
  974. if (l1>=0) and (l1<=16) then
  975. while (l1>0) do
  976. begin
  977. l2:=2*l2;
  978. dec(l1);
  979. end;
  980. l1:=l2;
  981. ConcatAlign(curlist,l1);
  982. if actasmtoken<>AS_SEPARATOR then
  983. Consume(AS_SEPARATOR);
  984. end;
  985. AS_ASCIIZ:
  986. Begin
  987. Consume(AS_ASCIIZ);
  988. BuildStringConstant(TRUE);
  989. end;
  990. AS_ASCII:
  991. Begin
  992. Consume(AS_ASCII);
  993. BuildStringConstant(FALSE);
  994. end;
  995. AS_LCOMM:
  996. Begin
  997. Consume(AS_LCOMM);
  998. commname:=actasmpattern;
  999. Consume(AS_ID);
  1000. Consume(AS_COMMA);
  1001. ConcatLocalBss(commname,BuildConstExpression(false,false));
  1002. if actasmtoken<>AS_SEPARATOR then
  1003. Consume(AS_SEPARATOR);
  1004. end;
  1005. AS_COMM:
  1006. Begin
  1007. Consume(AS_COMM);
  1008. commname:=actasmpattern;
  1009. Consume(AS_ID);
  1010. Consume(AS_COMMA);
  1011. ConcatGlobalBss(commname,BuildConstExpression(false,false));
  1012. if actasmtoken<>AS_SEPARATOR then
  1013. Consume(AS_SEPARATOR);
  1014. end;
  1015. AS_OPCODE:
  1016. Begin
  1017. HandleOpCode;
  1018. end;
  1019. AS_SEPARATOR:
  1020. Begin
  1021. Consume(AS_SEPARATOR);
  1022. end;
  1023. AS_END:
  1024. begin
  1025. break; { end assembly block }
  1026. end;
  1027. else
  1028. Begin
  1029. Message(asmr_e_syntax_error);
  1030. RecoverConsume(false);
  1031. end;
  1032. end;
  1033. until false;
  1034. { Check LocalLabelList }
  1035. LocalLabelList.CheckEmitted;
  1036. LocalLabelList.Free;
  1037. { are we back in the code section? }
  1038. if lasTSec<>sec_code then
  1039. begin
  1040. Message(asmr_w_assembler_code_not_returned_to_text);
  1041. curList.Concat(Tai_section.Create(sec_code));
  1042. end;
  1043. { Return the list in an asmnode }
  1044. assemble:=curlist;
  1045. Message1(asmr_d_finish_reading,'GNU AS');
  1046. end;
  1047. {*****************************************************************************
  1048. Parsing Helpers
  1049. *****************************************************************************}
  1050. Procedure tattreader.BuildRecordOffsetSize(const expr: string;var offset:longint;var size:longint);
  1051. { Description: This routine builds up a record offset after a AS_DOT }
  1052. { token is encountered. }
  1053. { On entry actasmtoken should be equal to AS_DOT }
  1054. var
  1055. s : string;
  1056. Begin
  1057. offset:=0;
  1058. size:=0;
  1059. s:=expr;
  1060. while (actasmtoken=AS_DOT) do
  1061. begin
  1062. Consume(AS_DOT);
  1063. if actasmtoken=AS_ID then
  1064. s:=s+'.'+actasmpattern;
  1065. if not Consume(AS_ID) then
  1066. begin
  1067. RecoverConsume(true);
  1068. break;
  1069. end;
  1070. end;
  1071. if not GetRecordOffsetSize(s,offset,size) then
  1072. Message(asmr_e_building_record_offset);
  1073. end;
  1074. procedure tattreader.BuildConstSymbolExpression(allowref,betweenbracket,needofs:boolean;var value:longint;var asmsym:string);
  1075. var
  1076. hs,tempstr,expr : string;
  1077. parenlevel,l,k : longint;
  1078. errorflag : boolean;
  1079. prevtok : tasmtoken;
  1080. sym : tsym;
  1081. srsymtable : tsymtable;
  1082. hl : tasmlabel;
  1083. Begin
  1084. asmsym:='';
  1085. value:=0;
  1086. errorflag:=FALSE;
  1087. tempstr:='';
  1088. expr:='';
  1089. parenlevel:=0;
  1090. Repeat
  1091. Case actasmtoken of
  1092. AS_LPAREN:
  1093. Begin
  1094. { Exit if ref? }
  1095. if allowref and (prevasmtoken in [AS_INTNUM,AS_ID]) then
  1096. break;
  1097. Consume(AS_LPAREN);
  1098. expr:=expr + '(';
  1099. inc(parenlevel);
  1100. end;
  1101. AS_RPAREN:
  1102. Begin
  1103. { end of ref ? }
  1104. if (parenlevel=0) and betweenbracket then
  1105. break;
  1106. Consume(AS_RPAREN);
  1107. expr:=expr + ')';
  1108. dec(parenlevel);
  1109. end;
  1110. AS_SHL:
  1111. Begin
  1112. Consume(AS_SHL);
  1113. expr:=expr + '<';
  1114. end;
  1115. AS_SHR:
  1116. Begin
  1117. Consume(AS_SHR);
  1118. expr:=expr + '>';
  1119. end;
  1120. AS_SLASH:
  1121. Begin
  1122. Consume(AS_SLASH);
  1123. expr:=expr + '/';
  1124. end;
  1125. AS_MOD:
  1126. Begin
  1127. Consume(AS_MOD);
  1128. expr:=expr + '%';
  1129. end;
  1130. AS_STAR:
  1131. Begin
  1132. Consume(AS_STAR);
  1133. expr:=expr + '*';
  1134. end;
  1135. AS_PLUS:
  1136. Begin
  1137. Consume(AS_PLUS);
  1138. expr:=expr + '+';
  1139. end;
  1140. AS_MINUS:
  1141. Begin
  1142. Consume(AS_MINUS);
  1143. expr:=expr + '-';
  1144. end;
  1145. AS_AND:
  1146. Begin
  1147. Consume(AS_AND);
  1148. expr:=expr + '&';
  1149. end;
  1150. AS_NOT:
  1151. Begin
  1152. Consume(AS_NOT);
  1153. expr:=expr + '~';
  1154. end;
  1155. AS_XOR:
  1156. Begin
  1157. Consume(AS_XOR);
  1158. expr:=expr + '^';
  1159. end;
  1160. AS_OR:
  1161. Begin
  1162. Consume(AS_OR);
  1163. expr:=expr + '|';
  1164. end;
  1165. AS_INTNUM:
  1166. Begin
  1167. expr:=expr + actasmpattern;
  1168. Consume(AS_INTNUM);
  1169. end;
  1170. AS_DOLLAR:
  1171. begin
  1172. Consume(AS_DOLLAR);
  1173. if actasmtoken<>AS_ID then
  1174. Message(asmr_e_dollar_without_identifier);
  1175. end;
  1176. AS_STRING:
  1177. Begin
  1178. l:=0;
  1179. case Length(actasmpattern) of
  1180. 1 :
  1181. l:=ord(actasmpattern[1]);
  1182. 2 :
  1183. l:=ord(actasmpattern[2]) + ord(actasmpattern[1]) shl 8;
  1184. 3 :
  1185. l:=ord(actasmpattern[3]) +
  1186. Ord(actasmpattern[2]) shl 8 + ord(actasmpattern[1]) shl 16;
  1187. 4 :
  1188. l:=ord(actasmpattern[4]) + ord(actasmpattern[3]) shl 8 +
  1189. Ord(actasmpattern[2]) shl 16 + ord(actasmpattern[1]) shl 24;
  1190. else
  1191. Message1(asmr_e_invalid_string_as_opcode_operand,actasmpattern);
  1192. end;
  1193. str(l, tempstr);
  1194. expr:=expr + tempstr;
  1195. Consume(AS_STRING);
  1196. end;
  1197. AS_TYPE:
  1198. begin
  1199. l:=0;
  1200. Consume(AS_TYPE);
  1201. if actasmtoken<>AS_ID then
  1202. Message(asmr_e_type_without_identifier)
  1203. else
  1204. begin
  1205. tempstr:=actasmpattern;
  1206. Consume(AS_ID);
  1207. if actasmtoken=AS_DOT then
  1208. BuildRecordOffsetSize(tempstr,k,l)
  1209. else
  1210. begin
  1211. searchsym(tempstr,sym,srsymtable);
  1212. if assigned(sym) then
  1213. begin
  1214. case sym.typ of
  1215. varsym :
  1216. l:=tvarsym(sym).getsize;
  1217. typedconstsym :
  1218. l:=ttypedconstsym(sym).getsize;
  1219. typesym :
  1220. l:=ttypesym(sym).restype.def.size;
  1221. else
  1222. Message(asmr_e_wrong_sym_type);
  1223. end;
  1224. end
  1225. else
  1226. Message1(sym_e_unknown_id,tempstr);
  1227. end;
  1228. end;
  1229. str(l, tempstr);
  1230. expr:=expr + tempstr;
  1231. end;
  1232. AS_ID:
  1233. Begin
  1234. hs:='';
  1235. tempstr:=actasmpattern;
  1236. prevtok:=prevasmtoken;
  1237. consume(AS_ID);
  1238. if SearchIConstant(tempstr,l) then
  1239. begin
  1240. str(l, tempstr);
  1241. expr:=expr + tempstr;
  1242. end
  1243. else
  1244. begin
  1245. if is_locallabel(tempstr) then
  1246. begin
  1247. CreateLocalLabel(tempstr,hl,false);
  1248. hs:=hl.name
  1249. end
  1250. else
  1251. if SearchLabel(tempstr,hl,false) then
  1252. hs:=hl.name
  1253. else
  1254. begin
  1255. searchsym(tempstr,sym,srsymtable);
  1256. if assigned(sym) then
  1257. begin
  1258. case sym.typ of
  1259. varsym :
  1260. begin
  1261. if sym.owner.symtabletype in [localsymtable,parasymtable] then
  1262. Message(asmr_e_no_local_or_para_allowed);
  1263. hs:=tvarsym(sym).mangledname;
  1264. end;
  1265. typedconstsym :
  1266. hs:=ttypedconstsym(sym).mangledname;
  1267. procsym :
  1268. begin
  1269. if Tprocsym(sym).procdef_count>1 then
  1270. Message(asmr_w_calling_overload_func);
  1271. hs:=tprocsym(sym).first_procdef.mangledname;
  1272. end;
  1273. typesym :
  1274. begin
  1275. if not(ttypesym(sym).restype.def.deftype in [recorddef,objectdef]) then
  1276. Message(asmr_e_wrong_sym_type);
  1277. end;
  1278. else
  1279. Message(asmr_e_wrong_sym_type);
  1280. end;
  1281. end
  1282. else
  1283. Message1(sym_e_unknown_id,tempstr);
  1284. end;
  1285. { symbol found? }
  1286. if hs<>'' then
  1287. begin
  1288. if needofs and (prevtok<>AS_DOLLAR) then
  1289. Message(asmr_e_need_dollar);
  1290. if asmsym='' then
  1291. asmsym:=hs
  1292. else
  1293. Message(asmr_e_cant_have_multiple_relocatable_symbols);
  1294. if (expr='') or (expr[length(expr)]='+') then
  1295. begin
  1296. { don't remove the + if there could be a record field }
  1297. if actasmtoken<>AS_DOT then
  1298. delete(expr,length(expr),1);
  1299. end
  1300. else
  1301. Message(asmr_e_only_add_relocatable_symbol);
  1302. end;
  1303. if actasmtoken=AS_DOT then
  1304. begin
  1305. BuildRecordOffsetSize(tempstr,l,k);
  1306. str(l, tempstr);
  1307. expr:=expr + tempstr;
  1308. end
  1309. else
  1310. begin
  1311. if (expr='') or (expr[length(expr)] in ['+','-','/','*']) then
  1312. delete(expr,length(expr),1);
  1313. end;
  1314. end;
  1315. { check if there are wrong operator used like / or mod etc. }
  1316. if (hs<>'') and not(actasmtoken in [AS_MINUS,AS_PLUS,AS_COMMA,AS_SEPARATOR,AS_LPAREN,AS_END]) then
  1317. Message(asmr_e_only_add_relocatable_symbol);
  1318. end;
  1319. AS_END,
  1320. AS_SEPARATOR,
  1321. AS_COMMA:
  1322. break;
  1323. else
  1324. Begin
  1325. { write error only once. }
  1326. if not errorflag then
  1327. Message(asmr_e_invalid_constant_expression);
  1328. { consume tokens until we find COMMA or SEPARATOR }
  1329. Consume(actasmtoken);
  1330. errorflag:=TRUE;
  1331. end;
  1332. end;
  1333. Until false;
  1334. { calculate expression }
  1335. if not ErrorFlag then
  1336. value:=CalculateExpression(expr)
  1337. else
  1338. value:=0;
  1339. end;
  1340. function tattreader.BuildConstExpression(allowref,betweenbracket:boolean): longint;
  1341. var
  1342. l : longint;
  1343. hs : string;
  1344. begin
  1345. BuildConstSymbolExpression(allowref,betweenbracket,false,l,hs);
  1346. if hs<>'' then
  1347. Message(asmr_e_relocatable_symbol_not_allowed);
  1348. BuildConstExpression:=l;
  1349. end;
  1350. Procedure tattreader.BuildConstantOperand(oper : toperand);
  1351. var
  1352. l : longint;
  1353. tempstr : string;
  1354. begin
  1355. BuildConstSymbolExpression(false,false,true,l,tempstr);
  1356. if tempstr<>'' then
  1357. begin
  1358. oper.opr.typ:=OPR_SYMBOL;
  1359. oper.opr.symofs:=l;
  1360. oper.opr.symbol:=objectlibrary.newasmsymbol(tempstr);
  1361. end
  1362. else
  1363. begin
  1364. oper.opr.typ:=OPR_CONSTANT;
  1365. oper.opr.val:=l;
  1366. end;
  1367. end;
  1368. end.
  1369. {
  1370. $Log$
  1371. Revision 1.5 2003-12-03 17:39:04 florian
  1372. * fixed several arm calling conventions issues
  1373. * fixed reference reading in the assembler reader
  1374. * fixed a_loadaddr_ref_reg
  1375. Revision 1.4 2003/11/29 16:27:19 jonas
  1376. * fixed several ppc assembler reader related problems
  1377. * local vars in assembler procedures now start at offset 4
  1378. * fixed second_int_to_bool (apparently an integer can be in LOC_JUMP??)
  1379. Revision 1.3 2003/11/17 23:23:47 florian
  1380. + first part of arm assembler reader
  1381. Revision 1.2 2003/11/15 19:00:10 florian
  1382. * fixed ppc assembler reader
  1383. Revision 1.1 2003/11/12 16:05:39 florian
  1384. * assembler readers OOPed
  1385. + typed currency constants
  1386. + typed 128 bit float constants if the CPU supports it
  1387. }