linux汇编stdin,汇编:从标准输入中读取整数,将其递增并打印到标准输出

我为IA32编写了以下汇编脚本。应该从stdin读取一个数字,将其递增并打印到stdout,但是它的行为不符合预期,它不会打印任何内容(也许从stdin的读取不会终止,或者打印有问题吗?)

.section .text

.globl _start

_start:

movl $3, %eax # use syscall 3 (read) to read from stdin

movl $0, %ebx # reads from stdin (FD 0)

movl %edi, %ecx # store input in register %edi

movl $4, %edx # read one byte

int $0x80 # invoke system call to read from stdin

incl %edi # increment the value we got from stdin

movl $4, %eax # use syscall 4 (write) to print to screen

movl $1, %ebx # print to stdout (FD 1)

movl %edi, %ecx # pointer to text to write out

movl $4, %edx # length of text to write out (1 byte)

int $0x80 # invoke system call to write to stdout

movl $1, %eax # use syscall 1 (exit) to exit

movl $0, %ebx # error code = 0

int $0x80 # invoke system call

看到错误了吗?对于任何帮助,我要先感谢您,

祝一切顺利,西蒙

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值