itcpugas.pas 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 itcpugas;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cgbase,cpubase;
  22. type
  23. TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint,AttSufINTdual,AttSufMM);
  24. const
  25. { include mnemonic strings }
  26. {$if defined(x86_64)}
  27. gas_op2str:op2strtable={$i x8664att.inc}
  28. gas_needsuffix:array[tasmop] of TAttSuffix={$i x8664ats.inc}
  29. {$elseif defined(i386)}
  30. gas_op2str:op2strtable={$i i386att.inc}
  31. gas_needsuffix:array[tasmop] of TAttSuffix={$i i386atts.inc}
  32. {$elseif defined(i8086)}
  33. gas_op2str:op2strtable={$i i8086att.inc}
  34. gas_needsuffix:array[tasmop] of TAttSuffix={$i i8086atts.inc}
  35. {$endif}
  36. {$ifdef x86_64}
  37. gas_opsize2str : array[topsize] of string[2] = ('',
  38. 'b','w','l','q','bw','bl','wl','bq','wq','lq',
  39. 's','l','q',
  40. 's','l','t','v','x',
  41. 'd',
  42. '','','',
  43. 't',
  44. 'x',
  45. 'y',
  46. 'z'
  47. );
  48. { suffix-to-opsize conversion tables, used in asmreadrer }
  49. { !! S_LQ excluded: movzlq does not exist, movslq is processed
  50. as a separate instruction w/o suffix (aka movsxd), and there are
  51. no more instructions needing it. }
  52. att_sizesuffixstr : array[0..14] of string[2] = (
  53. '','BW','BL','WL','BQ','WQ',{'LQ',}'B','W','L','S','Q','T','X','Y','Z'
  54. );
  55. att_sizesuffix : array[0..14] of topsize = (
  56. S_NO,S_BW,S_BL,S_WL,S_BQ,S_WQ,{S_LQ,}S_B,S_W,S_L,S_NO,S_Q,S_NO,S_NO,S_NO,S_NO
  57. );
  58. att_sizefpusuffix : array[0..14] of topsize = (
  59. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_FL,S_FS,S_NO,S_FX,S_NO,S_NO,S_NO
  60. );
  61. att_sizefpuintsuffix : array[0..14] of topsize = (
  62. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO,S_NO,S_NO,S_NO
  63. );
  64. att_sizemmsuffix : array[0..14] of topsize = (
  65. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_XMM,S_YMM,S_ZMM
  66. );
  67. {$else x86_64}
  68. gas_opsize2str : array[topsize] of string[2] = ('',
  69. 'b','w','l','q','bw','bl','wl',
  70. 's','l','q',
  71. 's','l','t','v','',
  72. 'd',
  73. '','','',
  74. 't',
  75. 'x',
  76. 'y',
  77. 'z'
  78. );
  79. { suffix-to-opsize conversion tables, used in asmreadrer }
  80. att_sizesuffixstr : array[0..12] of string[2] = (
  81. '','BW','BL','WL','B','W','L','S','Q','T','X','Y','Z'
  82. );
  83. att_sizesuffix : array[0..12] of topsize = (
  84. S_NO,S_BW,S_BL,S_WL,S_B,S_W,S_L,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO
  85. );
  86. att_sizefpusuffix : array[0..12] of topsize = (
  87. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_FL,S_FS,S_NO,S_FX,S_NO,S_NO,S_NO
  88. );
  89. att_sizefpuintsuffix : array[0..12] of topsize = (
  90. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO,S_NO,S_NO,S_NO
  91. );
  92. att_sizemmsuffix : array[0..12] of topsize = (
  93. S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_XMM,S_YMM,S_ZMM
  94. );
  95. {$endif x86_64}
  96. function gas_regnum_search(const s:string):Tregister;
  97. function gas_regname(r:Tregister):string;
  98. implementation
  99. uses
  100. cutils,rgbase;
  101. const
  102. {$if defined(x86_64)}
  103. att_regname_table : TRegNameTable = (
  104. {r8664att.inc contains the AT&T name of each register.}
  105. {$i r8664att.inc}
  106. );
  107. att_regname_index : array[tregisterindex] of tregisterindex = (
  108. {r8664ari.inc contains an index which sorts att_regname_table by
  109. ATT name.}
  110. {$i r8664ari.inc}
  111. );
  112. {$elseif defined(i386)}
  113. att_regname_table : TRegNameTable = (
  114. {r386att.inc contains the AT&T name of each register.}
  115. {$i r386att.inc}
  116. );
  117. att_regname_index : array[tregisterindex] of tregisterindex = (
  118. {r386ari.inc contains an index which sorts att_regname_table by
  119. ATT name.}
  120. {$i r386ari.inc}
  121. );
  122. {$elseif defined(i8086)}
  123. att_regname_table : TRegNameTable = (
  124. {r8086att.inc contains the AT&T name of each register.}
  125. {$i r8086att.inc}
  126. );
  127. att_regname_index : array[tregisterindex] of tregisterindex = (
  128. {r8086ari.inc contains an index which sorts att_regname_table by
  129. ATT name.}
  130. {$i r8086ari.inc}
  131. );
  132. {$endif}
  133. function gas_regnum_search(const s:string):Tregister;
  134. begin
  135. result:=regnumber_table[findreg_by_name_table(s,att_regname_table,att_regname_index)];
  136. end;
  137. function gas_regname(r:Tregister):string;
  138. var
  139. p : tregisterindex;
  140. begin
  141. p:=findreg_by_number(r);
  142. if p<>0 then
  143. result:=att_regname_table[p]
  144. else
  145. result:='%'+generic_regname(r);
  146. end;
  147. end.