symcpu.pas 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. {
  2. Copyright (c) 2014 by Florian Klaempfl
  3. Symbol table overrides for i8086
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit symcpu;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. symconst,symtype,symdef,symsym,symx86,symi86;
  23. type
  24. { defs }
  25. tcpufiledef = class(tfiledef)
  26. end;
  27. tcpufiledefclass = class of tcpufiledef;
  28. tcpuvariantdef = class(tvariantdef)
  29. end;
  30. tcpuvariantdefclass = class of tcpuvariantdef;
  31. tcpuformaldef = class(tformaldef)
  32. end;
  33. tcpuformaldefclass = class of tcpuformaldef;
  34. tcpuforwarddef = class(tforwarddef)
  35. end;
  36. tcpuforwarddefclass = class of tcpuforwarddef;
  37. tcpuundefineddef = class(tundefineddef)
  38. end;
  39. tcpuundefineddefclass = class of tcpuundefineddef;
  40. tcpuerrordef = class(terrordef)
  41. end;
  42. tcpuerrordefclass = class of tcpuerrordef;
  43. tcpupointerdef = class(tx86pointerdef)
  44. class function default_x86_data_pointer_type: tx86pointertyp; override;
  45. end;
  46. tcpupointerdefclass = class of tcpupointerdef;
  47. tcpurecorddef = class(trecorddef)
  48. end;
  49. tcpurecorddefclass = class of tcpurecorddef;
  50. tcpuimplementedinterface = class(timplementedinterface)
  51. end;
  52. tcpuimplementedinterfaceclass = class of tcpuimplementedinterface;
  53. tcpuobjectdef = class(tobjectdef)
  54. end;
  55. tcpuobjectdefclass = class of tcpuobjectdef;
  56. tcpuclassrefdef = class(tclassrefdef)
  57. end;
  58. tcpuclassrefdefclass = class of tcpuclassrefdef;
  59. tcpuarraydef = class(tarraydef)
  60. end;
  61. tcpuarraydefclass = class of tcpuarraydef;
  62. tcpuorddef = class(torddef)
  63. end;
  64. tcpuorddefclass = class of tcpuorddef;
  65. tcpufloatdef = class(tfloatdef)
  66. end;
  67. tcpufloatdefclass = class of tcpufloatdef;
  68. { tcpuprocvardef }
  69. tcpuprocvardef = class(tprocvardef)
  70. constructor create(level:byte);override;
  71. end;
  72. tcpuprocvardefclass = class of tcpuprocvardef;
  73. { tcpuprocdef }
  74. tcpuprocdef = class(tprocdef)
  75. constructor create(level:byte);override;
  76. end;
  77. tcpuprocdefclass = class of tcpuprocdef;
  78. tcpustringdef = class(tstringdef)
  79. end;
  80. tcpustringdefclass = class of tcpustringdef;
  81. tcpuenumdef = class(tenumdef)
  82. end;
  83. tcpuenumdefclass = class of tcpuenumdef;
  84. tcpusetdef = class(tsetdef)
  85. end;
  86. tcpusetdefclass = class of tcpusetdef;
  87. { syms }
  88. tcpulabelsym = class(tlabelsym)
  89. end;
  90. tcpulabelsymclass = class of tcpulabelsym;
  91. tcpuunitsym = class(tunitsym)
  92. end;
  93. tcpuunitsymclass = class of tcpuunitsym;
  94. tcpunamespacesym = class(tnamespacesym)
  95. end;
  96. tcpunamespacesymclass = class of tcpunamespacesym;
  97. tcpuprocsym = class(tprocsym)
  98. end;
  99. tcpuprocsymclass = class of tcpuprocsym;
  100. tcputypesym = class(ttypesym)
  101. end;
  102. tcpuypesymclass = class of tcputypesym;
  103. tcpufieldvarsym = class(tfieldvarsym)
  104. end;
  105. tcpufieldvarsymclass = class of tcpufieldvarsym;
  106. tcpulocalvarsym = class(tlocalvarsym)
  107. end;
  108. tcpulocalvarsymclass = class of tcpulocalvarsym;
  109. tcpuparavarsym = class(tparavarsym)
  110. end;
  111. tcpuparavarsymclass = class of tcpuparavarsym;
  112. tcpustaticvarsym = class(tstaticvarsym)
  113. end;
  114. tcpustaticvarsymclass = class of tcpustaticvarsym;
  115. tcpuabsolutevarsym = class(ti86absolutevarsym)
  116. protected
  117. procedure ppuload_platform(ppufile: tcompilerppufile); override;
  118. procedure ppuwrite_platform(ppufile: tcompilerppufile); override;
  119. public
  120. addrsegment : aword;
  121. end;
  122. tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
  123. tcpupropertysym = class(tpropertysym)
  124. end;
  125. tcpupropertysymclass = class of tcpupropertysym;
  126. tcpuconstsym = class(tconstsym)
  127. end;
  128. tcpuconstsymclass = class of tcpuconstsym;
  129. tcpuenumsym = class(tenumsym)
  130. end;
  131. tcpuenumsymclass = class of tcpuenumsym;
  132. tcpusyssym = class(tsyssym)
  133. end;
  134. tcpusyssymclass = class of tcpusyssym;
  135. const
  136. pbestrealtype : ^tdef = @s80floattype;
  137. implementation
  138. uses
  139. globals, cpuinfo;
  140. {****************************************************************************
  141. tcpuprocdef
  142. ****************************************************************************}
  143. constructor tcpuprocdef.create(level: byte);
  144. begin
  145. inherited create(level);
  146. { todo: allow using near procs in the far code memory models, like in TP7 }
  147. if current_settings.x86memorymodel in x86_far_code_models then
  148. procoptions:=procoptions+[po_far];
  149. end;
  150. {****************************************************************************
  151. tcpuprocvardef
  152. ****************************************************************************}
  153. constructor tcpuprocvardef.create(level: byte);
  154. begin
  155. inherited create(level);
  156. { procvars are always far in the far code memory models }
  157. if current_settings.x86memorymodel in x86_far_code_models then
  158. procoptions:=procoptions+[po_far];
  159. end;
  160. {****************************************************************************
  161. tcpupointerdef
  162. ****************************************************************************}
  163. class function tcpupointerdef.default_x86_data_pointer_type: tx86pointertyp;
  164. begin
  165. if current_settings.x86memorymodel in x86_far_data_models then
  166. result:=x86pt_far
  167. else
  168. result:=inherited;
  169. end;
  170. {****************************************************************************
  171. tcpuabsolutevarsym
  172. ****************************************************************************}
  173. procedure tcpuabsolutevarsym.ppuload_platform(ppufile: tcompilerppufile);
  174. begin
  175. inherited;
  176. if absseg then
  177. addrsegment:=ppufile.getaword;
  178. end;
  179. procedure tcpuabsolutevarsym.ppuwrite_platform(ppufile: tcompilerppufile);
  180. begin
  181. inherited;
  182. if absseg then
  183. ppufile.putaword(addrsegment);
  184. end;
  185. begin
  186. { used tdef classes }
  187. cfiledef:=tcpufiledef;
  188. cvariantdef:=tcpuvariantdef;
  189. cformaldef:=tcpuformaldef;
  190. cforwarddef:=tcpuforwarddef;
  191. cundefineddef:=tcpuundefineddef;
  192. cerrordef:=tcpuerrordef;
  193. cpointerdef:=tcpupointerdef;
  194. crecorddef:=tcpurecorddef;
  195. cimplementedinterface:=tcpuimplementedinterface;
  196. cobjectdef:=tcpuobjectdef;
  197. cclassrefdef:=tcpuclassrefdef;
  198. carraydef:=tcpuarraydef;
  199. corddef:=tcpuorddef;
  200. cfloatdef:=tcpufloatdef;
  201. cprocvardef:=tcpuprocvardef;
  202. cprocdef:=tcpuprocdef;
  203. cstringdef:=tcpustringdef;
  204. cenumdef:=tcpuenumdef;
  205. csetdef:=tcpusetdef;
  206. { used tsym classes }
  207. clabelsym:=tcpulabelsym;
  208. cunitsym:=tcpuunitsym;
  209. cnamespacesym:=tcpunamespacesym;
  210. cprocsym:=tcpuprocsym;
  211. ctypesym:=tcputypesym;
  212. cfieldvarsym:=tcpufieldvarsym;
  213. clocalvarsym:=tcpulocalvarsym;
  214. cparavarsym:=tcpuparavarsym;
  215. cstaticvarsym:=tcpustaticvarsym;
  216. cabsolutevarsym:=tcpuabsolutevarsym;
  217. cpropertysym:=tcpupropertysym;
  218. cconstsym:=tcpuconstsym;
  219. cenumsym:=tcpuenumsym;
  220. csyssym:=tcpusyssym;
  221. end.