itcpugas.pas 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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','fadd',
  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','fmove','fmovem',
  66. 'fmul','fneg','fnop','fsqrt','fsub','fsgldiv',
  67. 'fsflmul','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. implementation
  84. const
  85. gas_regname_table : array[tregisterindex] of string[7] = (
  86. {r386att.inc contains the AT&T name of each register.}
  87. {$i r68kgas.inc}
  88. );
  89. gas_regname_index : array[tregisterindex] of tregisterindex = (
  90. {r386ari.inc contains an index which sorts att_regname_table by
  91. ATT name.}
  92. {$i r68kgri.inc}
  93. );
  94. function findreg_by_gasname(const s:string):byte;
  95. var
  96. i,p : tregisterindex;
  97. begin
  98. {Binary search.}
  99. p:=0;
  100. i:=regnumber_count_bsstart;
  101. repeat
  102. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  103. p:=p+i;
  104. i:=i shr 1;
  105. until i=0;
  106. if gas_regname_table[gas_regname_index[p]]=s then
  107. findreg_by_gasname:=gas_regname_index[p]
  108. else
  109. findreg_by_gasname:=0;
  110. end;
  111. function gas_regnum_search(const s:string):Tregister;
  112. begin
  113. result:=regnumber_table[findreg_by_gasname(s)];
  114. end;
  115. function gas_regname(r:Tregister):string;
  116. var
  117. p : tregisterindex;
  118. begin
  119. p:=findreg_by_number(r);
  120. if p<>0 then
  121. result:=gas_regname_table[p]
  122. else
  123. result:='%'+generic_regname(r);
  124. end;
  125. end.