Browse Source

+ support the xlat x86 instruction syntax with a memory operand. This allows
specifying the address size (e.g. xlat byte ptr [bx] or xlat byte ptr [ebx])

git-svn-id: trunk@37478 -

nickysn 7 years ago
parent
commit
e8bbc4eef9

+ 1 - 1
compiler/i386/i386nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-1976;
+1977;

+ 7 - 0
compiler/i386/i386tab.inc

@@ -5810,6 +5810,13 @@
     code    : #1#215;
     flags   : [if_8086]
   ),
+  (
+    opcode  : A_XLAT;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits8,ot_none,ot_none,ot_none);
+    code    : #1#215;
+    flags   : [if_8086]
+  ),
   (
     opcode  : A_XLATB;
     ops     : 0;

+ 1 - 1
compiler/i8086/i8086nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-2008;
+2009;

+ 7 - 0
compiler/i8086/i8086tab.inc

@@ -5824,6 +5824,13 @@
     code    : #1#215;
     flags   : [if_8086]
   ),
+  (
+    opcode  : A_XLAT;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits8,ot_none,ot_none,ot_none);
+    code    : #1#215;
+    flags   : [if_8086]
+  ),
   (
     opcode  : A_XLATB;
     ops     : 0;

+ 17 - 0
compiler/x86/agx86nsm.pas

@@ -985,6 +985,23 @@ interface
                     end;
                if fixed_opcode=A_FWAIT then
                 writer.AsmWriteln(#9#9'DB'#9'09bh')
+               else if (fixed_opcode=A_XLAT) and (taicpu(hp).ops=1) and
+                       (taicpu(hp).oper[0]^.typ=top_ref) then
+                begin
+                  writer.AsmWrite(#9#9);
+                  if (taicpu(hp).oper[0]^.ref^.segment<>NR_NO) and
+                     (taicpu(hp).oper[0]^.ref^.segment<>NR_DS) then
+                    writer.AsmWrite(std_regname(taicpu(hp).oper[0]^.ref^.segment)+' ');
+                  case get_ref_address_size(taicpu(hp).oper[0]^.ref^) of
+                    16:
+                      writer.AsmWrite('a16 ');
+                    32:
+                      writer.AsmWrite('a32 ');
+                    64:
+                      writer.AsmWrite('a64 ');
+                  end;
+                  writer.AsmWriteLn('xlatb');
+                end
                else if is_x86_parameterized_string_op(fixed_opcode) then
                 begin
                   writer.AsmWrite(#9#9);

+ 1 - 0
compiler/x86/x86ins.dat

@@ -2074,6 +2074,7 @@ mem8,reg8             \1\x86\101                      8086
 [XLAT]
 (Ch_WEAX, Ch_REBX)
 void                  \1\xD7                          8086
+mem8                  \1\xD7                          8086
 
 [XLATB]
 (Ch_WEAX, Ch_REBX)

+ 1 - 1
compiler/x86_64/x8664nop.inc

@@ -1,2 +1,2 @@
 { don't edit, this file is generated from x86ins.dat }
-2027;
+2028;

+ 7 - 0
compiler/x86_64/x8664tab.inc

@@ -5866,6 +5866,13 @@
     code    : #1#215;
     flags   : [if_8086]
   ),
+  (
+    opcode  : A_XLAT;
+    ops     : 1;
+    optypes : (ot_memory or ot_bits8,ot_none,ot_none,ot_none);
+    code    : #1#215;
+    flags   : [if_8086]
+  ),
   (
     opcode  : A_XLATB;
     ops     : 0;

+ 12 - 0
tests/test/tasm12a.pp

@@ -39,7 +39,13 @@ begin
     outsw
     outsd
 
+    xlat
+    xlatb
+
     { no segment overrides }
+    xlat byte ptr [rbx]
+    xlat byte ptr [ebx]
+
     movs byte ptr [rdi], byte ptr [rsi]
     movs byte ptr [edi], byte ptr [esi]
     movs word ptr [rdi], word ptr [rsi]
@@ -100,6 +106,9 @@ begin
     outs dx, dword ptr [esi]
 
     { es:di }
+    xlat byte ptr ds:[rbx]
+    xlat byte ptr ds:[ebx]
+
     movs byte ptr es:[rdi], byte ptr [rsi]
     movs byte ptr es:[edi], byte ptr [esi]
     movs word ptr es:[rdi], word ptr [rsi]
@@ -160,6 +169,9 @@ begin
     outs dx, dword ptr [esi]
 
     { es:di, fs:si }
+    xlat byte ptr fs:[rbx]
+    xlat byte ptr fs:[ebx]
+
     movs byte ptr es:[rdi], byte ptr fs:[rsi]
     movs byte ptr es:[edi], byte ptr fs:[esi]
     movs word ptr es:[rdi], word ptr fs:[rsi]

+ 12 - 0
tests/test/tasm12b.pp

@@ -34,7 +34,13 @@ begin
     outsw
     outsd
 
+    xlat
+    xlatb
+
     { no segment overrides }
+    xlat byte ptr [ebx]
+    xlat byte ptr [bx]
+
     movs byte ptr [edi], byte ptr [esi]
     movs byte ptr [di], byte ptr [si]
     movs word ptr [edi], word ptr [esi]
@@ -85,6 +91,9 @@ begin
     outs dx, dword ptr [si]
 
     { es:di }
+    xlat byte ptr ds:[ebx]
+    xlat byte ptr ds:[bx]
+
     movs byte ptr es:[edi], byte ptr [esi]
     movs byte ptr es:[di], byte ptr [si]
     movs word ptr es:[edi], word ptr [esi]
@@ -135,6 +144,9 @@ begin
     outs dx, dword ptr [si]
 
     { es:di, fs:si }
+    xlat byte ptr fs:[ebx]
+    xlat byte ptr fs:[bx]
+
     movs byte ptr es:[edi], byte ptr fs:[esi]
     movs byte ptr es:[di], byte ptr fs:[si]
     movs word ptr es:[edi], word ptr fs:[esi]

+ 12 - 0
tests/test/tasm12c.pp

@@ -35,7 +35,13 @@ begin
     outsw
     outsd
 
+    xlat
+    xlatb
+
     { no segment overrides }
+    xlat byte ptr [ebx]
+    xlat byte ptr [bx]
+
     movs byte ptr [edi], byte ptr [esi]
     movs byte ptr [di], byte ptr [si]
     movs word ptr [edi], word ptr [esi]
@@ -86,6 +92,9 @@ begin
     outs dx, dword ptr [si]
 
     { es:di }
+    xlat byte ptr ds:[ebx]
+    xlat byte ptr ds:[bx]
+
     movs byte ptr es:[edi], byte ptr [esi]
     movs byte ptr es:[di], byte ptr [si]
     movs word ptr es:[edi], word ptr [esi]
@@ -136,6 +145,9 @@ begin
     outs dx, dword ptr [si]
 
     { es:di, fs:si }
+    xlat byte ptr fs:[ebx]
+    xlat byte ptr fs:[bx]
+
     movs byte ptr es:[edi], byte ptr fs:[esi]
     movs byte ptr es:[di], byte ptr fs:[si]
     movs word ptr es:[edi], word ptr fs:[esi]