I'm writing a x86 (32-bit) assembly program to read two characters from the user and then print them. I'm using syscalls for reading and writing, but my program only waits for the first input and then exits without waiting for the second input:
section .data
input_buffer1 db 0 ;will store ASCII for the first number from 0 to 9
input_buffer2 db 0
section .text
global _start
_start:
mov ecx, input_buffer1
call input
call write
mov ecx, input_buffer2
call input
call write
call exit
sys_call:
xor ebx, ebx
mov edx, 1
int 0x80
ret
input:
mov eax, 3
call sys_call
ret
write:
mov eax, 4
call sys_call
ret
exit:
mov eax, 1
xor ebx, ebx
int 0x80
ret
When I run this program, it waits for the first input, prints it, and then exits immediately without waiting for the second input. What is the issue with my code, and how can I fix it so that my program waits for the second input as intended? I tried asking chat gpt, but none of its suggestions, such as changing the terminal's settings, work.
Note: I'm using NASM as my assembler and Ubuntu 22.04, which I don't know if it's relevant.