itcpugas.pas 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit contains the m68k GAS instruction tables
  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 itcpugas;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cpubase,cgbase;
  22. const
  23. gas_op2str : op2strtable=
  24. { warning: CPU32 opcodes are not fully compatible with the MC68020. }
  25. { 68000 only opcodes }
  26. ( '',
  27. 'abcd','add','adda','addi','addq','addx','and','andi',
  28. 'asl','asr','bcc','bcs','beq','bge','bgt','bhi',
  29. 'ble','bls','blt','bmi','bne','bpl','bvc','bvs',
  30. 'bchg','bclr','bra','bset','bsr','btst','chk',
  31. 'clr','cmp','cmpa','cmpi','cmpm','dbcc','dbcs','dbeq','dbge',
  32. 'dbgt','dbhi','dble','dbls','dblt','dbmi','dbne','dbra',
  33. 'dbpl','dbt','dbvc','dbvs','dbf','divs','divu',
  34. 'eor','eori','exg','illegal','ext','jmp','jsr',
  35. 'lea','link','lsl','lsr','move','movea','movei','moveq',
  36. 'movem','movep','muls','mulu','nbcd','neg','negx',
  37. 'nop','not','or','ori','pea','rol','ror','roxl',
  38. 'roxr','rtr','rts','sbcd','scc','scs','seq','sge',
  39. 'sgt','shi','sle','sls','slt','smi','sne',
  40. 'spl','st','svc','svs','sf','sub','suba','subi','subq',
  41. 'subx','swap','tas','trap','trapv','tst','unlk',
  42. 'rte','reset','stop',
  43. { mc68010 instructions }
  44. 'bkpt','movec','moves','rtd',
  45. { mc68020 instructions }
  46. 'bfchg','bfclr','bfexts','bfextu','bfffo',
  47. 'bfins','bfset','bftst','callm','cas','cas2',
  48. 'chk2','cmp2','divsl','divul','extb','pack','rtm',
  49. 'trapcc','tracs','trapeq','trapf','trapge','trapgt',
  50. 'traphi','traple','trapls','traplt','trapmi','trapne',
  51. 'trappl','trapt','trapvc','trapvs','unpk',
  52. { mc64040 instructions }
  53. 'move16',
  54. { coldfire v4 instructions }
  55. 'mov3q','mvz','mvs','sats','byterev','ff1','remu','rems',
  56. { fpu processor instructions - directly supported }
  57. { ieee aware and misc. condition codes not supported }
  58. 'fabs','fsabs','fdabs','fadd','fsadd','fdadd',
  59. 'fbeq','fbne','fbngt','fbgt','fbge','fbnge',
  60. 'fblt','fbnlt','fble','fbgl','fbngl','fbgle','fbngle',
  61. 'fdbeq','fdbne','fdbgt','fdbngt','fdbge','fdbnge',
  62. 'fdblt','fdbnlt','fdble','fdbgl','fdbngl','fdbgle','fdbngle',
  63. 'fseq','fsne','fsgt','fsngt','fsge','fsnge',
  64. 'fslt','fsnlt','fsle','fsgl','fsngl','fsgle','fsngle',
  65. 'fcmp','fdiv','fsdiv','fddiv','fmove','fsmove','fdmove','fmovem',
  66. 'fmul','fsmul','fdmul','fneg','fsneg','fdneg','fnop','fsqrt','fssqrt','fdsqrt',
  67. 'fsub','fssub','fdsub','fsgldiv','fsglmul','ftst',
  68. 'ftrapeq','ftrapne','ftrapgt','ftrapngt','ftrapge','ftrapnge',
  69. 'ftraplt','ftrapnlt','ftraple','ftrapgl','ftrapngl','ftrapgle','ftrapngle',
  70. 'fint','fintrz',
  71. { fpu instructions - indirectly supported }
  72. 'fsin','fcos',
  73. { protected instructions }
  74. 'cprestore','cpsave',
  75. { fpu unit protected instructions }
  76. { and 68030/68851 common mmu instructions }
  77. { (this may include 68040 mmu instructions) }
  78. 'frestore','fsave','pflush','pflusha','pload','pmove','ptest',
  79. { useful for assembly language output }
  80. 'label','db','s','b','fs','fb');
  81. function gas_regnum_search(const s:string):Tregister;
  82. function gas_regname(r:Tregister):string;
  83. function gas_regfullname(r:Tregister):string;
  84. implementation
  85. const
  86. gas_regname_table : array[tregisterindex] of string[7] = (
  87. {r68kgas.inc contains the name of each register.}
  88. {$i r68kgas.inc}
  89. );
  90. gas_regfullname_table : array[tregisterindex] of string[7] = (
  91. {r68kgasf.inc contains the "full" name of each register.}
  92. {$i r68kgasf.inc}
  93. );
  94. gas_regname_index : array[tregisterindex] of tregisterindex = (
  95. {r68kgri.inc contains an index which sorts gas_regname_table by name }
  96. {$i r68kgri.inc}
  97. );
  98. function findreg_by_gasname(const s:string):byte;
  99. var
  100. i,p : tregisterindex;
  101. begin
  102. {Binary search.}
  103. p:=0;
  104. i:=regnumber_count_bsstart;
  105. repeat
  106. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  107. p:=p+i;
  108. i:=i shr 1;
  109. until i=0;
  110. if gas_regname_table[gas_regname_index[p]]=s then
  111. findreg_by_gasname:=gas_regname_index[p]
  112. else
  113. findreg_by_gasname:=0;
  114. end;
  115. function gas_regnum_search(const s:string):Tregister;
  116. begin
  117. result:=regnumber_table[findreg_by_gasname(s)];
  118. end;
  119. function gas_regname(r:Tregister):string;
  120. var
  121. p : tregisterindex;
  122. begin
  123. p:=findreg_by_number(r);
  124. if p<>0 then
  125. result:=gas_regname_table[p]
  126. else
  127. result:='%'+generic_regname(r);
  128. end;
  129. function gas_regfullname(r:Tregister):string;
  130. var
  131. p : tregisterindex;
  132. begin
  133. p:=findreg_by_number(r);
  134. if p<>0 then
  135. result:=gas_regfullname_table[p]
  136. else
  137. result:='%'+generic_regname(r);
  138. end;
  139. end.