itx86int.pas 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit contains the i386 AT&T 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 itx86int;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cgbase;
  23. function masm_regnum_search(const s:string):Tregister;
  24. function masm_regname(r:Tregister):string;
  25. implementation
  26. uses
  27. cutils,verbose,
  28. cpubase;
  29. const
  30. int_regname_table : array[tregisterindex] of string[7] = (
  31. {$i r386int.inc}
  32. );
  33. int_regname_index : array[tregisterindex] of tregisterindex = (
  34. {$i r386iri.inc}
  35. );
  36. function findreg_by_intname(const s:string):byte;
  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 (int_regname_table[int_regname_index[p+i]]<=s) then
  45. p:=p+i;
  46. i:=i shr 1;
  47. until i=0;
  48. if int_regname_table[int_regname_index[p]]=s then
  49. findreg_by_intname:=int_regname_index[p]
  50. else
  51. findreg_by_intname:=0;
  52. end;
  53. function masm_regnum_search(const s:string):Tregister;
  54. begin
  55. result:=regnumber_table[findreg_by_intname(s)];
  56. end;
  57. function masm_regname(r:Tregister):string;
  58. var
  59. p : tregisterindex;
  60. begin
  61. p:=findreg_by_number(r);
  62. if p<>0 then
  63. result:=int_regname_table[p]
  64. else
  65. result:=generic_regname(r);
  66. end;
  67. end.
  68. {
  69. $Log$
  70. Revision 1.5 2004-06-20 08:55:32 florian
  71. * logs truncated
  72. }