nz80mat.pas 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate Z80 assembler for math 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 nz80mat;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,nmat,ncgmat;
  22. type
  23. { tz80notnode }
  24. tz80notnode = class(tcgnotnode)
  25. protected
  26. procedure second_boolean;override;
  27. end;
  28. implementation
  29. uses
  30. globtype,systems,constexp,
  31. cutils,verbose,globals,
  32. symconst,symdef,aasmbase,aasmtai,aasmdata,aasmcpu,defutil,
  33. cgbase,pass_2,
  34. ncon,
  35. cpubase,cpuinfo,
  36. ncgutil,cgobj,cgutils,
  37. hlcgobj;
  38. {*****************************************************************************
  39. tz80notnode
  40. *****************************************************************************}
  41. procedure tz80notnode.second_boolean;
  42. var
  43. i: Integer;
  44. begin
  45. secondpass(left);
  46. if not handle_locjump then
  47. begin
  48. if left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
  49. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
  50. case left.location.loc of
  51. LOC_FLAGS :
  52. begin
  53. location_reset(location,LOC_FLAGS,OS_NO);
  54. location.resflags:=left.location.resflags;
  55. inverse_flags(location.resflags);
  56. end;
  57. (* LOC_CREFERENCE,
  58. LOC_REFERENCE:
  59. begin
  60. {$if defined(cpu32bitalu)}
  61. if is_64bit(resultdef) then
  62. begin
  63. hreg:=cg.GetIntRegister(current_asmdata.CurrAsmList,OS_32);
  64. tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,left.location.reference);
  65. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.reference,hreg);
  66. inc(left.location.reference.offset,4);
  67. cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.reference,hreg);
  68. end
  69. else
  70. {$elseif defined(cpu16bitalu)}
  71. if is_64bit(resultdef) then
  72. begin
  73. hreg:=cg.GetIntRegister(current_asmdata.CurrAsmList,OS_16);
  74. tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,left.location.reference);
  75. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_16,OS_16,left.location.reference,hreg);
  76. inc(left.location.reference.offset,2);
  77. cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_16,left.location.reference,hreg);
  78. inc(left.location.reference.offset,2);
  79. cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_16,left.location.reference,hreg);
  80. inc(left.location.reference.offset,2);
  81. cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_16,left.location.reference,hreg);
  82. end
  83. else if is_32bit(resultdef) then
  84. begin
  85. hreg:=cg.GetIntRegister(current_asmdata.CurrAsmList,OS_16);
  86. tcgx86(cg).make_simple_ref(current_asmdata.CurrAsmList,left.location.reference);
  87. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_16,OS_16,left.location.reference,hreg);
  88. inc(left.location.reference.offset,2);
  89. cg.a_op_ref_reg(current_asmdata.CurrAsmList,OP_OR,OS_16,left.location.reference,hreg);
  90. end
  91. else
  92. {$endif}
  93. emit_const_ref(A_CMP, TCGSize2Opsize[opsize], 0, left.location.reference);
  94. location_reset(location,LOC_FLAGS,OS_NO);
  95. location.resflags:=F_E;
  96. end;*)
  97. LOC_CONSTANT,
  98. LOC_REGISTER,
  99. LOC_CREGISTER,
  100. LOC_SUBSETREG,
  101. LOC_CSUBSETREG,
  102. LOC_SUBSETREF,
  103. LOC_CSUBSETREF :
  104. begin
  105. if tcgsize2size[def_cgsize(left.resultdef)]<>tcgsize2size[def_cgsize(resultdef)] then
  106. internalerror(2020042209);
  107. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
  108. if tcgsize2size[def_cgsize(left.resultdef)]=1 then
  109. begin
  110. cg.getcpuregister(current_asmdata.CurrAsmList,NR_A);
  111. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_8,OS_8,left.location.register,NR_A);
  112. current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg(A_OR,NR_A,NR_A));
  113. cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_A);
  114. end
  115. else
  116. begin
  117. cg.getcpuregister(current_asmdata.CurrAsmList,NR_A);
  118. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_8,OS_8,left.location.register,NR_A);
  119. for i:=1 to tcgsize2size[def_cgsize(left.resultdef)]-1 do
  120. current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg(A_OR,NR_A,cg.GetOffsetReg64(left.location.register,left.location.registerhi,i)));
  121. cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_A);
  122. end;
  123. location_reset(location,LOC_FLAGS,OS_NO);
  124. location.resflags:=F_E;
  125. end;
  126. else
  127. internalerror(2020042208);
  128. end;
  129. end;
  130. end;
  131. begin
  132. cnotnode:=tz80notnode;
  133. end.