Printf 带气体组件 [英] Printf with gas assembly

查看:47
本文介绍了Printf 带气体组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么如果字符串末尾缺少 \n(LF - newline),我无法在 GAS 程序集中用 printf 打印任何内容.如果我把换行符 \n 打印出来,但如果我删除 \n 行不打印.谁能告诉我为什么?

I don't know why I cannot print anything with printf in GAS assembly if \n(LF - newline) is missing at the end of the string. If I put the newline char \n the line prints, but if I remove \n the line doesn't print. Can someone tell me why?

.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

推荐答案

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

这篇关于Printf 带气体组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆