Hello, in the following code snippet, GAS assemble what should be a direct constant as it were a memory reference. binutils 2.15.90 GAS version 2.15.90 Platform Windows XP. Comments show the interesting line. Comments follow. _________________________________________________________________________ .intel_syntax noprefix .data Format: .asciz "FormatLen = %d - %d\n" FormatLen= . - Format # FormatLen=0x15 .text .global _main _main: push ebp mov ebp, esp # Following instruction assembles as # it were written: # push dword ptr [0x15] push FormatLen # whereas it should be just like: push 0x15 push offset Format call _printf add esp, 12 xor eax, eax mov esp, ebp pop ebp ret .end _________________________________________________________________________ Maybe that doesn't show up in AT&T syntax because constants are $-prefixed. As far as I know, Intel syntax is: - Load a constant (note no brackets): mov eax, 0x12 which should also be for symbolic constants - Load the value at the specified address (note brackets): mov eax, dword ptr [myLabel] - Load address (note the OFFSET keyword): mov eax, offset myLabel Thank you for your attention. And thank you all for your work aimed to allowing Windows users easy access to GNU tools.
Fixed on mainline
This bug has reappeared, or is still present (using .intel_syntax noprefix) GNU assembler version 2.22.51 (i686-cygwin) using BFD version (GNU Binutils) 2.2 2.51.20111013 Example: (test.s) -------------------------------------- .intel_syntax noprefix .text .equ A, 0xaaaa B = 0xbbbb mov ax, A mov ax, B mov ax, C mov ax, D .equ C, 0xcccc D = 0xdddd ------------------------------------- $ as test.s $ objdump -Mintel-mnemonic -d a.out ----------------------------------------------------- a.out: file format pe-i386 Disassembly of section .text: 00000000 <.text>: 0: 66 b8 aa aa mov ax,0xaaaa 4: 66 b8 bb bb mov ax,0xbbbb 8: 66 a1 cc cc 00 00 mov ax,ds:0xcccc e: 66 a1 dd dd 00 00 mov ax,ds:0xdddd ------------------------------------------------------ EXPECTED output: ----------------------------------------------------- 00000000 <.text>: 0: 66 b8 aa aa mov ax,0xaaaa 4: 66 b8 bb bb mov ax,0xbbbb 8: 66 b8 cc cc mov ax,0xcccc e: 66 b8 dd dd mov ax,0xdddd -----------------------------------------------------
The comment #2 testcase isn't fixable without a two-pass assembler or a change in assembly syntax.