我正在尝试使用 NASM 汇编语言中的系统调用创建自己的获取和放置函数。到目前为止,puts 函数在这段代码中工作得很好,但我无法让终端在 gets 函数中等待来自键盘的输入。
global start
SECTION .text
SECTION .data
prompt1: db "We will make you a box. How tall would you like it to be?", 0
length1: equ $-prompt1
prompt2: db "How wide would you like it to be?" , 0
length2: equ $-prompt2
input: dd 0
start:
mov edi, prompt1
mov esi, length1
call puts
mov edi, input
mov esi, 4
call gets
mov eax, 0
ret
puts:
mov dword [esp], 1
mov dword [esp+8], esi
mov dword [esp+4], edi
mov eax, 0x4
sub esp, 4
int 0x80
add esp, 16
ret
gets:
mov dword [esp], 0
mov dword [esp+4], esi
mov dword [esp+8], edi
mov eax, 3
sub esp, 4
int 0x80
add esp, 16
ret
这是输出:我们将为您制作一个盒子。你希望它有多高?
但它不会提示输入...请帮助!