aasmcpu.pas 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. {
  2. $Id$
  3. Copyright (c) 1998-2001 by Florian Klaempfl and Pierre Muller
  4. virtual instruction set family assembler instructions
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit aasmcpu;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cclasses,aasmtai,
  23. aasmbase,globals,verbose,
  24. cpubase,cpuinfo;
  25. type
  26. taicpu = class(taicpu_abstract)
  27. opsize : topsize;
  28. constructor op_none(op : tasmop;_size : topsize);
  29. constructor op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  30. constructor op_const(op : tasmop;_size : topsize;_op1 : longint);
  31. constructor op_ref(op : tasmop;_size : topsize;_op1 : treference);
  32. constructor op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  33. constructor op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : treference);
  34. constructor op_ref_reg(op : tasmop;_size : topsize;_op1 : treference;_op2 : tregister);
  35. constructor op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  36. constructor op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : treference);
  37. { this is for Jmp instructions }
  38. constructor op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
  39. constructor op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
  40. { for DBxx opcodes }
  41. constructor op_reg_sym(op: tasmop; _size : topsize; _op1: tregister; _op2 :tasmsymbol);
  42. constructor op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
  43. constructor op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
  44. constructor op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  45. private
  46. procedure init(_size : topsize); { this need to be called by all constructor }
  47. end;
  48. tai_align = class(tai_align_abstract)
  49. { nothing to add }
  50. end;
  51. procedure InitAsm;
  52. procedure DoneAsm;
  53. implementation
  54. {*****************************************************************************
  55. Taicpu Constructors
  56. *****************************************************************************}
  57. procedure taicpu.init(_size : topsize);
  58. begin
  59. typ:=ait_instruction;
  60. is_jmp:=false;
  61. opsize:=_size;
  62. ops:=0;
  63. end;
  64. constructor taicpu.op_none(op : tasmop;_size : topsize);
  65. begin
  66. inherited create(op);;
  67. init(_size);
  68. end;
  69. constructor taicpu.op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  70. begin
  71. inherited create(op);;
  72. init(_size);
  73. ops:=1;
  74. loadreg(0,_op1);
  75. end;
  76. constructor taicpu.op_const(op : tasmop;_size : topsize;_op1 : longint);
  77. begin
  78. inherited create(op);;
  79. init(_size);
  80. ops:=1;
  81. loadconst(0,aword(_op1));
  82. end;
  83. constructor taicpu.op_ref(op : tasmop;_size : topsize;_op1 : treference);
  84. begin
  85. inherited create(op);;
  86. init(_size);
  87. ops:=1;
  88. loadref(0,_op1);
  89. end;
  90. constructor taicpu.op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  91. begin
  92. inherited create(op);;
  93. init(_size);
  94. ops:=2;
  95. loadreg(0,_op1);
  96. loadreg(1,_op2);
  97. end;
  98. constructor taicpu.op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : treference);
  99. begin
  100. inherited create(op);;
  101. init(_size);
  102. ops:=2;
  103. loadreg(0,_op1);
  104. loadref(1,_op2);
  105. end;
  106. constructor taicpu.op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  107. begin
  108. inherited create(op);;
  109. init(_size);
  110. ops:=2;
  111. loadconst(0,aword(_op1));
  112. loadreg(1,_op2);
  113. end;
  114. constructor taicpu.op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : treference);
  115. begin
  116. inherited create(op);;
  117. init(_size);
  118. ops:=2;
  119. loadconst(0,aword(_op1));
  120. loadref(1,_op2);
  121. end;
  122. constructor taicpu.op_ref_reg(op : tasmop;_size : topsize;_op1 : treference;_op2 : tregister);
  123. begin
  124. inherited create(op);;
  125. init(_size);
  126. ops:=2;
  127. loadref(0,_op1);
  128. loadreg(1,_op2);
  129. end;
  130. constructor taicpu.op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
  131. begin
  132. inherited create(op);;
  133. init(_size);
  134. ops:=1;
  135. loadsymbol(0,_op1,0);
  136. end;
  137. constructor taicpu.op_reg_sym(op: tasmop; _size : topsize; _op1: tregister; _op2 :tasmsymbol);
  138. begin
  139. inherited create(op);
  140. init(_size);
  141. ops:=2;
  142. loadreg(0,_op1);
  143. loadsymbol(1,_op2,0);
  144. end;
  145. constructor taicpu.op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  146. begin
  147. inherited create(op);
  148. init(_size);
  149. ops:=2;
  150. loadsymbol(0,_op1,_op1ofs);
  151. loadref(1,_op2);
  152. end;
  153. constructor taicpu.op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
  154. begin
  155. inherited create(op);
  156. init(_size);
  157. ops:=1;
  158. loadsymbol(0,_op1,_op1ofs);
  159. end;
  160. constructor taicpu.op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
  161. begin
  162. inherited create(op);;
  163. init(_size);
  164. ops:=2;
  165. loadreg(0,_op2);
  166. loadsymbol(1,_op1,_op1ofs);
  167. end;
  168. constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
  169. begin
  170. inherited create(op);
  171. init(_size);
  172. condition:=cond;
  173. ops:=1;
  174. loadsymbol(0,_op1,0);
  175. end;
  176. procedure InitAsm;
  177. begin
  178. end;
  179. procedure DoneAsm;
  180. begin
  181. end;
  182. end.
  183. {
  184. $Log$
  185. Revision 1.1 2003-02-02 19:25:54 carl
  186. * Several bugfixes for m68k target (register alloc., opcode emission)
  187. + VIS target
  188. + Generic add more complete (still not verified)
  189. }