PATCH: PR gas/10637: x86 assembler failed to handle [addr] in Intel mode

H.J. Lu hjl.tools@gmail.com
Tue Sep 15 16:54:00 GMT 2009


On Tue, Sep 15, 2009 at 8:58 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Sep 15, 2009 at 7:09 AM, Jan Beulich <JBeulich@novell.com> wrote:
>>>>> "H.J. Lu" <hjl.tools@gmail.com> 15.09.09 15:46 >>>
>>>I will take a look.
>>>
>>>Please tell me which version masm you used. Mine doesn't
>>>take [] as immediate.
>>
>> I used 8.00.50727.42, 7.10.3077, and 7.00.9466 - which all give the
>> same result.
>>
>
> For MASM 8.00.50727.42, we got
>
>
>      OPTION DOTNAME
> _TEXT SEGMENT      'CODE'
>       ALIGN     16
>      PUBLIC f1
> f1    PROC
>        mov       eax, 1
>        mov       eax, [1]
>        mov       eax, DWORD PTR [1]
>        mov       eax, DWORD PTR 1
>        ret
>        ALIGN     16
> ::
> f1 ENDP
> _TEXT ENDS
> _DATA SEGMENT      'DATA'
> _DATA ENDS
> _DATA SEGMENT      'DATA'
> _DATA ENDS
> EXTRN __ImageBase:PROC
>      END
>
> MASM produces this:
>
> f1:
>  0000000000000000: B8 01 00 00 00     mov         eax,1
>  0000000000000005: 8B 04 25 01 00 00  mov         eax,dword ptr [00000001h]
>                    00
>  000000000000000C: 8B 04 25 01 00 00  mov         eax,dword ptr [00000001h]
>                    00
>  0000000000000013: B8 01 00 00 00     mov         eax,1
>  0000000000000018: C3                 ret
>  0000000000000019: 0F 1F 80 00 00 00  nop         dword ptr [rax+00000000h]
>                    00
>
> It doesn't match you what you described. Can you try our test?
>

Apparently, x86-64 MASM and ia32 MASM behave differently. x86-64 MASM
treats [0x8000] as memory while ia32 MASM treats [0x8000] as immediate
value. My questions are

1. Should x86 GNU assembler treat [0x8000] the same for both 32bit and
64bit?
2. If yes, how should we treat [0x8000]?

Personally, I think we should treat [0x8000] the same. Since we have
been treating [0x8000] as memory for a long time, we should keep
treating [0x8000] as memory.

Thanks.

-- 
H.J.



More information about the Binutils mailing list