symcpu.pas 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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(ti86procvardef)
  70. constructor create(level:byte);override;
  71. end;
  72. tcpuprocvardefclass = class of tcpuprocvardef;
  73. { tcpuprocdef }
  74. tcpuprocdef = class(ti86procdef)
  75. constructor create(level:byte);override;
  76. function address_type:tdef;override;
  77. end;
  78. tcpuprocdefclass = class of tcpuprocdef;
  79. tcpustringdef = class(tstringdef)
  80. end;
  81. tcpustringdefclass = class of tcpustringdef;
  82. tcpuenumdef = class(tenumdef)
  83. end;
  84. tcpuenumdefclass = class of tcpuenumdef;
  85. tcpusetdef = class(tsetdef)
  86. end;
  87. tcpusetdefclass = class of tcpusetdef;
  88. { syms }
  89. tcpulabelsym = class(tlabelsym)
  90. end;
  91. tcpulabelsymclass = class of tcpulabelsym;
  92. tcpuunitsym = class(tunitsym)
  93. end;
  94. tcpuunitsymclass = class of tcpuunitsym;
  95. tcpunamespacesym = class(tnamespacesym)
  96. end;
  97. tcpunamespacesymclass = class of tcpunamespacesym;
  98. tcpuprocsym = class(tprocsym)
  99. end;
  100. tcpuprocsymclass = class of tcpuprocsym;
  101. tcputypesym = class(ttypesym)
  102. end;
  103. tcpuypesymclass = class of tcputypesym;
  104. tcpufieldvarsym = class(tfieldvarsym)
  105. end;
  106. tcpufieldvarsymclass = class of tcpufieldvarsym;
  107. tcpulocalvarsym = class(tlocalvarsym)
  108. end;
  109. tcpulocalvarsymclass = class of tcpulocalvarsym;
  110. tcpuparavarsym = class(tparavarsym)
  111. end;
  112. tcpuparavarsymclass = class of tcpuparavarsym;
  113. tcpustaticvarsym = class(tstaticvarsym)
  114. end;
  115. tcpustaticvarsymclass = class of tcpustaticvarsym;
  116. tcpuabsolutevarsym = class(ti86absolutevarsym)
  117. protected
  118. procedure ppuload_platform(ppufile: tcompilerppufile); override;
  119. procedure ppuwrite_platform(ppufile: tcompilerppufile); override;
  120. public
  121. addrsegment : aword;
  122. end;
  123. tcpuabsolutevarsymclass = class of tcpuabsolutevarsym;
  124. tcpupropertysym = class(tpropertysym)
  125. end;
  126. tcpupropertysymclass = class of tcpupropertysym;
  127. tcpuconstsym = class(tconstsym)
  128. end;
  129. tcpuconstsymclass = class of tcpuconstsym;
  130. tcpuenumsym = class(tenumsym)
  131. end;
  132. tcpuenumsymclass = class of tcpuenumsym;
  133. tcpusyssym = class(tsyssym)
  134. end;
  135. tcpusyssymclass = class of tcpusyssym;
  136. const
  137. pbestrealtype : ^tdef = @s80floattype;
  138. implementation
  139. uses
  140. globals, cpuinfo;
  141. {****************************************************************************
  142. tcpuprocdef
  143. ****************************************************************************}
  144. constructor tcpuprocdef.create(level: byte);
  145. begin
  146. inherited create(level);
  147. { todo: allow using near procs in the far code memory models, like in TP7 }
  148. if current_settings.x86memorymodel in x86_far_code_models then
  149. procoptions:=procoptions+[po_far];
  150. end;
  151. function tcpuprocdef.address_type: tdef;
  152. begin
  153. if po_far in procoptions then
  154. result:=voidfarpointertype
  155. else
  156. result:=voidnearpointertype;
  157. end;
  158. {****************************************************************************
  159. tcpuprocvardef
  160. ****************************************************************************}
  161. constructor tcpuprocvardef.create(level: byte);
  162. begin
  163. inherited create(level);
  164. { procvars are always far in the far code memory models }
  165. if current_settings.x86memorymodel in x86_far_code_models then
  166. procoptions:=procoptions+[po_far];
  167. end;
  168. {****************************************************************************
  169. tcpupointerdef
  170. ****************************************************************************}
  171. class function tcpupointerdef.default_x86_data_pointer_type: tx86pointertyp;
  172. begin
  173. if current_settings.x86memorymodel in x86_far_data_models then
  174. result:=x86pt_far
  175. else
  176. result:=inherited;
  177. end;
  178. {****************************************************************************
  179. tcpuabsolutevarsym
  180. ****************************************************************************}
  181. procedure tcpuabsolutevarsym.ppuload_platform(ppufile: tcompilerppufile);
  182. begin
  183. inherited;
  184. if absseg then
  185. addrsegment:=ppufile.getaword;
  186. end;
  187. procedure tcpuabsolutevarsym.ppuwrite_platform(ppufile: tcompilerppufile);
  188. begin
  189. inherited;
  190. if absseg then
  191. ppufile.putaword(addrsegment);
  192. end;
  193. begin
  194. { used tdef classes }
  195. cfiledef:=tcpufiledef;
  196. cvariantdef:=tcpuvariantdef;
  197. cformaldef:=tcpuformaldef;
  198. cforwarddef:=tcpuforwarddef;
  199. cundefineddef:=tcpuundefineddef;
  200. cerrordef:=tcpuerrordef;
  201. cpointerdef:=tcpupointerdef;
  202. crecorddef:=tcpurecorddef;
  203. cimplementedinterface:=tcpuimplementedinterface;
  204. cobjectdef:=tcpuobjectdef;
  205. cclassrefdef:=tcpuclassrefdef;
  206. carraydef:=tcpuarraydef;
  207. corddef:=tcpuorddef;
  208. cfloatdef:=tcpufloatdef;
  209. cprocvardef:=tcpuprocvardef;
  210. cprocdef:=tcpuprocdef;
  211. cstringdef:=tcpustringdef;
  212. cenumdef:=tcpuenumdef;
  213. csetdef:=tcpusetdef;
  214. { used tsym classes }
  215. clabelsym:=tcpulabelsym;
  216. cunitsym:=tcpuunitsym;
  217. cnamespacesym:=tcpunamespacesym;
  218. cprocsym:=tcpuprocsym;
  219. ctypesym:=tcputypesym;
  220. cfieldvarsym:=tcpufieldvarsym;
  221. clocalvarsym:=tcpulocalvarsym;
  222. cparavarsym:=tcpuparavarsym;
  223. cstaticvarsym:=tcpustaticvarsym;
  224. cabsolutevarsym:=tcpuabsolutevarsym;
  225. cpropertysym:=tcpupropertysym;
  226. cconstsym:=tcpuconstsym;
  227. cenumsym:=tcpuenumsym;
  228. csyssym:=tcpusyssym;
  229. end.