itx86att.pas 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. { This unit implements an asmoutput class for i386 AT&T syntax
  19. }
  20. unit itx86att;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. cpubase;
  25. type
  26. TAttSuffix = (AttSufNONE,AttSufINT,AttSufFPU,AttSufFPUint);
  27. const
  28. {$ifdef x86_64}
  29. gas_op2str:op2strtable={$i x64att.inc}
  30. gas_needsuffix:array[tasmop] of TAttSuffix={$i x64atts.inc}
  31. {$else x86_64}
  32. gas_op2str:op2strtable={$i i386att.inc}
  33. gas_needsuffix:array[tasmop] of TAttSuffix={$i i386atts.inc}
  34. {$endif x86_64}
  35. gas_reg2str : reg2strtable = ('',
  36. {$ifdef x86_64}
  37. '%rax','%rcx','%rdx','%rbx','%rsp','%rbp','%rsi','%rdi',
  38. '%r8','%r9','%r10','%r11','%r12','%r13','%r14','%r15','%rip',
  39. {$endif x86_64}
  40. '%eax','%ecx','%edx','%ebx','%esp','%ebp','%esi','%edi',
  41. {$ifdef x86_64}
  42. '%r8d','%r9d','%r10d','%r11d','%r12d','%r13d','%r14d','%r15d',
  43. {$endif x86_64}
  44. '%ax','%cx','%dx','%bx','%sp','%bp','%si','%di',
  45. {$ifdef x86_64}
  46. '%r8w','%r9w','%r10w','%r11w','%r12w','%r13w','%r14w','%r15w',
  47. {$endif x86_64}
  48. '%al','%cl','%dl','%bl',
  49. {$ifdef x86_64}
  50. '%spl','%bpl','%sil','%dil',
  51. '%r8b','%r9b','%r10b','%r11b','%r12b','%r13b','%r14b','%r15b',
  52. {$endif x86_64}
  53. '%ah','%ch','%bh','%dh',
  54. {$ifdef x86_64}
  55. {$endif x86_64}
  56. '%cs','%ds','%es','%ss','%fs','%gs',
  57. '%st','%st(0)','%st(1)','%st(2)','%st(3)','%st(4)','%st(5)','%st(6)','%st(7)',
  58. '%dr0','%dr1','%dr2','%dr3','%dr6','%dr7',
  59. '%cr0','%cr2','%cr3','%cr4',
  60. '%tr3','%tr4','%tr5','%tr6','%tr7',
  61. '%mm0','%mm1','%mm2','%mm3','%mm4','%mm5','%mm6','%mm7',
  62. '%xmm0','%xmm1','%xmm2','%xmm3','%xmm4','%xmm5','%xmm6','%xmm7'
  63. {$ifdef x86_64}
  64. ,'%xmm8','%xmm9','%xmm10','%xmm11','%xmm12','%xmm13','%xmm14','%xmm15'
  65. {$endif x86_64}
  66. );
  67. regname_count=45;
  68. regname_count_bsstart=32;
  69. gas_regname2regnum:array[0..regname_count-1] of regname2regnumrec=(
  70. (name:'%ah'; number:NR_AH),
  71. (name:'%al'; number:NR_AL),
  72. (name:'%ax'; number:NR_AX),
  73. (name:'%bh'; number:NR_BH),
  74. (name:'%bl'; number:NR_BL),
  75. (name:'%bp'; number:NR_BP),
  76. (name:'%bx'; number:NR_BX),
  77. (name:'%ch'; number:NR_CH),
  78. (name:'%cl'; number:NR_CL),
  79. (name:'%cs'; number:NR_CS),
  80. (name:'%cr0'; number:NR_CR0),
  81. (name:'%cr2'; number:NR_CR2),
  82. (name:'%cr3'; number:NR_CR3),
  83. (name:'%cr4'; number:NR_CR4),
  84. (name:'%cx'; number:NR_CX),
  85. (name:'%dh'; number:NR_DH),
  86. (name:'%dl'; number:NR_DL),
  87. (name:'%di'; number:NR_DI),
  88. (name:'%dr0'; number:NR_DR0),
  89. (name:'%dr1'; number:NR_DR1),
  90. (name:'%dr2'; number:NR_DR2),
  91. (name:'%dr3'; number:NR_DR3),
  92. (name:'%dr6'; number:NR_DR6),
  93. (name:'%dr7'; number:NR_DR7),
  94. (name:'%ds'; number:NR_DS),
  95. (name:'%dx'; number:NR_DX),
  96. (name:'%eax'; number:NR_EAX),
  97. (name:'%ebp'; number:NR_EBP),
  98. (name:'%ebx'; number:NR_EBX),
  99. (name:'%ecx'; number:NR_ECX),
  100. (name:'%edi'; number:NR_EDI),
  101. (name:'%edx'; number:NR_EDX),
  102. (name:'%es'; number:NR_ES),
  103. (name:'%esi'; number:NR_ESI),
  104. (name:'%esp'; number:NR_ESP),
  105. (name:'%fs'; number:NR_FS),
  106. (name:'%gs'; number:NR_GS),
  107. (name:'%si'; number:NR_SI),
  108. (name:'%sp'; number:NR_SP),
  109. (name:'%ss'; number:NR_SS),
  110. (name:'%tr3'; number:NR_DR0),
  111. (name:'%tr4'; number:NR_DR1),
  112. (name:'%tr5'; number:NR_DR2),
  113. (name:'%tr6'; number:NR_DR6),
  114. (name:'%tr7'; number:NR_DR7)
  115. );
  116. {$ifdef x86_64}
  117. gas_opsize2str : array[topsize] of string[2] = ('',
  118. 'b','w','l','bw','bl','wl','bq','wq','lq',
  119. 's','l','q',
  120. 's','l','t','d','q','v','x',
  121. '','',''
  122. );
  123. {$else x86_64}
  124. gas_opsize2str : array[topsize] of string[2] = ('',
  125. 'b','w','l','bw','bl','wl',
  126. 's','l','q',
  127. 's','l','t','d','q','v','',
  128. '','',''
  129. );
  130. {$endif x86_64}
  131. function gas_regnum_search(const s:string):Tnewregister;
  132. implementation
  133. uses
  134. cutils,systems,
  135. verbose;
  136. function gas_regnum_search(const s:string):Tnewregister;
  137. {Searches the register number that belongs to the register in s.
  138. s must be in uppercase!.}
  139. var i,p:byte;
  140. begin
  141. {Binary search.}
  142. p:=0;
  143. i:=regname_count_bsstart;
  144. while i<>0 do
  145. begin
  146. if (p+i<regname_count) and (upper(gas_regname2regnum[p+i].name)<=s) then
  147. p:=p+i;
  148. i:=i shr 1;
  149. end;
  150. if upper(gas_regname2regnum[p].name)=s then
  151. gas_regnum_search:=gas_regname2regnum[p].number
  152. else
  153. gas_regnum_search:=NR_NO;
  154. end;
  155. end.
  156. {
  157. $Log$
  158. Revision 1.1 2003-05-22 21:33:08 peter
  159. * i386 att instruction table moved to separate unit
  160. }