itcpugas.pas 2.5 KB

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