rautils.pas 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  1. {
  2. $Id$
  3. Copyright (c) 1998 Carl Eric Codere
  4. This unit implements some support routines for assembler parsing
  5. independent of the processor
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. **********************************************************************}
  18. Unit RAUtils;
  19. Interface
  20. Uses
  21. strings,
  22. cobjects,
  23. globtype,systems,verbose,globals,files,
  24. symconst,symtable,aasm,hcodegen,cpubase,cpuasm
  25. ;
  26. Const
  27. RPNMax = 10; { I think you only need 4, but just to be safe }
  28. OpMax = 25;
  29. maxoperands = 3; { Maximum operands for assembler instructions }
  30. {---------------------------------------------------------------------
  31. Local Label Management
  32. ---------------------------------------------------------------------}
  33. Type
  34. { Each local label has this structure associated with it }
  35. PLocalLabel = ^TLocalLabel;
  36. TLocalLabel = object(TNamedIndexObject)
  37. Emitted : boolean;
  38. constructor Init(const n:string);
  39. function Getpasmlabel:pasmlabel;
  40. private
  41. lab : pasmlabel;
  42. end;
  43. PLocalLabelList = ^TLocalLabelList;
  44. TLocalLabelList = Object(TDictionary)
  45. procedure CheckEmitted;
  46. end;
  47. var
  48. LocalLabelList : PLocalLabelList;
  49. function CreateLocalLabel(const s: string; var hl: pasmlabel; emit:boolean):boolean;
  50. Function SearchLabel(const s: string; var hl: pasmlabel;emit:boolean): boolean;
  51. {---------------------------------------------------------------------
  52. Instruction management
  53. ---------------------------------------------------------------------}
  54. type
  55. TOprType=(OPR_NONE,OPR_CONSTANT,OPR_SYMBOL,OPR_REFERENCE,OPR_REGISTER);
  56. TOprRec = record
  57. case typ:TOprType of
  58. OPR_NONE : ();
  59. OPR_CONSTANT : (val:longint);
  60. OPR_SYMBOL : (symbol:PAsmSymbol;symofs:longint);
  61. OPR_REFERENCE : (ref:treference);
  62. OPR_REGISTER : (reg:tregister);
  63. end;
  64. POperand = ^TOperand;
  65. TOperand = object
  66. size : topsize;
  67. hasvar : boolean; { if the operand is loaded with a variable }
  68. opr : TOprRec;
  69. constructor init;
  70. destructor done;virtual;
  71. Procedure BuildOperand;virtual;
  72. Procedure SetSize(_size:longint);
  73. Function SetupResult:boolean;
  74. Function SetupSelf:boolean;
  75. Function SetupOldEBP:boolean;
  76. Function SetupVar(const hs:string): Boolean;
  77. Function SetupDirectVar(const hs:string): Boolean;
  78. Procedure InitRef;
  79. end;
  80. PInstruction = ^TInstruction;
  81. TInstruction = object
  82. opcode : tasmop;
  83. opsize : topsize;
  84. condition : tasmcond;
  85. ops : byte;
  86. operands : array[1..maxoperands] of POperand;
  87. constructor init;
  88. destructor done;virtual;
  89. Procedure InitOperands;virtual;
  90. Procedure BuildOpcode;virtual;
  91. procedure ConcatInstruction(p:PAasmoutput);virtual;
  92. Procedure SwapOperands;
  93. end;
  94. {---------------------------------------------------------------------}
  95. { Expression parser types }
  96. {---------------------------------------------------------------------}
  97. TExprOperator = record
  98. ch: char; { operator }
  99. is_prefix: boolean; { was it a prefix, possible prefixes are +,- and not }
  100. end;
  101. String15 = String[15];
  102. {**********************************************************************}
  103. { The following operators are supported: }
  104. { '+' : addition }
  105. { '-' : subtraction }
  106. { '*' : multiplication }
  107. { '/' : modulo division }
  108. { '^' : exclusive or }
  109. { '<' : shift left }
  110. { '>' : shift right }
  111. { '&' : bitwise and }
  112. { '|' : bitwise or }
  113. { '~' : bitwise complement }
  114. { '%' : modulo division }
  115. { nnn: longint numbers }
  116. { ( and ) parenthesis }
  117. {**********************************************************************}
  118. TExprParse = Object
  119. public
  120. Constructor Init;
  121. Destructor Done;
  122. Function Evaluate(Expr: String): longint;
  123. Function Priority(_Operator: Char): Integer; virtual;
  124. private
  125. RPNStack : Array[1..RPNMax] of longint; { Stack For RPN calculator }
  126. RPNTop : Integer;
  127. OpStack : Array[1..OpMax] of TExprOperator; { Operator stack For conversion }
  128. OpTop : Integer;
  129. Procedure RPNPush(Num: Longint);
  130. Function RPNPop: Longint;
  131. Procedure RPNCalc(token: String15; prefix: boolean);
  132. Procedure OpPush(_Operator: char; prefix: boolean);
  133. { In reality returns TExprOperaotr }
  134. Procedure OpPop(var _Operator:TExprOperator);
  135. end;
  136. { Evaluate an expression string to a longint }
  137. Function CalculateExpression(const expression: string): longint;
  138. {---------------------------------------------------------------------}
  139. { String routines }
  140. {---------------------------------------------------------------------}
  141. Function ValDecimal(const S:String):longint;
  142. Function ValOctal(const S:String):longint;
  143. Function ValBinary(const S:String):longint;
  144. Function ValHexaDecimal(const S:String):longint;
  145. Function PadZero(Var s: String; n: byte): Boolean;
  146. Function EscapeToPascal(const s:string): string;
  147. {---------------------------------------------------------------------
  148. Symbol helper routines
  149. ---------------------------------------------------------------------}
  150. Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
  151. Function SearchRecordType(const s:string): boolean;
  152. Function SearchIConstant(const s:string; var l:longint): boolean;
  153. {---------------------------------------------------------------------
  154. Instruction generation routines
  155. ---------------------------------------------------------------------}
  156. Procedure ConcatPasString(p : paasmoutput;s:string);
  157. Procedure ConcatDirect(p : paasmoutput;s:string);
  158. Procedure ConcatLabel(p: paasmoutput;var l : pasmlabel);
  159. Procedure ConcatConstant(p : paasmoutput;value: longint; maxvalue: longint);
  160. Procedure ConcatConstSymbol(p : paasmoutput;const sym:string;l:longint);
  161. Procedure ConcatRealConstant(p : paasmoutput;value: bestreal; real_typ : tfloattype);
  162. Procedure ConcatString(p : paasmoutput;s:string);
  163. procedure ConcatAlign(p:paasmoutput;l:longint);
  164. Procedure ConcatPublic(p:paasmoutput;const s : string);
  165. Procedure ConcatLocal(p:paasmoutput;const s : string);
  166. Procedure ConcatGlobalBss(const s : string;size : longint);
  167. Procedure ConcatLocalBss(const s : string;size : longint);
  168. Implementation
  169. {*************************************************************************
  170. TExprParse
  171. *************************************************************************}
  172. Constructor TExprParse.Init;
  173. Begin
  174. end;
  175. Procedure TExprParse.RPNPush(Num : longint);
  176. { Add an operand to the top of the RPN stack }
  177. begin
  178. if RPNTop < RPNMax then
  179. begin
  180. Inc(RPNTop);
  181. RPNStack[RPNTop]:=Num;
  182. end
  183. else
  184. Message(asmr_e_ev_stack_overflow);
  185. end;
  186. Function TExprParse.RPNPop : longint;
  187. { Get the operand at the top of the RPN stack }
  188. begin
  189. if RPNTop > 0 then
  190. begin
  191. RPNPop:=RPNStack[RPNTop];
  192. Dec(RPNTop);
  193. end
  194. else
  195. Message(asmr_e_ev_stack_underflow);
  196. end;
  197. Procedure TExprParse.RPNCalc(Token : String15; prefix:boolean); { RPN Calculator }
  198. Var
  199. Temp : longint;
  200. LocalError : Integer;
  201. begin
  202. { Handle operators }
  203. if (Length(Token) = 1) and (Token[1] in ['+', '-', '*', '/','&','|','%','^','~','<','>']) then
  204. Case Token[1] of
  205. '+' :
  206. Begin
  207. if not prefix then
  208. RPNPush(RPNPop + RPNPop);
  209. end;
  210. '-' :
  211. Begin
  212. if prefix then
  213. RPNPush(-(RPNPop))
  214. else
  215. RPNPush(RPNPop - RPNPop);
  216. end;
  217. '*' : RPNPush(RPNPop * RPNPop);
  218. '&' : RPNPush(RPNPop AND RPNPop);
  219. '|' : RPNPush(RPNPop OR RPNPop);
  220. '~' : RPNPush(NOT RPNPop);
  221. '<' : RPNPush(RPNPop SHL RPNPop);
  222. '>' : RPNPush(RPNPop SHR RPNPop);
  223. '%' :
  224. begin
  225. Temp:=RPNPop;
  226. if Temp <> 0 then
  227. RPNPush(RPNPop mod Temp)
  228. else
  229. Message(asmr_e_ev_zero_divide);
  230. end;
  231. '^' : RPNPush(RPNPop XOR RPNPop);
  232. '/' :
  233. begin
  234. Temp:=RPNPop;
  235. if Temp <> 0 then
  236. RPNPush(RPNPop div Temp)
  237. else
  238. Message(asmr_e_ev_zero_divide);
  239. end;
  240. end
  241. else
  242. begin
  243. { Convert String to number and add to stack }
  244. if token='-2147483648' then
  245. begin
  246. temp:=$80000000;
  247. localerror:=0;
  248. end
  249. else
  250. Val(Token, Temp, LocalError);
  251. if LocalError = 0 then
  252. RPNPush(Temp)
  253. else
  254. Message(asmr_e_ev_invalid_number);
  255. end;
  256. end;
  257. Procedure TExprParse.OpPush(_Operator : char;prefix: boolean);
  258. { Add an operator onto top of the stack }
  259. begin
  260. if OpTop < OpMax then
  261. begin
  262. Inc(OpTop);
  263. OpStack[OpTop].ch:=_Operator;
  264. OpStack[OpTop].is_prefix:=prefix;
  265. end
  266. else
  267. Message(asmr_e_ev_stack_overflow);
  268. end;
  269. Procedure TExprParse.OpPop(var _Operator:TExprOperator);
  270. { Get operator at the top of the stack }
  271. begin
  272. if OpTop > 0 then
  273. begin
  274. _Operator:=OpStack[OpTop];
  275. Dec(OpTop);
  276. end
  277. else
  278. Message(asmr_e_ev_stack_underflow);
  279. end;
  280. Function TExprParse.Priority(_Operator : Char) : Integer;
  281. { Return priority of operator }
  282. { The greater the priority, the higher the precedence }
  283. begin
  284. Case _Operator OF
  285. '(' :
  286. Priority:=0;
  287. '+', '-' :
  288. Priority:=1;
  289. '*', '/','%','<','>' :
  290. Priority:=2;
  291. '|','&','^','~' :
  292. Priority:=0;
  293. else
  294. Message(asmr_e_ev_invalid_op);
  295. end;
  296. end;
  297. Function TExprParse.Evaluate(Expr : String):longint;
  298. Var
  299. I : Integer;
  300. Token : String15;
  301. opr : TExprOperator;
  302. begin
  303. Evaluate:=0;
  304. { Reset stacks }
  305. OpTop :=0;
  306. RPNTop:=0;
  307. Token :='';
  308. { nothing to do ? }
  309. if Expr='' then
  310. exit;
  311. For I:=1 to Length(Expr) DO
  312. begin
  313. if Expr[I] in ['0'..'9'] then
  314. begin { Build multi-digit numbers }
  315. Token:=Token + Expr[I];
  316. if I = Length(Expr) then { Send last one to calculator }
  317. RPNCalc(Token,false);
  318. end
  319. else
  320. if Expr[I] in ['+', '-', '*', '/', '(', ')','^','&','|','%','~','<','>'] then
  321. begin
  322. if Token <> '' then
  323. begin { Send last built number to calc. }
  324. RPNCalc(Token,false);
  325. Token:='';
  326. end;
  327. Case Expr[I] OF
  328. '(' : OpPush('(',false);
  329. ')' : begin
  330. While OpStack[OpTop].ch <> '(' DO
  331. Begin
  332. OpPop(opr);
  333. RPNCalc(opr.ch,opr.is_prefix);
  334. end;
  335. OpPop(opr); { Pop off and ignore the '(' }
  336. end;
  337. '+','-','~' : Begin
  338. { workaround for -2147483648 }
  339. if (expr[I]='-') and (expr[i+1] in ['0'..'9']) then
  340. begin
  341. token:='-';
  342. expr[i]:='+';
  343. end;
  344. { if start of expression then surely a prefix }
  345. { or if previous char was also an operator }
  346. if (I = 1) or (not (Expr[I-1] in ['0'..'9','(',')'])) then
  347. OpPush(Expr[I],true)
  348. else
  349. Begin
  350. { Evaluate all higher priority operators }
  351. While (OpTop > 0) AND (Priority(Expr[I]) <= Priority(OpStack[OpTop].ch)) DO
  352. Begin
  353. OpPop(opr);
  354. RPNCalc(opr.ch,opr.is_prefix);
  355. end;
  356. OpPush(Expr[I],false);
  357. End;
  358. end;
  359. '*', '/',
  360. '^','|','&',
  361. '%','<','>' : begin
  362. While (OpTop > 0) and (Priority(Expr[I]) <= Priority(OpStack[OpTop].ch)) DO
  363. Begin
  364. OpPop(opr);
  365. RPNCalc(opr.ch,opr.is_prefix);
  366. end;
  367. OpPush(Expr[I],false);
  368. end;
  369. end; { Case }
  370. end
  371. else
  372. Message(asmr_e_ev_invalid_op); { Handle bad input error }
  373. end;
  374. { Pop off the remaining operators }
  375. While OpTop > 0 do
  376. Begin
  377. OpPop(opr);
  378. RPNCalc(opr.ch,opr.is_prefix);
  379. end;
  380. { The result is stored on the top of the stack }
  381. Evaluate:=RPNPop;
  382. end;
  383. Destructor TExprParse.Done;
  384. Begin
  385. end;
  386. Function CalculateExpression(const expression: string): longint;
  387. var
  388. expr: TExprParse;
  389. Begin
  390. expr.Init;
  391. CalculateExpression:=expr.Evaluate(expression);
  392. expr.Done;
  393. end;
  394. {*************************************************************************}
  395. { String conversions/utils }
  396. {*************************************************************************}
  397. Function EscapeToPascal(const s:string): string;
  398. { converts a C styled string - which contains escape }
  399. { characters to a pascal style string. }
  400. var
  401. i,len : longint;
  402. hs : string;
  403. temp : string;
  404. c : char;
  405. Begin
  406. hs:='';
  407. len:=0;
  408. i:=0;
  409. while (i<length(s)) and (len<255) do
  410. begin
  411. Inc(i);
  412. if (s[i]='\') and (i<length(s)) then
  413. Begin
  414. inc(i);
  415. case s[i] of
  416. '\' :
  417. c:='\';
  418. 'b':
  419. c:=#8;
  420. 'f':
  421. c:=#12;
  422. 'n':
  423. c:=#10;
  424. 'r':
  425. c:=#13;
  426. 't':
  427. c:=#9;
  428. '"':
  429. c:='"';
  430. '0'..'7':
  431. Begin
  432. temp:=s[i];
  433. temp:=temp+s[i+1];
  434. temp:=temp+s[i+2];
  435. inc(i,2);
  436. c:=chr(ValOctal(temp));
  437. end;
  438. 'x':
  439. Begin
  440. temp:=s[i+1];
  441. temp:=temp+s[i+2];
  442. inc(i,2);
  443. c:=chr(ValHexaDecimal(temp));
  444. end;
  445. else
  446. Begin
  447. Message1(asmr_e_escape_seq_ignored,s[i]);
  448. c:=s[i];
  449. end;
  450. end;
  451. end
  452. else
  453. c:=s[i];
  454. inc(len);
  455. hs[len]:=c;
  456. end;
  457. hs[0]:=chr(len);
  458. EscapeToPascal:=hs;
  459. end;
  460. Function ValDecimal(const S:String):longint;
  461. { Converts a decimal string to longint }
  462. var
  463. vs,c : longint;
  464. Begin
  465. vs:=0;
  466. for c:=1 to length(s) do
  467. begin
  468. vs:=vs*10;
  469. if s[c] in ['0'..'9'] then
  470. inc(vs,ord(s[c])-ord('0'))
  471. else
  472. begin
  473. Message1(asmr_e_error_converting_decimal,s);
  474. ValDecimal:=0;
  475. exit;
  476. end;
  477. end;
  478. ValDecimal:=vs;
  479. end;
  480. Function ValOctal(const S:String):longint;
  481. { Converts an octal string to longint }
  482. var
  483. vs,c : longint;
  484. Begin
  485. vs:=0;
  486. for c:=1 to length(s) do
  487. begin
  488. vs:=vs shl 3;
  489. if s[c] in ['0'..'7'] then
  490. inc(vs,ord(s[c])-ord('0'))
  491. else
  492. begin
  493. Message1(asmr_e_error_converting_octal,s);
  494. ValOctal:=0;
  495. exit;
  496. end;
  497. end;
  498. ValOctal:=vs;
  499. end;
  500. Function ValBinary(const S:String):longint;
  501. { Converts a binary string to longint }
  502. var
  503. vs,c : longint;
  504. Begin
  505. vs:=0;
  506. for c:=1 to length(s) do
  507. begin
  508. vs:=vs shl 1;
  509. if s[c] in ['0'..'1'] then
  510. inc(vs,ord(s[c])-ord('0'))
  511. else
  512. begin
  513. Message1(asmr_e_error_converting_binary,s);
  514. ValBinary:=0;
  515. exit;
  516. end;
  517. end;
  518. ValBinary:=vs;
  519. end;
  520. Function ValHexadecimal(const S:String):longint;
  521. { Converts a binary string to longint }
  522. var
  523. vs,c : longint;
  524. Begin
  525. vs:=0;
  526. for c:=1 to length(s) do
  527. begin
  528. vs:=vs shl 4;
  529. case s[c] of
  530. '0'..'9' :
  531. inc(vs,ord(s[c])-ord('0'));
  532. 'A'..'F' :
  533. inc(vs,ord(s[c])-ord('A')+10);
  534. 'a'..'f' :
  535. inc(vs,ord(s[c])-ord('a')+10);
  536. else
  537. begin
  538. Message1(asmr_e_error_converting_hexadecimal,s);
  539. ValHexadecimal:=0;
  540. exit;
  541. end;
  542. end;
  543. end;
  544. ValHexadecimal:=vs;
  545. end;
  546. Function PadZero(Var s: String; n: byte): Boolean;
  547. Begin
  548. PadZero:=TRUE;
  549. { Do some error checking first }
  550. if Length(s) = n then
  551. exit
  552. else
  553. if Length(s) > n then
  554. Begin
  555. PadZero:=FALSE;
  556. delete(s,n+1,length(s));
  557. exit;
  558. end
  559. else
  560. PadZero:=TRUE;
  561. { Fill it up with the specified character }
  562. fillchar(s[length(s)+1],n-1,#0);
  563. s[0]:=chr(n);
  564. end;
  565. {****************************************************************************
  566. TOperand
  567. ****************************************************************************}
  568. constructor TOperand.init;
  569. begin
  570. size:=S_NO;
  571. hasvar:=false;
  572. FillChar(Opr,sizeof(Opr),0);
  573. end;
  574. destructor TOperand.done;
  575. begin
  576. end;
  577. Procedure TOperand.SetSize(_size:longint);
  578. begin
  579. if (size = S_NO) and (_size<extended_size) then
  580. Begin
  581. case _size of
  582. 1 : size:=S_B;
  583. 2 : size:=S_W{ could be S_IS};
  584. 4 : size:=S_L{ could be S_IL or S_FS};
  585. 8 : size:=S_IQ{ could be S_D or S_FL};
  586. extended_size : size:=S_FX;
  587. end;
  588. end;
  589. end;
  590. Function TOperand.SetupResult:boolean;
  591. Begin
  592. SetupResult:=false;
  593. { replace by correct offset. }
  594. if assigned(procinfo^.retdef) and
  595. (procinfo^.retdef<>pdef(voiddef)) then
  596. begin
  597. opr.ref.offset:=procinfo^.retoffset;
  598. opr.ref.base:= procinfo^.framepointer;
  599. { always assume that the result is valid. }
  600. procinfo^.funcret_is_valid:=true;
  601. SetupResult:=true;
  602. end
  603. else
  604. Message(asmr_e_void_function);
  605. end;
  606. Function TOperand.SetupSelf:boolean;
  607. Begin
  608. SetupSelf:=false;
  609. if assigned(procinfo^._class) then
  610. Begin
  611. opr.typ:=OPR_REFERENCE;
  612. opr.ref.offset:=procinfo^.ESI_offset;
  613. opr.ref.base:=procinfo^.framepointer;
  614. opr.ref.options:=ref_selffixup;
  615. SetupSelf:=true;
  616. end
  617. else
  618. Message(asmr_e_cannot_use_SELF_outside_a_method);
  619. end;
  620. Function TOperand.SetupOldEBP:boolean;
  621. Begin
  622. SetupOldEBP:=false;
  623. if lexlevel>normal_function_level then
  624. Begin
  625. opr.typ:=OPR_REFERENCE;
  626. opr.ref.offset:=procinfo^.framepointer_offset;
  627. opr.ref.base:=procinfo^.framepointer;
  628. SetupOldEBP:=true;
  629. end
  630. else
  631. Message(asmr_e_cannot_use_OLDEBP_outside_nested_procedure);
  632. end;
  633. Function TOperand.SetupVar(const hs:string): Boolean;
  634. { search and sets up the correct fields in the Instr record }
  635. { for the NON-constant identifier passed to the routine. }
  636. { if not found returns FALSE. }
  637. var
  638. sym : psym;
  639. harrdef : parraydef;
  640. Begin
  641. SetupVar:=false;
  642. { are we in a routine ? }
  643. getsym(hs,false);
  644. sym:=srsym;
  645. if sym=nil then
  646. exit;
  647. case sym^.typ of
  648. varsym :
  649. begin
  650. { we always assume in asm statements that }
  651. { that the variable is valid. }
  652. pvarsym(sym)^.varstate:=vs_used;
  653. inc(pvarsym(sym)^.refs);
  654. case pvarsym(sym)^.owner^.symtabletype of
  655. objectsymtable :
  656. begin
  657. { this is not allowed, because we don't know if the self
  658. register is still free, and loading it first is also
  659. not possible, because this could break code }
  660. opr.typ:=OPR_CONSTANT;
  661. opr.val:=pvarsym(sym)^.address;
  662. hasvar:=true;
  663. SetupVar:=true;
  664. Exit;
  665. end;
  666. unitsymtable,
  667. globalsymtable,
  668. staticsymtable :
  669. opr.ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname);
  670. parasymtable :
  671. begin
  672. opr.ref.base:=procinfo^.framepointer;
  673. opr.ref.offset:=pvarsym(sym)^.address;
  674. opr.ref.offsetfixup:=aktprocsym^.definition^.parast^.address_fixup;
  675. opr.ref.options:=ref_parafixup;
  676. end;
  677. localsymtable :
  678. begin
  679. if (vo_is_external in pvarsym(sym)^.varoptions) then
  680. opr.ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname)
  681. else
  682. begin
  683. opr.ref.base:=procinfo^.framepointer;
  684. opr.ref.offset:=-(pvarsym(sym)^.address);
  685. opr.ref.options:=ref_localfixup;
  686. opr.ref.offsetfixup:=aktprocsym^.definition^.localst^.address_fixup;
  687. end;
  688. end;
  689. end;
  690. case pvarsym(sym)^.definition^.deftype of
  691. orddef,
  692. enumdef,
  693. pointerdef,
  694. floatdef :
  695. SetSize(pvarsym(sym)^.getsize);
  696. arraydef :
  697. begin
  698. { for arrays try to get the element size, take care of
  699. multiple indexes }
  700. harrdef:=Parraydef(PVarsym(sym)^.definition);
  701. while assigned(harrdef^.definition) and
  702. (harrdef^.definition^.deftype=arraydef) do
  703. harrdef:=parraydef(harrdef^.definition);
  704. SetSize(harrdef^.elesize);
  705. end;
  706. end;
  707. hasvar:=true;
  708. SetupVar:=true;
  709. Exit;
  710. end;
  711. typedconstsym :
  712. begin
  713. opr.ref.symbol:=newasmsymbol(ptypedconstsym(sym)^.mangledname);
  714. case ptypedconstsym(sym)^.definition^.deftype of
  715. orddef,
  716. enumdef,
  717. pointerdef,
  718. floatdef :
  719. SetSize(ptypedconstsym(sym)^.getsize);
  720. arraydef :
  721. begin
  722. { for arrays try to get the element size, take care of
  723. multiple indexes }
  724. harrdef:=Parraydef(PTypedConstSym(sym)^.definition);
  725. while assigned(harrdef^.definition) and
  726. (harrdef^.definition^.deftype=arraydef) do
  727. harrdef:=parraydef(harrdef^.definition);
  728. SetSize(harrdef^.elesize);
  729. end;
  730. end;
  731. hasvar:=true;
  732. SetupVar:=true;
  733. Exit;
  734. end;
  735. constsym :
  736. begin
  737. if pconstsym(sym)^.consttype in [constint,constchar,constbool] then
  738. begin
  739. opr.typ:=OPR_CONSTANT;
  740. opr.val:=pconstsym(sym)^.value;
  741. hasvar:=true;
  742. SetupVar:=true;
  743. Exit;
  744. end;
  745. end;
  746. typesym :
  747. begin
  748. if ptypesym(sym)^.definition^.deftype in [recorddef,objectdef] then
  749. begin
  750. opr.typ:=OPR_CONSTANT;
  751. opr.val:=0;
  752. hasvar:=true;
  753. SetupVar:=TRUE;
  754. Exit;
  755. end;
  756. end;
  757. procsym :
  758. begin
  759. if assigned(pprocsym(sym)^.definition^.nextoverloaded) then
  760. Message(asmr_w_calling_overload_func);
  761. opr.typ:=OPR_SYMBOL;
  762. opr.symbol:=newasmsymbol(pprocsym(sym)^.definition^.mangledname);
  763. hasvar:=true;
  764. SetupVar:=TRUE;
  765. Exit;
  766. end;
  767. else
  768. begin
  769. Message(asmr_e_unsupported_symbol_type);
  770. exit;
  771. end;
  772. end;
  773. end;
  774. { looks for internal names of variables and routines }
  775. Function TOperand.SetupDirectVar(const hs:string): Boolean;
  776. {$ifndef OLDDIRECTVAR}
  777. var
  778. p : pasmsymbol;
  779. begin
  780. SetupDirectVar:=false;
  781. p:=getasmsymbol(hs);
  782. if assigned(p) then
  783. begin
  784. opr.ref.symbol:=p;
  785. hasvar:=true;
  786. SetupDirectVar:=true;
  787. end;
  788. end;
  789. {$else}
  790. var
  791. p : pai_external;
  792. Begin
  793. SearchDirectVar:=false;
  794. { search in the list of internals }
  795. p:=search_assembler_symbol(internals,hs,EXT_ANY);
  796. if p=nil then
  797. p:=search_assembler_symbol(externals,hs,EXT_ANY);
  798. if p<>nil then
  799. begin
  800. instr.operands[operandnum].opr.ref.symbol:=p^.sym;
  801. case p^.exttyp of
  802. EXT_BYTE : instr.operands[operandnum].size:=S_B;
  803. EXT_WORD : instr.operands[operandnum].size:=S_W;
  804. EXT_NEAR,EXT_FAR,EXT_PROC,EXT_DWORD,EXT_CODEPTR,EXT_DATAPTR:
  805. instr.operands[operandnum].size:=S_L;
  806. EXT_QWORD : instr.operands[operandnum].size:=S_FL;
  807. EXT_TBYTE : instr.operands[operandnum].size:=S_FX;
  808. else
  809. { this is in the case where the instruction is LEA }
  810. { or something like that, in that case size is not }
  811. { important. }
  812. instr.operands[operandnum].size:=S_NO;
  813. end;
  814. instr.operands[operandnum].hasvar:=true;
  815. SearchDirectVar:=TRUE;
  816. Exit;
  817. end;
  818. end;
  819. {$endif}
  820. procedure TOperand.InitRef;
  821. {*********************************************************************}
  822. { Description: This routine first check if the opcode is of }
  823. { type OPR_NONE, or OPR_REFERENCE , if not it gives out an error. }
  824. { If the operandtype = OPR_NONE or <> OPR_REFERENCE then it sets up }
  825. { the operand type to OPR_REFERENCE, as well as setting up the ref }
  826. { to point to the default segment. }
  827. {*********************************************************************}
  828. Begin
  829. case opr.typ of
  830. OPR_REFERENCE:
  831. exit;
  832. OPR_NONE: ;
  833. else
  834. Message(asmr_e_invalid_operand_type);
  835. end;
  836. opr.typ := OPR_REFERENCE;
  837. reset_reference(opr.ref);
  838. end;
  839. procedure TOperand.BuildOperand;
  840. begin
  841. abstract;
  842. end;
  843. {****************************************************************************
  844. TInstruction
  845. ****************************************************************************}
  846. constructor TInstruction.init;
  847. Begin
  848. Opcode:=A_NONE;
  849. Opsize:=S_NO;
  850. Condition:=C_NONE;
  851. Ops:=0;
  852. InitOperands;
  853. end;
  854. destructor TInstruction.done;
  855. var
  856. i : longint;
  857. Begin
  858. for i:=1 to 3 do
  859. Dispose(Operands[i],Done);
  860. end;
  861. procedure TInstruction.InitOperands;
  862. var
  863. i : longint;
  864. begin
  865. for i:=1 to 3 do
  866. New(Operands[i],init);
  867. end;
  868. Procedure TInstruction.SwapOperands;
  869. Var
  870. p : POperand;
  871. Begin
  872. case Ops of
  873. 2 :
  874. begin
  875. p:=Operands[1];
  876. Operands[1]:=Operands[2];
  877. Operands[2]:=p;
  878. end;
  879. 3 :
  880. begin
  881. p:=Operands[1];
  882. Operands[1]:=Operands[3];
  883. Operands[3]:=p;
  884. end;
  885. end;
  886. end;
  887. procedure TInstruction.ConcatInstruction(p:PAasmOutput);
  888. begin
  889. abstract;
  890. end;
  891. procedure TInstruction.BuildOpcode;
  892. begin
  893. abstract;
  894. end;
  895. {***************************************************************************
  896. TLocalLabel
  897. ***************************************************************************}
  898. constructor TLocalLabel.Init(const n:string);
  899. begin
  900. inherited InitName(n);
  901. lab:=nil;
  902. emitted:=false;
  903. end;
  904. function TLocalLabel.Getpasmlabel:pasmlabel;
  905. begin
  906. if not assigned(lab) then
  907. begin
  908. getlabel(lab);
  909. { this label is forced to be used so it's always written }
  910. inc(lab^.refs);
  911. end;
  912. Getpasmlabel:=lab;
  913. end;
  914. {***************************************************************************
  915. TLocalLabelList
  916. ***************************************************************************}
  917. procedure LocalLabelEmitted(p:PNamedIndexObject);{$ifndef FPC}far;{$endif}
  918. begin
  919. if not PLocalLabel(p)^.emitted then
  920. Message1(asmr_e_unknown_label_identifier,p^.name);
  921. end;
  922. procedure TLocalLabelList.CheckEmitted;
  923. begin
  924. ForEach({$ifndef TP}@{$endif}LocalLabelEmitted)
  925. end;
  926. function CreateLocalLabel(const s: string; var hl: pasmlabel; emit:boolean):boolean;
  927. var
  928. lab : PLocalLabel;
  929. Begin
  930. CreateLocalLabel:=true;
  931. { Check if it already is defined }
  932. lab:=PLocalLabel(LocalLabelList^.Search(s));
  933. if not assigned(lab) then
  934. begin
  935. new(lab,init(s));
  936. LocalLabelList^.Insert(lab);
  937. end;
  938. { set emitted flag and check for dup syms }
  939. if emit then
  940. begin
  941. if lab^.Emitted then
  942. begin
  943. Message1(asmr_e_dup_local_sym,lab^.Name);
  944. CreateLocalLabel:=false;
  945. end;
  946. lab^.Emitted:=true;
  947. end;
  948. hl:=lab^.Getpasmlabel;
  949. end;
  950. {****************************************************************************
  951. Symbol table helper routines
  952. ****************************************************************************}
  953. Function SearchRecordType(const s:string): boolean;
  954. Begin
  955. SearchRecordType:=false;
  956. { Check the constants in symtable }
  957. getsym(s,false);
  958. if srsym <> nil then
  959. Begin
  960. case srsym^.typ of
  961. typesym :
  962. begin
  963. if ptypesym(srsym)^.definition^.deftype in [recorddef,objectdef] then
  964. begin
  965. SearchRecordType:=true;
  966. exit;
  967. end;
  968. end;
  969. end;
  970. end;
  971. end;
  972. Function SearchIConstant(const s:string; var l:longint): boolean;
  973. {**********************************************************************}
  974. { Description: Searches for a CONSTANT of name s in either the local }
  975. { symbol list, then in the global symbol list, and returns the value }
  976. { of that constant in l. Returns TRUE if successfull, if not found, }
  977. { or if the constant is not of correct type, then returns FALSE }
  978. { Remarks: Also handle TRUE and FALSE returning in those cases 1 and 0 }
  979. { respectively. }
  980. {**********************************************************************}
  981. Begin
  982. SearchIConstant:=false;
  983. { check for TRUE or FALSE reserved words first }
  984. if s = 'TRUE' then
  985. Begin
  986. SearchIConstant:=TRUE;
  987. l:=1;
  988. exit;
  989. end;
  990. if s = 'FALSE' then
  991. Begin
  992. SearchIConstant:=TRUE;
  993. l:=0;
  994. exit;
  995. end;
  996. { Check the constants in symtable }
  997. getsym(s,false);
  998. if srsym <> nil then
  999. Begin
  1000. case srsym^.typ of
  1001. constsym :
  1002. begin
  1003. if (pconstsym(srsym)^.consttype in [constord,constint,constchar,constbool]) then
  1004. Begin
  1005. l:=pconstsym(srsym)^.value;
  1006. SearchIConstant:=TRUE;
  1007. exit;
  1008. end;
  1009. end;
  1010. enumsym:
  1011. Begin
  1012. l:=penumsym(srsym)^.value;
  1013. SearchIConstant:=TRUE;
  1014. exit;
  1015. end;
  1016. end;
  1017. end;
  1018. end;
  1019. Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
  1020. { search and returns the offset and size of records/objects of the base }
  1021. { with field name setup in field. }
  1022. { returns FALSE if not found. }
  1023. { used when base is a variable or a typed constant name. }
  1024. var
  1025. st : psymtable;
  1026. harrdef : parraydef;
  1027. sym : psym;
  1028. i : longint;
  1029. base : string;
  1030. Begin
  1031. GetRecordOffsetSize:=FALSE;
  1032. Offset:=0;
  1033. Size:=0;
  1034. i:=pos('.',s);
  1035. if i=0 then
  1036. i:=255;
  1037. base:=Copy(s,1,i-1);
  1038. delete(s,1,i);
  1039. if base='SELF' then
  1040. st:=procinfo^._class^.symtable
  1041. else
  1042. begin
  1043. getsym(base,false);
  1044. sym:=srsym;
  1045. st:=nil;
  1046. { we can start with a var,type,typedconst }
  1047. case sym^.typ of
  1048. varsym :
  1049. begin
  1050. case pvarsym(sym)^.definition^.deftype of
  1051. recorddef :
  1052. st:=precorddef(pvarsym(sym)^.definition)^.symtable;
  1053. objectdef :
  1054. st:=pobjectdef(pvarsym(sym)^.definition)^.symtable;
  1055. end;
  1056. end;
  1057. typesym :
  1058. begin
  1059. case ptypesym(sym)^.definition^.deftype of
  1060. recorddef :
  1061. st:=precorddef(ptypesym(sym)^.definition)^.symtable;
  1062. objectdef :
  1063. st:=pobjectdef(ptypesym(sym)^.definition)^.symtable;
  1064. end;
  1065. end;
  1066. typedconstsym :
  1067. begin
  1068. case pvarsym(sym)^.definition^.deftype of
  1069. recorddef :
  1070. st:=precorddef(ptypedconstsym(sym)^.definition)^.symtable;
  1071. objectdef :
  1072. st:=pobjectdef(ptypedconstsym(sym)^.definition)^.symtable;
  1073. end;
  1074. end;
  1075. end;
  1076. end;
  1077. { now walk all recordsymtables }
  1078. while assigned(st) and (s<>'') do
  1079. begin
  1080. { load next field in base }
  1081. i:=pos('.',s);
  1082. if i=0 then
  1083. i:=255;
  1084. base:=Copy(s,1,i-1);
  1085. delete(s,1,i);
  1086. sym:=st^.search(base);
  1087. if not assigned(sym) then
  1088. begin
  1089. GetRecordOffsetSize:=false;
  1090. exit;
  1091. end;
  1092. st:=nil;
  1093. case sym^.typ of
  1094. varsym :
  1095. begin
  1096. inc(Offset,pvarsym(sym)^.address);
  1097. Size:=PVarsym(sym)^.getsize;
  1098. case pvarsym(sym)^.definition^.deftype of
  1099. arraydef :
  1100. begin
  1101. { for arrays try to get the element size, take care of
  1102. multiple indexes }
  1103. harrdef:=Parraydef(PVarsym(sym)^.definition);
  1104. while assigned(harrdef^.definition) and
  1105. (harrdef^.definition^.deftype=arraydef) do
  1106. harrdef:=parraydef(harrdef^.definition);
  1107. size:=harrdef^.elesize;
  1108. end;
  1109. recorddef :
  1110. st:=precorddef(pvarsym(sym)^.definition)^.symtable;
  1111. objectdef :
  1112. st:=pobjectdef(pvarsym(sym)^.definition)^.symtable;
  1113. end;
  1114. end;
  1115. end;
  1116. end;
  1117. GetRecordOffsetSize:=(s='');
  1118. end;
  1119. Function SearchLabel(const s: string; var hl: pasmlabel;emit:boolean): boolean;
  1120. var
  1121. sym : psym;
  1122. hs : string;
  1123. Begin
  1124. hl:=nil;
  1125. SearchLabel:=false;
  1126. { Check for pascal labels, which are case insensetive }
  1127. hs:=upper(s);
  1128. getsym(hs,false);
  1129. sym:=srsym;
  1130. if sym=nil then
  1131. exit;
  1132. case sym^.typ of
  1133. labelsym :
  1134. begin
  1135. hl:=plabelsym(sym)^.lab;
  1136. if emit then
  1137. plabelsym(sym)^.defined:=true;
  1138. SearchLabel:=true;
  1139. exit;
  1140. end;
  1141. end;
  1142. end;
  1143. {*************************************************************************}
  1144. { Instruction Generation Utilities }
  1145. {*************************************************************************}
  1146. Procedure ConcatString(p : paasmoutput;s:string);
  1147. {*********************************************************************}
  1148. { PROCEDURE ConcatString(s:string); }
  1149. { Description: This routine adds the character chain pointed to in }
  1150. { s to the instruction linked list. }
  1151. {*********************************************************************}
  1152. Var
  1153. pc: PChar;
  1154. Begin
  1155. getmem(pc,length(s)+1);
  1156. p^.concat(new(pai_string,init_length_pchar(strpcopy(pc,s),length(s))));
  1157. end;
  1158. Procedure ConcatPasString(p : paasmoutput;s:string);
  1159. {*********************************************************************}
  1160. { PROCEDURE ConcatPasString(s:string); }
  1161. { Description: This routine adds the character chain pointed to in }
  1162. { s to the instruction linked list, contrary to ConcatString it }
  1163. { uses a pascal style string, so it conserves null characters. }
  1164. {*********************************************************************}
  1165. Begin
  1166. p^.concat(new(pai_string,init(s)));
  1167. end;
  1168. Procedure ConcatDirect(p : paasmoutput;s:string);
  1169. {*********************************************************************}
  1170. { PROCEDURE ConcatDirect(s:string) }
  1171. { Description: This routine output the string directly to the asm }
  1172. { output, it is only sed when writing special labels in AT&T mode, }
  1173. { and should not be used without due consideration, since it may }
  1174. { cause problems. }
  1175. {*********************************************************************}
  1176. Var
  1177. pc: PChar;
  1178. Begin
  1179. getmem(pc,length(s)+1);
  1180. p^.concat(new(pai_direct,init(strpcopy(pc,s))));
  1181. end;
  1182. Procedure ConcatConstant(p: paasmoutput; value: longint; maxvalue: longint);
  1183. {*********************************************************************}
  1184. { PROCEDURE ConcatConstant(value: longint; maxvalue: longint); }
  1185. { Description: This routine adds the value constant to the current }
  1186. { instruction linked list. }
  1187. { maxvalue -> indicates the size of the data to initialize: }
  1188. { $ff -> create a byte node. }
  1189. { $ffff -> create a word node. }
  1190. { $ffffffff -> create a dword node. }
  1191. {*********************************************************************}
  1192. Begin
  1193. if (maxvalue <> $ffffffff) and (value > maxvalue) then
  1194. Begin
  1195. Message(asmr_e_constant_out_of_bounds);
  1196. { assuming a value of maxvalue }
  1197. value:=maxvalue;
  1198. end;
  1199. if maxvalue = $ff then
  1200. p^.concat(new(pai_const,init_8bit(byte(value))))
  1201. else
  1202. if maxvalue = $ffff then
  1203. p^.concat(new(pai_const,init_16bit(word(value))))
  1204. else
  1205. if maxvalue = $ffffffff then
  1206. p^.concat(new(pai_const,init_32bit(longint(value))));
  1207. end;
  1208. Procedure ConcatConstSymbol(p : paasmoutput;const sym:string;l:longint);
  1209. begin
  1210. p^.concat(new(pai_const_symbol,initname_offset(sym,l)));
  1211. end;
  1212. Procedure ConcatRealConstant(p : paasmoutput;value: bestreal; real_typ : tfloattype);
  1213. {***********************************************************************}
  1214. { PROCEDURE ConcatRealConstant(value: bestreal; real_typ : tfloattype); }
  1215. { Description: This routine adds the value constant to the current }
  1216. { instruction linked list. }
  1217. { real_typ -> indicates the type of the real data to initialize: }
  1218. { s32real -> create a single node. }
  1219. { s64real -> create a double node. }
  1220. { s80real -> create an extended node. }
  1221. { s64bit -> create a comp node. }
  1222. { f32bit -> create a fixed node. (not used normally) }
  1223. {***********************************************************************}
  1224. Begin
  1225. case real_typ of
  1226. s32real : p^.concat(new(pai_real_32bit,init(value)));
  1227. s64real : p^.concat(new(pai_real_64bit,init(value)));
  1228. s80real : p^.concat(new(pai_real_80bit,init(value)));
  1229. s64comp : p^.concat(new(pai_comp_64bit,init(value)));
  1230. f32bit : p^.concat(new(pai_const,init_32bit(trunc(value*$10000))));
  1231. end;
  1232. end;
  1233. Procedure ConcatLabel(p: paasmoutput;var l : pasmlabel);
  1234. {*********************************************************************}
  1235. { PROCEDURE ConcatLabel }
  1236. { Description: This routine either emits a label or a labeled }
  1237. { instruction to the linked list of instructions. }
  1238. {*********************************************************************}
  1239. begin
  1240. p^.concat(new(pai_label,init(l)));
  1241. end;
  1242. procedure ConcatAlign(p:paasmoutput;l:longint);
  1243. {*********************************************************************}
  1244. { PROCEDURE ConcatPublic }
  1245. { Description: This routine emits an global definition to the }
  1246. { linked list of instructions.(used by AT&T styled asm) }
  1247. {*********************************************************************}
  1248. begin
  1249. p^.concat(new(pai_align,init(l)));
  1250. end;
  1251. procedure ConcatPublic(p:paasmoutput;const s : string);
  1252. {*********************************************************************}
  1253. { PROCEDURE ConcatPublic }
  1254. { Description: This routine emits an global definition to the }
  1255. { linked list of instructions.(used by AT&T styled asm) }
  1256. {*********************************************************************}
  1257. begin
  1258. p^.concat(new(pai_symbol,initname_global(s,0)));
  1259. end;
  1260. procedure ConcatLocal(p:paasmoutput;const s : string);
  1261. {*********************************************************************}
  1262. { PROCEDURE ConcatLocal }
  1263. { Description: This routine emits an local definition to the }
  1264. { linked list of instructions. }
  1265. {*********************************************************************}
  1266. begin
  1267. p^.concat(new(pai_symbol,initname(s,0)));
  1268. end;
  1269. Procedure ConcatGlobalBss(const s : string;size : longint);
  1270. {*********************************************************************}
  1271. { PROCEDURE ConcatGlobalBss }
  1272. { Description: This routine emits an global datablock to the }
  1273. { linked list of instructions. }
  1274. {*********************************************************************}
  1275. begin
  1276. bsssegment^.concat(new(pai_datablock,init_global(s,size)));
  1277. end;
  1278. Procedure ConcatLocalBss(const s : string;size : longint);
  1279. {*********************************************************************}
  1280. { PROCEDURE ConcatLocalBss }
  1281. { Description: This routine emits a local datablcok to the }
  1282. { linked list of instructions. }
  1283. {*********************************************************************}
  1284. begin
  1285. bsssegment^.concat(new(pai_datablock,init(s,size)));
  1286. end;
  1287. end.
  1288. {
  1289. $Log$
  1290. Revision 1.28 1999-11-06 14:34:26 peter
  1291. * truncated log to 20 revs
  1292. Revision 1.27 1999/09/27 23:44:58 peter
  1293. * procinfo is now a pointer
  1294. * support for result setting in sub procedure
  1295. Revision 1.26 1999/09/08 16:04:04 peter
  1296. * better support for object fields and more error checks for
  1297. field accesses which create buggy code
  1298. Revision 1.25 1999/09/04 20:29:11 florian
  1299. * bug 577 fixed
  1300. Revision 1.24 1999/08/27 14:37:50 peter
  1301. * fixed crash with typedconst array
  1302. Revision 1.23 1999/08/13 21:28:38 peter
  1303. * more reference types support
  1304. * arraydef size returns elementsize, also for multiple indexing array
  1305. Revision 1.22 1999/08/04 00:23:28 florian
  1306. * renamed i386asm and i386base to cpuasm and cpubase
  1307. Revision 1.21 1999/08/03 22:03:12 peter
  1308. * moved bitmask constants to sets
  1309. * some other type/const renamings
  1310. Revision 1.20 1999/07/29 20:54:06 peter
  1311. * write .size also
  1312. Revision 1.19 1999/06/02 22:44:17 pierre
  1313. * previous wrong log corrected
  1314. Revision 1.18 1999/06/02 22:25:47 pierre
  1315. * changed $ifdef FPC @ into $ifndef TP
  1316. Revision 1.17 1999/05/27 19:45:01 peter
  1317. * removed oldasm
  1318. * plabel -> pasmlabel
  1319. * -a switches to source writing automaticly
  1320. * assembler readers OOPed
  1321. * asmsymbol automaticly external
  1322. * jumptables and other label fixes for asm readers
  1323. Revision 1.16 1999/05/21 13:55:18 peter
  1324. * NEWLAB for label as symbol
  1325. Revision 1.15 1999/05/12 00:17:11 peter
  1326. * fixed error which was shown for all 32bit consts
  1327. Revision 1.14 1999/05/11 16:27:23 peter
  1328. * support for pointerdef
  1329. Revision 1.13 1999/05/06 09:05:27 peter
  1330. * generic write_float and str_float
  1331. * fixed constant float conversions
  1332. Revision 1.12 1999/05/05 22:22:04 peter
  1333. * updated messages
  1334. Revision 1.11 1999/05/02 22:41:57 peter
  1335. * moved section names to systems
  1336. * fixed nasm,intel writer
  1337. Revision 1.10 1999/05/01 13:24:41 peter
  1338. * merged nasm compiler
  1339. * old asm moved to oldasm/
  1340. Revision 1.8 1999/04/26 23:26:19 peter
  1341. * redesigned record offset parsing to support nested records
  1342. * normal compiler uses the redesigned SetupVar()
  1343. Revision 1.7 1999/04/14 09:07:48 peter
  1344. * asm reader improvements
  1345. }