Wrox Programmer Forums
|
BOOK: Professional Assembly Language
This is the forum to discuss the Wrox book Professional Assembly Language by Richard Blum; ISBN: 9780764579011
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Assembly Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2006, 08:04 AM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default AMD64

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.










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.