raatt.pas 47 KB

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