itcpugas.pas 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 itcpugas;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cgbase,cpubase;
  23. type
  24. TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
  25. const
  26. {$ifdef x86_64}
  27. {x86att.inc contains the name for each x86-64 mnemonic}
  28. gas_op2str:op2strtable={$i x8664att.inc}
  29. gas_needsuffix:array[tasmop] of TAttSuffix={$i x8664ats.inc}
  30. {$else x86_64}
  31. {x86att.inc contains the name for each i386 mnemonic}
  32. gas_op2str:op2strtable={$i i386att.inc}
  33. gas_needsuffix:array[tasmop] of TAttSuffix={$i i386atts.inc}
  34. {$endif x86_64}
  35. {$ifdef x86_64}
  36. gas_opsize2str : array[topsize] of string[2] = ('',
  37. 'b','w','l','q','bw','bl','wl','bq','wq','lq',
  38. 's','l','q',
  39. 's','l','t','v','x',
  40. 'd',
  41. '','','',
  42. 't'
  43. );
  44. {$else x86_64}
  45. gas_opsize2str : array[topsize] of string[2] = ('',
  46. 'b','w','l','q','bw','bl','wl',
  47. 's','l','q',
  48. 's','l','t','v','',
  49. 'd',
  50. '','','',
  51. 't'
  52. );
  53. {$endif x86_64}
  54. function gas_regnum_search(const s:string):Tregister;
  55. function gas_regname(r:Tregister):string;
  56. implementation
  57. uses
  58. cutils,verbose;
  59. const
  60. {$ifdef x86_64}
  61. att_regname_table : array[tregisterindex] of string[7] = (
  62. {r8664att.inc contains the AT&T name of each register.}
  63. {$i r8664att.inc}
  64. );
  65. att_regname_index : array[tregisterindex] of tregisterindex = (
  66. {r8664ari.inc contains an index which sorts att_regname_table by
  67. ATT name.}
  68. {$i r8664ari.inc}
  69. );
  70. {$else x86_64}
  71. att_regname_table : array[tregisterindex] of string[7] = (
  72. {r386att.inc contains the AT&T name of each register.}
  73. {$i r386att.inc}
  74. );
  75. att_regname_index : array[tregisterindex] of tregisterindex = (
  76. {r386ari.inc contains an index which sorts att_regname_table by
  77. ATT name.}
  78. {$i r386ari.inc}
  79. );
  80. {$endif x86_64}
  81. function findreg_by_attname(const s:string):byte;
  82. var
  83. i,p : tregisterindex;
  84. begin
  85. {Binary search.}
  86. p:=0;
  87. i:=regnumber_count_bsstart;
  88. repeat
  89. if (p+i<=high(tregisterindex)) and (att_regname_table[att_regname_index[p+i]]<=s) then
  90. p:=p+i;
  91. i:=i shr 1;
  92. until i=0;
  93. if att_regname_table[att_regname_index[p]]=s then
  94. findreg_by_attname:=att_regname_index[p]
  95. else
  96. findreg_by_attname:=0;
  97. end;
  98. function gas_regnum_search(const s:string):Tregister;
  99. begin
  100. result:=regnumber_table[findreg_by_attname(s)];
  101. end;
  102. function gas_regname(r:Tregister):string;
  103. var
  104. p : tregisterindex;
  105. begin
  106. p:=findreg_by_number(r);
  107. if p<>0 then
  108. result:=att_regname_table[p]
  109. else
  110. result:='%'+generic_regname(r);
  111. end;
  112. end.
  113. {
  114. $Log$
  115. Revision 1.5 2004-12-12 10:50:35 florian
  116. * fixed operand size calculation for sse operands
  117. + all nasm assembler targets to help page output added
  118. Revision 1.4 2004/06/20 08:55:32 florian
  119. * logs truncated
  120. Revision 1.3 2004/02/05 18:28:37 peter
  121. * x86_64 fixes for opsize
  122. Revision 1.2 2004/01/15 14:01:32 florian
  123. + x86 instruction tables for x86-64 extended
  124. }