n8086ld.pas 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {
  2. Copyright (c) 2002-2014 by Florian Klaempfl
  3. Generate i8086 assembler for load nodes
  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 n8086ld;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. symsym,symtype,
  23. node,ncgld;
  24. type
  25. ti8086loadnode = class(tcgloadnode)
  26. procedure generate_nested_access(vs: tsym); override;
  27. procedure generate_absaddr_access(vs: tabsolutevarsym); override;
  28. end;
  29. implementation
  30. uses
  31. globals,aasmdata,
  32. symcpu,
  33. nld,
  34. cgbase,cgobj,
  35. cpubase,cpuinfo;
  36. {*****************************************************************************
  37. TI8086LOADNODE
  38. *****************************************************************************}
  39. procedure ti8086loadnode.generate_nested_access(vs: tsym);
  40. begin
  41. inherited;
  42. { the parentfp pointer is always a near pointer (this is turbo pascal
  43. compatible) regardless of memory model, so we need to set the segment
  44. manually.
  45. todo: once the far data memory models are fully implemented, the
  46. parentfp type should be changed to a near 'ss' pointer in all memory
  47. models and then this code can be removed. But this can only happen
  48. after:
  49. 1) all calls to a_loadaddr_ref_reg go through the high level code
  50. generator
  51. 2) a_loadaddr_ref_reg in the low level code generator stops using
  52. the presence of a segment in the source reference to determine the
  53. destination reg size
  54. 3) make_simple_ref is updated to remove unnecessary segment prefixes
  55. 4) hlcg.reference_reset_base is updated to set the segment on near_ss
  56. pointers }
  57. if (left.nodetype=loadparentfpn) and
  58. (current_settings.x86memorymodel in x86_far_data_models) then
  59. location.reference.segment:=NR_SS;
  60. end;
  61. procedure ti8086loadnode.generate_absaddr_access(vs: tabsolutevarsym);
  62. begin
  63. if tcpuabsolutevarsym(symtableentry).absseg then
  64. begin
  65. location.reference.segment:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
  66. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_16,aint(tcpuabsolutevarsym(symtableentry).addrsegment),location.reference.segment);
  67. end;
  68. inherited;
  69. end;
  70. begin
  71. cloadnode:=ti8086loadnode;
  72. end.