itx86int.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.4 2003-10-01 20:34:51 peter
  71. * procinfo unit contains tprocinfo
  72. * cginfo renamed to cgbase
  73. * moved cgmessage to verbose
  74. * fixed ppc and sparc compiles
  75. Revision 1.3 2003/09/04 14:42:44 peter
  76. * return 0 instead of $ff when no reg is found
  77. Revision 1.2 2003/09/03 15:55:02 peter
  78. * NEWRA branch merged
  79. Revision 1.1.2.5 2003/08/31 15:46:26 peter
  80. * more updates for tregister
  81. Revision 1.1.2.4 2003/08/31 13:50:16 daniel
  82. * Remove sorting and use pregenerated indexes
  83. * Some work on making things compile
  84. Revision 1.1.2.3 2003/08/28 18:35:08 peter
  85. * tregister changed to cardinal
  86. Revision 1.1.2.2 2003/08/27 21:06:34 peter
  87. * more updates
  88. Revision 1.1.2.1 2003/08/27 19:55:54 peter
  89. * first tregister patch
  90. }