Printf与气体组件

时间:2016-05-25 20:03:05

标签: linux assembly printf x86-64 gas

如果字符串末尾缺少printf(LF - 换行符),我不知道为什么我无法在GAS汇编中使用\n打印任何内容。如果我将换行符\n打印出行,但如果我删除了\n,则该行不会打印。有人可以告诉我为什么吗?

.extern printf
.section .data

hello:
    .string "Hello!" # doesn't print this way when \n is missing

.section .text

.globl _start

_start:
    nop
    movl $hello, %edi
    movl $0, %eax
    call printf

_end:    
    movq $60, %rax  #use the _exit syscall
    movq $0, %rdi   #return error code 0
    syscall         #make syscall

1 个答案:

答案 0 :(得分:-1)

pushl %ebp
lea   hello, %edi
movl  %esp, %ebp /*<----*/
call  printf
popl  %ebp