n8086tcon.pas 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {
  2. Copyright (c) 1998-2011 by Florian Klaempfl, Jonas Maebe
  3. Generates i8086 assembler for typed constant declarations
  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 n8086tcon;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,symdef,ngtcon;
  22. type
  23. { ti8086typedconstbuilder }
  24. ti8086typedconstbuilder = class(tasmlisttypedconstbuilder)
  25. protected
  26. procedure tc_emit_pointerdef(def: tpointerdef; var node: tnode);override;
  27. end;
  28. implementation
  29. uses
  30. ncnv,defcmp,defutil,aasmtai,symcpu;
  31. { ti8086typedconstbuilder }
  32. procedure ti8086typedconstbuilder.tc_emit_pointerdef(def: tpointerdef; var node: tnode);
  33. var
  34. hp: tnode;
  35. begin
  36. { remove equal typecasts for pointer/nil addresses }
  37. if (node.nodetype=typeconvn) then
  38. with Ttypeconvnode(node) do
  39. if (left.nodetype in [addrn,niln]) and equal_defs(def,node.resultdef) then
  40. begin
  41. hp:=left;
  42. left:=nil;
  43. node.free;
  44. node:=hp;
  45. end;
  46. if node.nodetype=niln then
  47. begin
  48. if is_farpointer(def) or is_hugepointer(def) then
  49. list.concat(Tai_const.Create_32bit(0))
  50. else
  51. list.concat(Tai_const.Create_16bit(0));
  52. end
  53. else
  54. inherited tc_emit_pointerdef(def, node);
  55. end;
  56. begin
  57. ctypedconstbuilder:=ti8086typedconstbuilder;
  58. end.