n8086inl.pas 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate i8086 inline 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 n8086inl;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. nx86inl,node;
  22. type
  23. { ti8086inlinenode }
  24. ti8086inlinenode = class(tx86inlinenode)
  25. function typecheck_seg: tnode; override;
  26. function first_seg: tnode; override;
  27. procedure second_seg; override;
  28. procedure second_get_frame;override;
  29. end;
  30. implementation
  31. uses
  32. ninl,
  33. systems,
  34. globtype,globals,
  35. cutils,verbose,
  36. symconst,
  37. defutil,
  38. aasmbase,aasmtai,aasmdata,aasmcpu,
  39. symtype,symdef,
  40. cgbase,pass_2,
  41. cpuinfo,cpubase,paramgr,
  42. nbas,ncon,ncal,ncnv,nld,ncgutil,
  43. tgobj,
  44. cga,cgutils,cgx86,cgobj,hlcgobj,
  45. htypechk,procinfo;
  46. function ti8086inlinenode.typecheck_seg: tnode;
  47. begin
  48. result := nil;
  49. resultdef:=u16inttype;
  50. end;
  51. function ti8086inlinenode.first_seg: tnode;
  52. begin
  53. expectloc:=LOC_REGISTER;
  54. result:=nil;
  55. end;
  56. procedure ti8086inlinenode.second_seg;
  57. begin
  58. location_reset(location,LOC_REGISTER,OS_16);
  59. location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_16);
  60. current_asmdata.CurrAsmList.Concat(Taicpu.op_reg_reg(A_MOV,S_W,NR_DS,location.register));
  61. end;
  62. procedure ti8086inlinenode.second_get_frame;
  63. begin
  64. if current_settings.x86memorymodel in x86_far_data_models then
  65. begin
  66. if current_procinfo.framepointer=NR_STACK_POINTER_REG then
  67. internalerror(2014030201);
  68. location_reset(location,LOC_REGISTER,OS_32);
  69. location.register:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  70. emit_reg_reg(A_MOV,S_W,current_procinfo.framepointer,location.register);
  71. current_asmdata.CurrAsmList.Concat(Taicpu.op_reg_reg(A_MOV,S_W,NR_SS,GetNextReg(location.register)));
  72. end
  73. else
  74. inherited second_get_frame;
  75. end;
  76. begin
  77. cinlinenode:=ti8086inlinenode;
  78. end.