gpt4 book ai didi

linux - 为什么我无法在 NASM 程序集中打印用户输入的数据?

转载 作者:太空宇宙 更新时间:2023-11-04 04:00:00 25 4
gpt4 key购买 nike

我正在尝试验证此示例中用户输入的长度(NASM):

section .bss
user_input resb 10

section .text
push ebp
mov ebp, esp

mov eax, 3 ;sys_read
mov ebx, 0 ;stdin
mov ecx, user_input
mov edx, 10
int 80h

cmp eax, 10
jg overflow
jmp done
overflow:
.
.
.
done:
mov eax, 1
int 80h

为什么这不起作用?

最佳答案

由于您的缓冲区是 10 个字节,并且您将长度放入 edx,因此返回值永远不会大于 10,并且您跳转到标签 done: 并退出。

您所显示的代码中没有任何内容可以打印出任何内容。

关于linux - 为什么我无法在 NASM 程序集中打印用户输入的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23305220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com