This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ia32 suffix inconsistency


>>> On 15.12.10 at 17:58, "H.J. Lu" <hjl.tools@gmail.com> wrote:
> On Wed, Dec 15, 2010 at 8:50 AM, Jan Beulich <JBeulich@novell.com> wrote:
>> I don't follow: In what way is the "add" case above more
>> ambiguous than the "mov" one? Both could mean byte, word,
>> or dword accesses. And for the "add" case, if the default
>> indeed is meant ot be 32-bits, there's *no* ambiguity wrt
>> the width of the immediate (as with "addl", one can clearly
>> expect the smaller to be picked as long as the immediate fits).
>>
> 
> I don't see any problems:

How do you not see the gas error for the "mov" case? And how
do you not see the absence of an error for the "add" case?

Once again, for "mov", the assembler needs to pick one of

- opcode c6
- opcode c7 with operand size override
- opcode c7 without operand size override

and it selects the last one.

For "add", the options are

- opcode 0x80
- opcode 0x81 with operand size override
- opcode 0x81 without operand size override
- opcode 0x83 with operand size override
- opcode 0x83 without operand size override

which it can't handle, despite it being obvious that if in the
"mov" case it picks the 32-bit variant, after eliminating all
non-32-bit variants it would have left to select between a
single 0x81 and a single 0x83 case. This very selection is
also what it successfully handles if the programmer
used "addl", but without the suffix it can't - for no good
reason.

Btw., where is it specified that in AT&T 32-bit operand size
ought to be the default? Alone the fact that it used to be
that way in gas (or any other assembler) doesn't mean
that's correct. Imo, minmally a warning should be issued.

Jan

> [hjl@gnu-35 tmp]$ cat x.s
>  mov     $1, (%eax)
> [hjl@gnu-35 tmp]$ cat y.s
>  add     $1, (%eax)
> [hjl@gnu-35 tmp]$ cat x.s
>  mov     $1, (%eax)
> [hjl@gnu-35 tmp]$ gcc -c -m32 x.s
> x.s: Assembler messages:
> x.s:1: Error: no instruction mnemonic suffix given and no register
> operands; can't size instruction
> [hjl@gnu-35 tmp]$ cat y.s
>  add     $1, (%eax)
> [hjl@gnu-35 tmp]$ gcc -c -m32 y.s
> [hjl@gnu-35 tmp]$ objdump -dw y.o
> 
> y.o:     file format elf32-i386
> 
> 
> Disassembly of section .text:
> 
> 00000000 <.text>:
>    0:	83 00 01             	addl   $0x1,(%eax)
> [hjl@gnu-35 tmp]$
> 





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]