Created
July 8, 2011 14:56
-
-
Save zliuva/1072017 to your computer and use it in GitHub Desktop.
An x86_64 OS X port of the cpuid example found in Ch. 4 of Professional Assembly
This file contains 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
# cpuid.s | |
# An x86_64 OS X port of the cpuid example found in Ch. 4 of Professional Assembly Language | |
# | |
# $ as -o cpuid.o cpuid.s | |
# $ ld -o cpuid cpuid.o | |
# $ ./cpuid | |
# GenuineIntel | |
# $ | |
.data | |
output: | |
.asciz "\0\0\0\0\0\0\0\0\0\0\0\0\n" | |
len: | |
.long len - output | |
.text | |
.globl start | |
start: | |
xor %rax, %rax | |
cpuid | |
leaq output(%rip), %rsi | |
movl %ebx, (%esi) | |
movl %edx, 4(%esi) | |
movl %ecx, 8(%esi) | |
movq len(%rip), %rdx | |
# leaq output(%rip), %rsi # %rsi already contains address of output | |
movq $0x1, %rdi # STDOUT | |
movq $0x02000004, %rax # write | |
syscall | |
movq $0x0, %rdi | |
movq $0x02000001, %rax # exit | |
syscall |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment