GNU Assembler (gas) on x86_64

Marc Lijour marc-bbkyySd1vPWsTnJN9+BGXg at public.gmane.org
Sun Dec 17 11:53:34 UTC 2006


Hi

I try to follow Richard Blum "Assembly Language" book (Wrox) which focuses on 
Linux and GNU gas -which is a very good thing.

However, my platform is x86_64, not i686. I could tweak the code a little bit 
to avoid segfault by using information gathered at 
http://www.x86-64.org/documentation/assembly . Now the code looks like this:

# Using printf from libc
.section .data
output:
        .asciz "The processor Vendor ID is '%s'\n"

.section .bss
        .lcomm  buffer, 12
.section .text
.globl _start
_start:
        nop
        movq    $0, %rax
        cpuid
        movq    $buffer, %rdi
        movq    %rbx, (%rdi)
        movq    %rdx, 4 (%rdi)
        movq    %rcx, 8 (%rdi)
        pushq   $buffer
        pushq   $output
        call    printf
        addq    $8, %rsp
        pushq   $0
        call    exit

The unmodified example from the book gives this result on Intel i686:
$ ./cpuid2_i686
The processor Vendor ID is 'GenuineIntel'

But the code above gives me this on my AMD64:
$ ./cpuid2_x86_64
AuthenticAMD

(followed by no newline)

Question: why is the string (label output) not used by printf??

Google failed me on this...

May be there are some assembly programming gurus on the list?

Marc
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list