# using C library calls
.section .data
output:
.asciz "The processor Vendor ID is '%s'\n"
.section .bss
.lcomm buffer, 12 # .lcomm把它声明为12个字节的缓冲区
.section .text
.globl _start
_start:
movl $0, %eax
cpuid
movl $buffer, %edi
movl %ebx, (%edi)
movl %edx, 4(%edi)
movl %ecx, 8(%edi)
push $buffer
push $output
call printf
add $8, %esp
push $0
call exit
# as -o printf.o printf.s
# ld -dynamic-linker /lib/ld-linux.so.2 -o printf -lc printf.o
或者把.globl _start改成.globl main后直接使用gcc编译,
# gcc -o printf printf.s