as/i386 all versions a bit too permissive with ins/outs/lods/stos

Alan Modra amodra@bigpond.net.au
Fri May 17 22:19:00 GMT 2002


On Fri, May 17, 2002 at 04:40:15PM +0200, Etienne Lorrain wrote:
>   Just for info, if someone has time:
>   "ins" only possible with %[e]di
>   "outs" only possible with %[e]si
>   I did not find a version of "as" complaining, even if they
>   analyse this part of the instruction for segment overwrite.
> 
>   The "89 F6" at end is just a nop.
> 
> etienne@Fulbert:~$ cat tmp.s
> .text
>         insw %dx,%es:(%edi)
>         insw %dx,%es:(%esi)
> 
>         outsw %es:(%esi),%dx
>         outsw %es:(%edi),%dx

This behaviour is deliberate.  The IA-32 Intel Architecture Software
Developer's Manual says:

At the assembly-code level, two forms of this instruction are allowed:
the explicit-operands form and the no-operands form.  The explicit-
operands form (specified with the INS mnemonic) allows the source and
destination operands to be specified explicitly.  Here, the source
operand must be DX, and the destination operand should be a symbol
that indicates the size of the I/O port and the destination address.
This explicit-operands form is provided to allow documentation;
however, note that the documentation provided by this form can be
misleading.  That is, the destination operand symbol must specify the
correct type (size) of the operand (byte, word, or doubleword), but it
does not have to specify the correct location.  The location is always
specified by the ES:(E)DI registers, which must be loaded correctly
before the INS instruction is executed.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list