itcpugas.pas 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Mazen NEIFER
  4. This unit contains the SPARC GAS instruction tables
  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 itcpugas;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cpubase,cgbase;
  23. const
  24. gas_op2str : array[tasmop] of string[14] = ({$INCLUDE strinst.inc});
  25. function gas_regnum_search(const s:string):Tregister;
  26. function gas_regname(r:Tregister):string;
  27. implementation
  28. uses
  29. cutils,verbose;
  30. const
  31. gas_regname_table : array[tregisterindex] of string[7] = (
  32. {$i rspstd.inc}
  33. );
  34. gas_regname_index : array[tregisterindex] of tregisterindex = (
  35. {$i rspsri.inc}
  36. );
  37. function findreg_by_gasname(const s:string):tregisterindex;
  38. var
  39. i,p : tregisterindex;
  40. begin
  41. {Binary search.}
  42. p:=0;
  43. i:=regnumber_count_bsstart;
  44. repeat
  45. if (p+i<=high(tregisterindex)) and (gas_regname_table[gas_regname_index[p+i]]<=s) then
  46. p:=p+i;
  47. i:=i shr 1;
  48. until i=0;
  49. if gas_regname_table[gas_regname_index[p]]=s then
  50. findreg_by_gasname:=gas_regname_index[p]
  51. else
  52. findreg_by_gasname:=0;
  53. end;
  54. function gas_regnum_search(const s:string):Tregister;
  55. begin
  56. result:=regnumber_table[findreg_by_gasname(s)];
  57. end;
  58. function gas_regname(r:Tregister):string;
  59. var
  60. hr : tregister;
  61. p : longint;
  62. begin
  63. { Double uses the same table as single }
  64. hr:=r;
  65. case getsubreg(hr) of
  66. R_SUBFD:
  67. setsubreg(hr,R_SUBFS);
  68. R_SUBL,R_SUBW,R_SUBD,R_SUBQ:
  69. setsubreg(hr,R_SUBD);
  70. end;
  71. p:=findreg_by_number(hr);
  72. if p<>0 then
  73. result:=gas_regname_table[p]
  74. else
  75. result:=generic_regname(r);
  76. end;
  77. end.
  78. {
  79. $Log$
  80. Revision 1.7 2005-02-14 17:13:10 peter
  81. * truncate log
  82. }