+ -
当前位置:首页 → 问答吧 → 汇编如何call printf

汇编如何call printf

时间:2010-12-09

来源:互联网

rt~

作者: soliddream66   发布时间: 2010-12-09

有个cpuid.s例子
Assembly code

.section .data
output:
    .asciz "the processor vendor ID is '%s'\n"
.section .bss
    .lcomm buffer,12
.section .text
.globl _start
_start:
  movl $0,%eax
  cpuid
  movl $buffer,%edi
  movl %ebx,(%edi)
  movl %edx,4(%edi)
  movl %ecx,8(%edi)
  pushl $buffer
  pushl $output
  call printf
  addl $8,%esp
  pushl $0
  call exit


编译
$as -o cpuid.o cpuid.s
$ld -dynamic-linker /lib/ld-linux.so.2 -o cpuid -lc cpuid.o

作者: gjx01212   发布时间: 2010-12-09

导入 msvcrt.dll 就可以call

作者: leezjnu008   发布时间: 2010-12-09