Hi
I am trying the first examples on my AMD64 platform.
cpuid.s works out of the box (the debugging with gdb and the call to info registers show different registers but that is to be expected with a different architecture).
The problems start with cpuid2.s. I modified the code to have it compiled on AMD64 (as was complaining about pushl) according to
http://www.x86-64.org/documentation/assembly as follows:
# 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 call to the linker is a little different because it links with the 64-bit loader instead:
ld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -lc -o cpuid2_x86_64 cpuid2_x86_64.o
Now running the binaries:
$ ./cpuid2_x86_64
AuthenticAMD
My question is this: why printf does not display the first part of the string? What happened to the stack?
I can't find any documentation about libc calls on AMD64.
Thank you.