itcpugas.pas 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. { fpu processor instructions - directly supported only. }
  53. { ieee aware and misc. condition codes not supported }
  54. 'fabs','fadd',
  55. 'fbeq','fbne','fbngt','fbgt','fbge','fbnge',
  56. 'fblt','fbnlt','fble','fbgl','fbngl','fbgle','fbngle',
  57. 'fdbeq','fdbne','fdbgt','fdbngt','fdbge','fdbnge',
  58. 'fdblt','fdbnlt','fdble','fdbgl','fdbngl','fdbgle','fdbngle',
  59. 'fseq','fsne','fsgt','fsngt','fsge','fsnge',
  60. 'fslt','fsnlt','fsle','fsgl','fsngl','fsgle','fsngle',
  61. 'fcmp','fdiv','fmove','fmovem',
  62. 'fmul','fneg','fnop','fsqrt','fsub','fsgldiv',
  63. 'fsflmul','ftst',
  64. 'ftrapeq','ftrapne','ftrapgt','ftrapngt','ftrapge','ftrapnge',
  65. 'ftraplt','ftrapnlt','ftraple','ftrapgl','ftrapngl','ftrapgle','ftrapngle',
  66. { protected instructions }
  67. 'cprestore','cpsave',
  68. { fpu unit protected instructions }
  69. { and 68030/68851 common mmu instructions }
  70. { (this may include 68040 mmu instructions) }
  71. 'frestore','fsave','pflush','pflusha','pload','pmove','ptest',
  72. { useful for assembly language output }
  73. 'label','db','s','b','fb');
  74. function gas_regnum_search(const s:string):Tregister;
  75. function gas_regname(r:Tregister):string;
  76. implementation
  77. const
  78. gas_regname_table : array[tregisterindex] of string[7] = (
  79. {r386att.inc contains the AT&T name of each register.}
  80. {$i r68kgas.inc}
  81. );
  82. gas_regname_index : array[tregisterindex] of tregisterindex = (
  83. {r386ari.inc contains an index which sorts att_regname_table by
  84. ATT name.}
  85. {$i r68kgri.inc}
  86. );
  87. function findreg_by_gasname(const s:string):byte;
  88. var
  89. i,p : tregisterindex;
  90. begin
  91. {Binary search.}
  92. p:=0;
  93. i:=regnumber_count_bsstart;
  94. repeat
  95. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  96. p:=p+i;
  97. i:=i shr 1;
  98. until i=0;
  99. if gas_regname_table[gas_regname_index[p]]=s then
  100. findreg_by_gasname:=gas_regname_index[p]
  101. else
  102. findreg_by_gasname:=0;
  103. end;
  104. function gas_regnum_search(const s:string):Tregister;
  105. begin
  106. result:=regnumber_table[findreg_by_gasname(s)];
  107. end;
  108. function gas_regname(r:Tregister):string;
  109. var
  110. p : tregisterindex;
  111. begin
  112. p:=findreg_by_number(r);
  113. if p<>0 then
  114. result:=gas_regname_table[p]
  115. else
  116. result:='%'+generic_regname(r);
  117. end;
  118. end.