n8086cnv.pas 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. if (current_settings.x86memorymodel in x86_far_code_models) and
  52. not is_proc_far(tabstractprocdef(left.resultdef)) then
  53. CGMessage1(type_e_procedure_must_be_far,left.resultdef.GetTypeName);
  54. Result:=inherited typecheck_proc_to_procvar;
  55. end;
  56. procedure t8086typeconvnode.second_proc_to_procvar;
  57. begin
  58. if is_proc_far(tabstractprocdef(resultdef))<>
  59. (current_settings.x86memorymodel in x86_far_code_models) then
  60. internalerror(2014041302);
  61. if is_proc_far(tabstractprocdef(left.resultdef))<>
  62. (current_settings.x86memorymodel in x86_far_code_models) then
  63. internalerror(2014041303);
  64. inherited;
  65. end;
  66. begin
  67. ctypeconvnode:=t8086typeconvnode
  68. end.