n8086cnv.pas 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate code for i8086 assembler for type converting 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 n8086cnv;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ncgcnv,nx86cnv,defutil,defcmp;
  22. type
  23. { t8086typeconvnode }
  24. t8086typeconvnode = class(tx86typeconvnode)
  25. protected
  26. function typecheck_int_to_int: tnode;override;
  27. function typecheck_proc_to_procvar: tnode;override;
  28. procedure second_proc_to_procvar;override;
  29. end;
  30. implementation
  31. uses
  32. verbose,systems,globals,globtype,
  33. aasmbase,aasmtai,aasmdata,aasmcpu,
  34. symconst,symdef,symcpu,
  35. cgbase,cga,procinfo,pass_1,pass_2,
  36. ncon,ncal,ncnv,nmem,n8086mem,
  37. cpubase,cpuinfo,
  38. cgutils,cgobj,hlcgobj,cgx86,ncgutil,
  39. tgobj;
  40. function t8086typeconvnode.typecheck_int_to_int: tnode;
  41. begin
  42. Result:=inherited typecheck_int_to_int;
  43. if (is_16bitint(totypedef) or is_8bitint(totypedef)) and (left.nodetype=addrn) then
  44. begin
  45. if left.nodetype=addrn then
  46. ti8086addrnode(left).get_offset_only:=true;
  47. end;
  48. end;
  49. function t8086typeconvnode.typecheck_proc_to_procvar: tnode;
  50. begin
  51. Result:=inherited typecheck_proc_to_procvar;
  52. if tcnf_proc_2_procvar_get_offset_only in convnodeflags then
  53. begin
  54. if resultdef.typ<>procvardef then
  55. internalerror(2018040401);
  56. exclude(tprocvardef(resultdef).procoptions,po_far);
  57. end
  58. else if (tcnf_proc_2_procvar_2_voidpointer in convnodeflags) and
  59. (current_settings.x86memorymodel in x86_far_code_models) then
  60. begin
  61. if resultdef.typ<>procvardef then
  62. internalerror(2018040402);
  63. include(tprocvardef(resultdef).procoptions,po_far);
  64. end;
  65. end;
  66. procedure t8086typeconvnode.second_proc_to_procvar;
  67. begin
  68. if (tcnf_proc_2_procvar_get_offset_only in convnodeflags) and
  69. is_proc_far(tabstractprocdef(resultdef)) then
  70. internalerror(2018040403);
  71. inherited;
  72. end;
  73. begin
  74. ctypeconvnode:=t8086typeconvnode
  75. end.