Created
July 9, 2011 07:40
-
-
Save zliuva/1073421 to your computer and use it in GitHub Desktop.
calling libc functions on OS X x64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cpuid2.s | |
# calling libc functions on OS X x64 | |
# | |
# $ as -g -o cpuid2.o cpuid2.s | |
# $ ld -o cpuid2 -lc cpuid2.o | |
# $ ./cpuid2 | |
# Vendor ID: GenuineIntel | |
# $ | |
.data | |
_output: | |
.asciz "Vendor ID: %s\n" | |
.lcomm _vendor, 12 | |
.text | |
.globl start | |
start: | |
xorq %rbp, %rbp | |
pushq %rbp | |
xorq %rax, %rax | |
cpuid | |
leaq _vendor(%rip), %rsi | |
movl %ebx, (%esi) | |
movl %edx, 4(%esi) | |
movl %ecx, 8(%esi) | |
# leaq _vendor(%rip), %rsi | |
leaq _output(%rip), %rdi | |
xorq %rax, %rax | |
callq _printf | |
xorq %rdi, %rdi | |
callq _exit | |
hlt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment