itx86int.pas 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit contains the i386 AT&T 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 itx86int;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cgbase;
  22. function masm_regnum_search(const s:string):Tregister;
  23. function masm_regname(r:Tregister):string;
  24. implementation
  25. uses
  26. cutils,verbose,
  27. cpubase;
  28. const
  29. int_regname_table : array[tregisterindex] of string[7] = (
  30. {$i r386int.inc}
  31. );
  32. int_regname_index : array[tregisterindex] of tregisterindex = (
  33. {$i r386iri.inc}
  34. );
  35. function findreg_by_intname(const s:string):byte;
  36. var
  37. i,p : tregisterindex;
  38. begin
  39. {Binary search.}
  40. p:=0;
  41. i:=regnumber_count_bsstart;
  42. repeat
  43. if (p+i<=high(tregisterindex)) and (int_regname_table[int_regname_index[p+i]]<=s) then
  44. p:=p+i;
  45. i:=i shr 1;
  46. until i=0;
  47. if int_regname_table[int_regname_index[p]]=s then
  48. findreg_by_intname:=int_regname_index[p]
  49. else
  50. findreg_by_intname:=0;
  51. end;
  52. function masm_regnum_search(const s:string):Tregister;
  53. begin
  54. result:=regnumber_table[findreg_by_intname(s)];
  55. end;
  56. function masm_regname(r:Tregister):string;
  57. var
  58. p : tregisterindex;
  59. begin
  60. p:=findreg_by_number(r);
  61. if p<>0 then
  62. result:=int_regname_table[p]
  63. else
  64. result:=generic_regname(r);
  65. end;
  66. end.