aasmcpu.pas 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. {
  2. Copyright (c) 1998-2001 by Florian Klaempfl and Pierre Muller
  3. virtual instruction set family assembler instructions
  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 aasmcpu;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cclasses,aasmtai,aasmdata,
  22. aasmbase,globals,verbose,
  23. cpubase,cpuinfo;
  24. type
  25. taicpu = class(taicpu_abstract)
  26. opsize : topsize;
  27. constructor op_none(op : tasmop;_size : topsize);
  28. constructor op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  29. constructor op_const(op : tasmop;_size : topsize;_op1 : longint);
  30. constructor op_ref(op : tasmop;_size : topsize;_op1 : treference);
  31. constructor op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  32. constructor op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : treference);
  33. constructor op_ref_reg(op : tasmop;_size : topsize;_op1 : treference;_op2 : tregister);
  34. constructor op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  35. constructor op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : treference);
  36. { this is for Jmp instructions }
  37. constructor op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
  38. constructor op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
  39. { for DBxx opcodes }
  40. constructor op_reg_sym(op: tasmop; _size : topsize; _op1: tregister; _op2 :tasmsymbol);
  41. constructor op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
  42. constructor op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
  43. constructor op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  44. private
  45. procedure init(_size : topsize); { this need to be called by all constructor }
  46. end;
  47. tai_align = class(tai_align_abstract)
  48. { nothing to add }
  49. end;
  50. procedure InitAsm;
  51. procedure DoneAsm;
  52. implementation
  53. {*****************************************************************************
  54. Taicpu Constructors
  55. *****************************************************************************}
  56. procedure taicpu.init(_size : topsize);
  57. begin
  58. typ:=ait_instruction;
  59. is_jmp:=false;
  60. opsize:=_size;
  61. ops:=0;
  62. end;
  63. constructor taicpu.op_none(op : tasmop;_size : topsize);
  64. begin
  65. inherited create(op);;
  66. init(_size);
  67. end;
  68. constructor taicpu.op_reg(op : tasmop;_size : topsize;_op1 : tregister);
  69. begin
  70. inherited create(op);;
  71. init(_size);
  72. ops:=1;
  73. loadreg(0,_op1);
  74. end;
  75. constructor taicpu.op_const(op : tasmop;_size : topsize;_op1 : longint);
  76. begin
  77. inherited create(op);;
  78. init(_size);
  79. ops:=1;
  80. loadconst(0,aword(_op1));
  81. end;
  82. constructor taicpu.op_ref(op : tasmop;_size : topsize;_op1 : treference);
  83. begin
  84. inherited create(op);;
  85. init(_size);
  86. ops:=1;
  87. loadref(0,_op1);
  88. end;
  89. constructor taicpu.op_reg_reg(op : tasmop;_size : topsize;_op1,_op2 : tregister);
  90. begin
  91. inherited create(op);;
  92. init(_size);
  93. ops:=2;
  94. loadreg(0,_op1);
  95. loadreg(1,_op2);
  96. end;
  97. constructor taicpu.op_reg_ref(op : tasmop;_size : topsize;_op1 : tregister;_op2 : treference);
  98. begin
  99. inherited create(op);;
  100. init(_size);
  101. ops:=2;
  102. loadreg(0,_op1);
  103. loadref(1,_op2);
  104. end;
  105. constructor taicpu.op_const_reg(op : tasmop;_size : topsize;_op1 : longint;_op2 : tregister);
  106. begin
  107. inherited create(op);;
  108. init(_size);
  109. ops:=2;
  110. loadconst(0,aword(_op1));
  111. loadreg(1,_op2);
  112. end;
  113. constructor taicpu.op_const_ref(op : tasmop;_size : topsize;_op1 : longint;_op2 : treference);
  114. begin
  115. inherited create(op);;
  116. init(_size);
  117. ops:=2;
  118. loadconst(0,aword(_op1));
  119. loadref(1,_op2);
  120. end;
  121. constructor taicpu.op_ref_reg(op : tasmop;_size : topsize;_op1 : treference;_op2 : tregister);
  122. begin
  123. inherited create(op);;
  124. init(_size);
  125. ops:=2;
  126. loadref(0,_op1);
  127. loadreg(1,_op2);
  128. end;
  129. constructor taicpu.op_sym(op : tasmop;_size : topsize;_op1 : tasmsymbol);
  130. begin
  131. inherited create(op);;
  132. init(_size);
  133. ops:=1;
  134. loadsymbol(0,_op1,0);
  135. end;
  136. constructor taicpu.op_reg_sym(op: tasmop; _size : topsize; _op1: tregister; _op2 :tasmsymbol);
  137. begin
  138. inherited create(op);
  139. init(_size);
  140. ops:=2;
  141. loadreg(0,_op1);
  142. loadsymbol(1,_op2,0);
  143. end;
  144. constructor taicpu.op_sym_ofs_ref(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;const _op2 : treference);
  145. begin
  146. inherited create(op);
  147. init(_size);
  148. ops:=2;
  149. loadsymbol(0,_op1,_op1ofs);
  150. loadref(1,_op2);
  151. end;
  152. constructor taicpu.op_sym_ofs(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint);
  153. begin
  154. inherited create(op);
  155. init(_size);
  156. ops:=1;
  157. loadsymbol(0,_op1,_op1ofs);
  158. end;
  159. constructor taicpu.op_sym_ofs_reg(op : tasmop;_size : topsize;_op1 : tasmsymbol;_op1ofs:longint;_op2 : tregister);
  160. begin
  161. inherited create(op);;
  162. init(_size);
  163. ops:=2;
  164. loadreg(0,_op2);
  165. loadsymbol(1,_op1,_op1ofs);
  166. end;
  167. constructor taicpu.op_cond_sym(op : tasmop;cond:TAsmCond;_size : topsize;_op1 : tasmsymbol);
  168. begin
  169. inherited create(op);
  170. init(_size);
  171. condition:=cond;
  172. ops:=1;
  173. loadsymbol(0,_op1,0);
  174. end;
  175. procedure InitAsm;
  176. begin
  177. end;
  178. procedure DoneAsm;
  179. begin
  180. end;
  181. end.