n8086con.pas 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. {
  2. Copyright (c) 1998-2012 by Florian Klaempfl and others
  3. Generate i8086 assembler for constants
  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 n8086con;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ncon,ncgcon,nx86con;
  22. type
  23. { tcgpointerconstnode }
  24. ti8086pointerconstnode = class(tcgpointerconstnode)
  25. procedure pass_generate_code;override;
  26. end;
  27. implementation
  28. uses
  29. systems,globals,globtype,
  30. symconst,symdef,
  31. defutil,
  32. cpubase,
  33. cga,cgx86,cgobj,cgbase,cgutils;
  34. {*****************************************************************************
  35. T8086POINTERCONSTNODE
  36. *****************************************************************************}
  37. procedure ti8086pointerconstnode.pass_generate_code;
  38. begin
  39. { far pointer? }
  40. if (typedef.typ=pointerdef) and (tpointerdef(typedef).x86pointertyp in [x86pt_far,x86pt_huge]) then
  41. begin
  42. location_reset(location,LOC_CONSTANT,OS_32);
  43. location.value:=longint(value);
  44. end
  45. else
  46. begin
  47. { an integer const. behaves as a memory reference }
  48. location_reset(location,LOC_CONSTANT,OS_ADDR);
  49. location.value:=aint(value);
  50. end;
  51. end;
  52. begin
  53. cpointerconstnode:=ti8086pointerconstnode;
  54. end.