rautils.pas 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489
  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.ref.offset:=procinfo.ESI_offset;
  612. opr.ref.base:=procinfo.framepointer;
  613. SetupSelf:=true;
  614. end
  615. else
  616. Message(asmr_e_cannot_use_SELF_outside_a_method);
  617. end;
  618. Function TOperand.SetupOldEBP:boolean;
  619. Begin
  620. SetupOldEBP:=false;
  621. if lexlevel>normal_function_level then
  622. Begin
  623. opr.typ:=OPR_REFERENCE;
  624. opr.ref.offset:=procinfo.framepointer_offset;
  625. opr.ref.base:=procinfo.framepointer;
  626. SetupOldEBP:=true;
  627. end
  628. else
  629. Message(asmr_e_cannot_use_OLDEBP_outside_nested_procedure);
  630. end;
  631. Function TOperand.SetupVar(const hs:string): Boolean;
  632. { search and sets up the correct fields in the Instr record }
  633. { for the NON-constant identifier passed to the routine. }
  634. { if not found returns FALSE. }
  635. var
  636. sym : psym;
  637. harrdef : parraydef;
  638. Begin
  639. SetupVar:=false;
  640. { are we in a routine ? }
  641. getsym(hs,false);
  642. sym:=srsym;
  643. if sym=nil then
  644. exit;
  645. case sym^.typ of
  646. varsym :
  647. begin
  648. { we always assume in asm statements that }
  649. { that the variable is valid. }
  650. pvarsym(sym)^.varstate:=vs_used;
  651. inc(pvarsym(sym)^.refs);
  652. case pvarsym(sym)^.owner^.symtabletype of
  653. unitsymtable,
  654. globalsymtable,
  655. staticsymtable :
  656. opr.ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname);
  657. parasymtable :
  658. begin
  659. opr.ref.base:=procinfo.framepointer;
  660. opr.ref.offset:=pvarsym(sym)^.address;
  661. opr.ref.offsetfixup:=aktprocsym^.definition^.parast^.address_fixup;
  662. opr.ref.options:=ref_parafixup;
  663. end;
  664. localsymtable :
  665. begin
  666. if (vo_is_external in pvarsym(sym)^.varoptions) then
  667. opr.ref.symbol:=newasmsymbol(pvarsym(sym)^.mangledname)
  668. else
  669. begin
  670. opr.ref.base:=procinfo.framepointer;
  671. opr.ref.offset:=-(pvarsym(sym)^.address);
  672. opr.ref.options:=ref_localfixup;
  673. opr.ref.offsetfixup:=aktprocsym^.definition^.localst^.address_fixup;
  674. end;
  675. end;
  676. end;
  677. case pvarsym(sym)^.definition^.deftype of
  678. orddef,
  679. enumdef,
  680. pointerdef,
  681. floatdef :
  682. SetSize(pvarsym(sym)^.getsize);
  683. arraydef :
  684. begin
  685. { for arrays try to get the element size, take care of
  686. multiple indexes }
  687. harrdef:=Parraydef(PVarsym(sym)^.definition);
  688. while assigned(harrdef^.definition) and
  689. (harrdef^.definition^.deftype=arraydef) do
  690. harrdef:=parraydef(harrdef^.definition);
  691. SetSize(harrdef^.elesize);
  692. end;
  693. end;
  694. hasvar:=true;
  695. SetupVar:=true;
  696. Exit;
  697. end;
  698. typedconstsym :
  699. begin
  700. opr.ref.symbol:=newasmsymbol(ptypedconstsym(sym)^.mangledname);
  701. case ptypedconstsym(sym)^.definition^.deftype of
  702. orddef,
  703. enumdef,
  704. pointerdef,
  705. floatdef :
  706. SetSize(ptypedconstsym(sym)^.getsize);
  707. arraydef :
  708. begin
  709. { for arrays try to get the element size, take care of
  710. multiple indexes }
  711. harrdef:=Parraydef(PTypedConstSym(sym)^.definition);
  712. while assigned(harrdef^.definition) and
  713. (harrdef^.definition^.deftype=arraydef) do
  714. harrdef:=parraydef(harrdef^.definition);
  715. SetSize(harrdef^.elesize);
  716. end;
  717. end;
  718. hasvar:=true;
  719. SetupVar:=true;
  720. Exit;
  721. end;
  722. constsym :
  723. begin
  724. if pconstsym(sym)^.consttype in [constint,constchar,constbool] then
  725. begin
  726. opr.typ:=OPR_CONSTANT;
  727. opr.val:=pconstsym(sym)^.value;
  728. hasvar:=true;
  729. SetupVar:=true;
  730. Exit;
  731. end;
  732. end;
  733. typesym :
  734. begin
  735. if ptypesym(sym)^.definition^.deftype in [recorddef,objectdef] then
  736. begin
  737. opr.typ:=OPR_CONSTANT;
  738. opr.val:=0;
  739. hasvar:=true;
  740. SetupVar:=TRUE;
  741. Exit;
  742. end;
  743. end;
  744. procsym :
  745. begin
  746. if assigned(pprocsym(sym)^.definition^.nextoverloaded) then
  747. Message(asmr_w_calling_overload_func);
  748. opr.typ:=OPR_SYMBOL;
  749. opr.symbol:=newasmsymbol(pprocsym(sym)^.definition^.mangledname);
  750. hasvar:=true;
  751. SetupVar:=TRUE;
  752. Exit;
  753. end;
  754. else
  755. begin
  756. Message(asmr_e_unsupported_symbol_type);
  757. exit;
  758. end;
  759. end;
  760. end;
  761. { looks for internal names of variables and routines }
  762. Function TOperand.SetupDirectVar(const hs:string): Boolean;
  763. {$ifndef OLDDIRECTVAR}
  764. var
  765. p : pasmsymbol;
  766. begin
  767. SetupDirectVar:=false;
  768. p:=getasmsymbol(hs);
  769. if assigned(p) then
  770. begin
  771. opr.ref.symbol:=p;
  772. hasvar:=true;
  773. SetupDirectVar:=true;
  774. end;
  775. end;
  776. {$else}
  777. var
  778. p : pai_external;
  779. Begin
  780. SearchDirectVar:=false;
  781. { search in the list of internals }
  782. p:=search_assembler_symbol(internals,hs,EXT_ANY);
  783. if p=nil then
  784. p:=search_assembler_symbol(externals,hs,EXT_ANY);
  785. if p<>nil then
  786. begin
  787. instr.operands[operandnum].opr.ref.symbol:=p^.sym;
  788. case p^.exttyp of
  789. EXT_BYTE : instr.operands[operandnum].size:=S_B;
  790. EXT_WORD : instr.operands[operandnum].size:=S_W;
  791. EXT_NEAR,EXT_FAR,EXT_PROC,EXT_DWORD,EXT_CODEPTR,EXT_DATAPTR:
  792. instr.operands[operandnum].size:=S_L;
  793. EXT_QWORD : instr.operands[operandnum].size:=S_FL;
  794. EXT_TBYTE : instr.operands[operandnum].size:=S_FX;
  795. else
  796. { this is in the case where the instruction is LEA }
  797. { or something like that, in that case size is not }
  798. { important. }
  799. instr.operands[operandnum].size:=S_NO;
  800. end;
  801. instr.operands[operandnum].hasvar:=true;
  802. SearchDirectVar:=TRUE;
  803. Exit;
  804. end;
  805. end;
  806. {$endif}
  807. procedure TOperand.InitRef;
  808. {*********************************************************************}
  809. { Description: This routine first check if the opcode is of }
  810. { type OPR_NONE, or OPR_REFERENCE , if not it gives out an error. }
  811. { If the operandtype = OPR_NONE or <> OPR_REFERENCE then it sets up }
  812. { the operand type to OPR_REFERENCE, as well as setting up the ref }
  813. { to point to the default segment. }
  814. {*********************************************************************}
  815. Begin
  816. case opr.typ of
  817. OPR_REFERENCE:
  818. exit;
  819. OPR_NONE: ;
  820. else
  821. Message(asmr_e_invalid_operand_type);
  822. end;
  823. opr.typ := OPR_REFERENCE;
  824. reset_reference(opr.ref);
  825. end;
  826. procedure TOperand.BuildOperand;
  827. begin
  828. abstract;
  829. end;
  830. {****************************************************************************
  831. TInstruction
  832. ****************************************************************************}
  833. constructor TInstruction.init;
  834. Begin
  835. Opcode:=A_NONE;
  836. Opsize:=S_NO;
  837. Condition:=C_NONE;
  838. Ops:=0;
  839. InitOperands;
  840. end;
  841. destructor TInstruction.done;
  842. var
  843. i : longint;
  844. Begin
  845. for i:=1 to 3 do
  846. Dispose(Operands[i],Done);
  847. end;
  848. procedure TInstruction.InitOperands;
  849. var
  850. i : longint;
  851. begin
  852. for i:=1 to 3 do
  853. New(Operands[i],init);
  854. end;
  855. Procedure TInstruction.SwapOperands;
  856. Var
  857. p : POperand;
  858. Begin
  859. case Ops of
  860. 2 :
  861. begin
  862. p:=Operands[1];
  863. Operands[1]:=Operands[2];
  864. Operands[2]:=p;
  865. end;
  866. 3 :
  867. begin
  868. p:=Operands[1];
  869. Operands[1]:=Operands[3];
  870. Operands[3]:=p;
  871. end;
  872. end;
  873. end;
  874. procedure TInstruction.ConcatInstruction(p:PAasmOutput);
  875. begin
  876. abstract;
  877. end;
  878. procedure TInstruction.BuildOpcode;
  879. begin
  880. abstract;
  881. end;
  882. {***************************************************************************
  883. TLocalLabel
  884. ***************************************************************************}
  885. constructor TLocalLabel.Init(const n:string);
  886. begin
  887. inherited InitName(n);
  888. lab:=nil;
  889. emitted:=false;
  890. end;
  891. function TLocalLabel.Getpasmlabel:pasmlabel;
  892. begin
  893. if not assigned(lab) then
  894. begin
  895. getlabel(lab);
  896. { this label is forced to be used so it's always written }
  897. inc(lab^.refs);
  898. end;
  899. Getpasmlabel:=lab;
  900. end;
  901. {***************************************************************************
  902. TLocalLabelList
  903. ***************************************************************************}
  904. procedure LocalLabelEmitted(p:PNamedIndexObject);{$ifndef FPC}far;{$endif}
  905. begin
  906. if not PLocalLabel(p)^.emitted then
  907. Message1(asmr_e_unknown_label_identifier,p^.name);
  908. end;
  909. procedure TLocalLabelList.CheckEmitted;
  910. begin
  911. ForEach({$ifndef TP}@{$endif}LocalLabelEmitted)
  912. end;
  913. function CreateLocalLabel(const s: string; var hl: pasmlabel; emit:boolean):boolean;
  914. var
  915. lab : PLocalLabel;
  916. Begin
  917. CreateLocalLabel:=true;
  918. { Check if it already is defined }
  919. lab:=PLocalLabel(LocalLabelList^.Search(s));
  920. if not assigned(lab) then
  921. begin
  922. new(lab,init(s));
  923. LocalLabelList^.Insert(lab);
  924. end;
  925. { set emitted flag and check for dup syms }
  926. if emit then
  927. begin
  928. if lab^.Emitted then
  929. begin
  930. Message1(asmr_e_dup_local_sym,lab^.Name);
  931. CreateLocalLabel:=false;
  932. end;
  933. lab^.Emitted:=true;
  934. end;
  935. hl:=lab^.Getpasmlabel;
  936. end;
  937. {****************************************************************************
  938. Symbol table helper routines
  939. ****************************************************************************}
  940. Function SearchRecordType(const s:string): boolean;
  941. Begin
  942. SearchRecordType:=false;
  943. { Check the constants in symtable }
  944. getsym(s,false);
  945. if srsym <> nil then
  946. Begin
  947. case srsym^.typ of
  948. typesym :
  949. begin
  950. if ptypesym(srsym)^.definition^.deftype in [recorddef,objectdef] then
  951. begin
  952. SearchRecordType:=true;
  953. exit;
  954. end;
  955. end;
  956. end;
  957. end;
  958. end;
  959. Function SearchIConstant(const s:string; var l:longint): boolean;
  960. {**********************************************************************}
  961. { Description: Searches for a CONSTANT of name s in either the local }
  962. { symbol list, then in the global symbol list, and returns the value }
  963. { of that constant in l. Returns TRUE if successfull, if not found, }
  964. { or if the constant is not of correct type, then returns FALSE }
  965. { Remarks: Also handle TRUE and FALSE returning in those cases 1 and 0 }
  966. { respectively. }
  967. {**********************************************************************}
  968. Begin
  969. SearchIConstant:=false;
  970. { check for TRUE or FALSE reserved words first }
  971. if s = 'TRUE' then
  972. Begin
  973. SearchIConstant:=TRUE;
  974. l:=1;
  975. exit;
  976. end;
  977. if s = 'FALSE' then
  978. Begin
  979. SearchIConstant:=TRUE;
  980. l:=0;
  981. exit;
  982. end;
  983. { Check the constants in symtable }
  984. getsym(s,false);
  985. if srsym <> nil then
  986. Begin
  987. case srsym^.typ of
  988. constsym :
  989. begin
  990. if (pconstsym(srsym)^.consttype in [constord,constint,constchar,constbool]) then
  991. Begin
  992. l:=pconstsym(srsym)^.value;
  993. SearchIConstant:=TRUE;
  994. exit;
  995. end;
  996. end;
  997. end;
  998. end;
  999. end;
  1000. Function GetRecordOffsetSize(s:string;Var Offset: longint;var Size:longint):boolean;
  1001. { search and returns the offset and size of records/objects of the base }
  1002. { with field name setup in field. }
  1003. { returns FALSE if not found. }
  1004. { used when base is a variable or a typed constant name. }
  1005. var
  1006. st : psymtable;
  1007. harrdef : parraydef;
  1008. sym : psym;
  1009. i : longint;
  1010. base : string;
  1011. Begin
  1012. GetRecordOffsetSize:=FALSE;
  1013. Offset:=0;
  1014. Size:=0;
  1015. i:=pos('.',s);
  1016. if i=0 then
  1017. i:=255;
  1018. base:=Copy(s,1,i-1);
  1019. delete(s,1,i);
  1020. getsym(base,false);
  1021. sym:=srsym;
  1022. st:=nil;
  1023. { we can start with a var,type,typedconst }
  1024. case sym^.typ of
  1025. varsym :
  1026. begin
  1027. case pvarsym(sym)^.definition^.deftype of
  1028. recorddef :
  1029. st:=precorddef(pvarsym(sym)^.definition)^.symtable;
  1030. objectdef :
  1031. st:=pobjectdef(pvarsym(sym)^.definition)^.symtable;
  1032. end;
  1033. end;
  1034. typesym :
  1035. begin
  1036. case ptypesym(sym)^.definition^.deftype of
  1037. recorddef :
  1038. st:=precorddef(ptypesym(sym)^.definition)^.symtable;
  1039. objectdef :
  1040. st:=pobjectdef(ptypesym(sym)^.definition)^.symtable;
  1041. end;
  1042. end;
  1043. typedconstsym :
  1044. begin
  1045. case pvarsym(sym)^.definition^.deftype of
  1046. recorddef :
  1047. st:=precorddef(ptypedconstsym(sym)^.definition)^.symtable;
  1048. objectdef :
  1049. st:=pobjectdef(ptypedconstsym(sym)^.definition)^.symtable;
  1050. end;
  1051. end;
  1052. end;
  1053. { now walk all recordsymtables }
  1054. while assigned(st) and (s<>'') do
  1055. begin
  1056. { load next field in base }
  1057. i:=pos('.',s);
  1058. if i=0 then
  1059. i:=255;
  1060. base:=Copy(s,1,i-1);
  1061. delete(s,1,i);
  1062. sym:=st^.search(base);
  1063. st:=nil;
  1064. case sym^.typ of
  1065. varsym :
  1066. begin
  1067. inc(Offset,pvarsym(sym)^.address);
  1068. Size:=PVarsym(sym)^.getsize;
  1069. case pvarsym(sym)^.definition^.deftype of
  1070. arraydef :
  1071. begin
  1072. { for arrays try to get the element size, take care of
  1073. multiple indexes }
  1074. harrdef:=Parraydef(PVarsym(sym)^.definition);
  1075. while assigned(harrdef^.definition) and
  1076. (harrdef^.definition^.deftype=arraydef) do
  1077. harrdef:=parraydef(harrdef^.definition);
  1078. size:=harrdef^.elesize;
  1079. end;
  1080. recorddef :
  1081. st:=precorddef(pvarsym(sym)^.definition)^.symtable;
  1082. objectdef :
  1083. st:=pobjectdef(pvarsym(sym)^.definition)^.symtable;
  1084. end;
  1085. end;
  1086. end;
  1087. end;
  1088. GetRecordOffsetSize:=(s='');
  1089. end;
  1090. Function SearchLabel(const s: string; var hl: pasmlabel;emit:boolean): boolean;
  1091. var
  1092. sym : psym;
  1093. hs : string;
  1094. Begin
  1095. hl:=nil;
  1096. SearchLabel:=false;
  1097. { Check for pascal labels, which are case insensetive }
  1098. hs:=upper(s);
  1099. getsym(hs,false);
  1100. sym:=srsym;
  1101. if sym=nil then
  1102. exit;
  1103. case sym^.typ of
  1104. labelsym :
  1105. begin
  1106. hl:=plabelsym(sym)^.lab;
  1107. if emit then
  1108. plabelsym(sym)^.defined:=true;
  1109. SearchLabel:=true;
  1110. exit;
  1111. end;
  1112. end;
  1113. end;
  1114. {*************************************************************************}
  1115. { Instruction Generation Utilities }
  1116. {*************************************************************************}
  1117. Procedure ConcatString(p : paasmoutput;s:string);
  1118. {*********************************************************************}
  1119. { PROCEDURE ConcatString(s:string); }
  1120. { Description: This routine adds the character chain pointed to in }
  1121. { s to the instruction linked list. }
  1122. {*********************************************************************}
  1123. Var
  1124. pc: PChar;
  1125. Begin
  1126. getmem(pc,length(s)+1);
  1127. p^.concat(new(pai_string,init_length_pchar(strpcopy(pc,s),length(s))));
  1128. end;
  1129. Procedure ConcatPasString(p : paasmoutput;s:string);
  1130. {*********************************************************************}
  1131. { PROCEDURE ConcatPasString(s:string); }
  1132. { Description: This routine adds the character chain pointed to in }
  1133. { s to the instruction linked list, contrary to ConcatString it }
  1134. { uses a pascal style string, so it conserves null characters. }
  1135. {*********************************************************************}
  1136. Begin
  1137. p^.concat(new(pai_string,init(s)));
  1138. end;
  1139. Procedure ConcatDirect(p : paasmoutput;s:string);
  1140. {*********************************************************************}
  1141. { PROCEDURE ConcatDirect(s:string) }
  1142. { Description: This routine output the string directly to the asm }
  1143. { output, it is only sed when writing special labels in AT&T mode, }
  1144. { and should not be used without due consideration, since it may }
  1145. { cause problems. }
  1146. {*********************************************************************}
  1147. Var
  1148. pc: PChar;
  1149. Begin
  1150. getmem(pc,length(s)+1);
  1151. p^.concat(new(pai_direct,init(strpcopy(pc,s))));
  1152. end;
  1153. Procedure ConcatConstant(p: paasmoutput; value: longint; maxvalue: longint);
  1154. {*********************************************************************}
  1155. { PROCEDURE ConcatConstant(value: longint; maxvalue: longint); }
  1156. { Description: This routine adds the value constant to the current }
  1157. { instruction linked list. }
  1158. { maxvalue -> indicates the size of the data to initialize: }
  1159. { $ff -> create a byte node. }
  1160. { $ffff -> create a word node. }
  1161. { $ffffffff -> create a dword node. }
  1162. {*********************************************************************}
  1163. Begin
  1164. if (maxvalue <> $ffffffff) and (value > maxvalue) then
  1165. Begin
  1166. Message(asmr_e_constant_out_of_bounds);
  1167. { assuming a value of maxvalue }
  1168. value:=maxvalue;
  1169. end;
  1170. if maxvalue = $ff then
  1171. p^.concat(new(pai_const,init_8bit(byte(value))))
  1172. else
  1173. if maxvalue = $ffff then
  1174. p^.concat(new(pai_const,init_16bit(word(value))))
  1175. else
  1176. if maxvalue = $ffffffff then
  1177. p^.concat(new(pai_const,init_32bit(longint(value))));
  1178. end;
  1179. Procedure ConcatConstSymbol(p : paasmoutput;const sym:string;l:longint);
  1180. begin
  1181. p^.concat(new(pai_const_symbol,initname_offset(sym,l)));
  1182. end;
  1183. Procedure ConcatRealConstant(p : paasmoutput;value: bestreal; real_typ : tfloattype);
  1184. {***********************************************************************}
  1185. { PROCEDURE ConcatRealConstant(value: bestreal; real_typ : tfloattype); }
  1186. { Description: This routine adds the value constant to the current }
  1187. { instruction linked list. }
  1188. { real_typ -> indicates the type of the real data to initialize: }
  1189. { s32real -> create a single node. }
  1190. { s64real -> create a double node. }
  1191. { s80real -> create an extended node. }
  1192. { s64bit -> create a comp node. }
  1193. { f32bit -> create a fixed node. (not used normally) }
  1194. {***********************************************************************}
  1195. Begin
  1196. case real_typ of
  1197. s32real : p^.concat(new(pai_real_32bit,init(value)));
  1198. s64real : p^.concat(new(pai_real_64bit,init(value)));
  1199. s80real : p^.concat(new(pai_real_80bit,init(value)));
  1200. s64comp : p^.concat(new(pai_comp_64bit,init(value)));
  1201. f32bit : p^.concat(new(pai_const,init_32bit(trunc(value*$10000))));
  1202. end;
  1203. end;
  1204. Procedure ConcatLabel(p: paasmoutput;var l : pasmlabel);
  1205. {*********************************************************************}
  1206. { PROCEDURE ConcatLabel }
  1207. { Description: This routine either emits a label or a labeled }
  1208. { instruction to the linked list of instructions. }
  1209. {*********************************************************************}
  1210. begin
  1211. p^.concat(new(pai_label,init(l)));
  1212. end;
  1213. procedure ConcatAlign(p:paasmoutput;l:longint);
  1214. {*********************************************************************}
  1215. { PROCEDURE ConcatPublic }
  1216. { Description: This routine emits an global definition to the }
  1217. { linked list of instructions.(used by AT&T styled asm) }
  1218. {*********************************************************************}
  1219. begin
  1220. p^.concat(new(pai_align,init(l)));
  1221. end;
  1222. procedure ConcatPublic(p:paasmoutput;const s : string);
  1223. {*********************************************************************}
  1224. { PROCEDURE ConcatPublic }
  1225. { Description: This routine emits an global definition to the }
  1226. { linked list of instructions.(used by AT&T styled asm) }
  1227. {*********************************************************************}
  1228. begin
  1229. p^.concat(new(pai_symbol,initname_global(s,0)));
  1230. end;
  1231. procedure ConcatLocal(p:paasmoutput;const s : string);
  1232. {*********************************************************************}
  1233. { PROCEDURE ConcatLocal }
  1234. { Description: This routine emits an local definition to the }
  1235. { linked list of instructions. }
  1236. {*********************************************************************}
  1237. begin
  1238. p^.concat(new(pai_symbol,initname(s,0)));
  1239. end;
  1240. Procedure ConcatGlobalBss(const s : string;size : longint);
  1241. {*********************************************************************}
  1242. { PROCEDURE ConcatGlobalBss }
  1243. { Description: This routine emits an global datablock to the }
  1244. { linked list of instructions. }
  1245. {*********************************************************************}
  1246. begin
  1247. bsssegment^.concat(new(pai_datablock,init_global(s,size)));
  1248. end;
  1249. Procedure ConcatLocalBss(const s : string;size : longint);
  1250. {*********************************************************************}
  1251. { PROCEDURE ConcatLocalBss }
  1252. { Description: This routine emits a local datablcok to the }
  1253. { linked list of instructions. }
  1254. {*********************************************************************}
  1255. begin
  1256. bsssegment^.concat(new(pai_datablock,init(s,size)));
  1257. end;
  1258. end.
  1259. {
  1260. $Log$
  1261. Revision 1.24 1999-08-27 14:37:50 peter
  1262. * fixed crash with typedconst array
  1263. Revision 1.23 1999/08/13 21:28:38 peter
  1264. * more reference types support
  1265. * arraydef size returns elementsize, also for multiple indexing array
  1266. Revision 1.22 1999/08/04 00:23:28 florian
  1267. * renamed i386asm and i386base to cpuasm and cpubase
  1268. Revision 1.21 1999/08/03 22:03:12 peter
  1269. * moved bitmask constants to sets
  1270. * some other type/const renamings
  1271. Revision 1.20 1999/07/29 20:54:06 peter
  1272. * write .size also
  1273. Revision 1.19 1999/06/02 22:44:17 pierre
  1274. * previous wrong log corrected
  1275. Revision 1.18 1999/06/02 22:25:47 pierre
  1276. * changed $ifdef FPC @ into $ifndef TP
  1277. Revision 1.17 1999/05/27 19:45:01 peter
  1278. * removed oldasm
  1279. * plabel -> pasmlabel
  1280. * -a switches to source writing automaticly
  1281. * assembler readers OOPed
  1282. * asmsymbol automaticly external
  1283. * jumptables and other label fixes for asm readers
  1284. Revision 1.16 1999/05/21 13:55:18 peter
  1285. * NEWLAB for label as symbol
  1286. Revision 1.15 1999/05/12 00:17:11 peter
  1287. * fixed error which was shown for all 32bit consts
  1288. Revision 1.14 1999/05/11 16:27:23 peter
  1289. * support for pointerdef
  1290. Revision 1.13 1999/05/06 09:05:27 peter
  1291. * generic write_float and str_float
  1292. * fixed constant float conversions
  1293. Revision 1.12 1999/05/05 22:22:04 peter
  1294. * updated messages
  1295. Revision 1.11 1999/05/02 22:41:57 peter
  1296. * moved section names to systems
  1297. * fixed nasm,intel writer
  1298. Revision 1.10 1999/05/01 13:24:41 peter
  1299. * merged nasm compiler
  1300. * old asm moved to oldasm/
  1301. Revision 1.8 1999/04/26 23:26:19 peter
  1302. * redesigned record offset parsing to support nested records
  1303. * normal compiler uses the redesigned SetupVar()
  1304. Revision 1.7 1999/04/14 09:07:48 peter
  1305. * asm reader improvements
  1306. Revision 1.6 1999/03/31 13:55:34 peter
  1307. * assembler inlining working for ag386bin
  1308. Revision 1.5 1999/03/26 00:01:17 peter
  1309. * first things for optimizer (compiles but cycle crashes)
  1310. Revision 1.4 1999/03/25 16:55:36 peter
  1311. + unitpath,librarypath,includepath,objectpath directives
  1312. Revision 1.3 1999/03/06 17:24:28 peter
  1313. * rewritten intel parser a lot, especially reference reading
  1314. * size checking added for asm parsers
  1315. Revision 1.2 1999/03/02 02:56:33 peter
  1316. + stabs support for binary writers
  1317. * more fixes and missing updates from the previous commit :(
  1318. Revision 1.1 1999/03/01 15:46:26 peter
  1319. * ag386bin finally make cycles correct
  1320. * prefixes are now also normal opcodes
  1321. }