symx86.pas 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {
  2. Copyright (c) 2014 by Florian Klaempfl
  3. Symbol table overrides for x86
  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 symx86;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. symconst, symtype,symdef,symsym;
  23. type
  24. tx86pointerdef = class(tpointerdef)
  25. protected
  26. procedure ppuload_platform(ppufile: tcompilerppufile); override;
  27. procedure ppuwrite_platform(ppufile: tcompilerppufile); override;
  28. public
  29. x86pointertyp : tx86pointertyp;
  30. constructor create(def: tdef); override;
  31. constructor createx86(def:tdef;x86typ:tx86pointertyp);virtual;
  32. function size: asizeint; override;
  33. function getcopy: tstoreddef; override;
  34. function GetTypeName: string; override;
  35. class function default_x86_data_pointer_type: tx86pointertyp; virtual;
  36. end;
  37. tx86pointerdefclass = class of tx86pointerdef;
  38. implementation
  39. uses
  40. globals, verbose;
  41. {****************************************************************************
  42. tx86pointerdef
  43. ****************************************************************************}
  44. procedure tx86pointerdef.ppuload_platform(ppufile: tcompilerppufile);
  45. begin
  46. inherited;
  47. x86pointertyp:=tx86pointertyp(ppufile.getbyte);
  48. end;
  49. procedure tx86pointerdef.ppuwrite_platform(ppufile: tcompilerppufile);
  50. begin
  51. inherited;
  52. ppufile.putbyte(byte(x86pointertyp));
  53. end;
  54. constructor tx86pointerdef.create(def: tdef);
  55. begin
  56. inherited create(def);
  57. x86pointertyp := default_x86_data_pointer_type;
  58. end;
  59. constructor tx86pointerdef.createx86(def: tdef; x86typ: tx86pointertyp);
  60. begin
  61. tabstractpointerdef(self).create(pointerdef,def);
  62. x86pointertyp := x86typ;
  63. has_pointer_math:=cs_pointermath in current_settings.localswitches;
  64. end;
  65. function tx86pointerdef.size: asizeint;
  66. begin
  67. if x86pointertyp in [x86pt_far,x86pt_huge] then
  68. result:=sizeof(pint)+2
  69. else
  70. result:=inherited;
  71. end;
  72. function tx86pointerdef.getcopy: tstoreddef;
  73. begin
  74. result:=inherited;
  75. tx86pointerdef(result).x86pointertyp:=x86pointertyp;
  76. end;
  77. function tx86pointerdef.GetTypeName: string;
  78. begin
  79. result:=inherited;
  80. if x86pointertyp<>default_x86_data_pointer_type then
  81. begin
  82. case x86pointertyp of
  83. x86pt_near:
  84. result:=result+';near';
  85. x86pt_near_cs:
  86. result:=result+';near ''CS''';
  87. x86pt_near_ds:
  88. result:=result+';near ''DS''';
  89. x86pt_near_ss:
  90. result:=result+';near ''SS''';
  91. x86pt_near_es:
  92. result:=result+';near ''ES''';
  93. x86pt_near_fs:
  94. result:=result+';near ''FS''';
  95. x86pt_near_gs:
  96. result:=result+';near ''GS''';
  97. x86pt_far:
  98. result:=result+';far';
  99. x86pt_huge:
  100. result:=result+';huge';
  101. else
  102. internalerror(2013050301);
  103. end;
  104. end;
  105. end;
  106. class function tx86pointerdef.default_x86_data_pointer_type: tx86pointertyp;
  107. begin
  108. result:=x86pt_near;
  109. end;
  110. end.