One of my problems was the file descriptor for stdout (now I see it's 0, thanks christop), which I couldn't find online.
Thank you a lot for the sample
I tried something a bit more complex now:
Code: section .bss
username: resb 128 ; Declare username input
password: resb 128 ; Declare password input
section .data
usernameText: db "Username: " ; Declare the text Username variable
passwordText: db "Password: " ; Declare the text Password variable
section .text
global _start
_start:
mov eax, 3 ; The system call for read (sys_read)
mov ebx, 0 ; File descriptor 0 - standard input
mov ecx, username ; Variable where input is saved
mov edx, 128 ; Length in bytes of the input
int 80h
mov edx, eax ; input length (read system call returns
; the number of bytes that it read in eax)
mov eax, 3 ; The system call for read (sys_read)
mov ebx, 0 ; File descriptor 0 - standard input
mov ecx, password ; Variable where input is saved
mov edx, 128 ; Length in bytes of the input
int 80h
mov edx, eax ; input length (read system call returns
; the number of bytes that it read in eax)
mov eax, 4
mov ebx,1
mov ecx, usernameText
int 80h
mov eax, 4 ; The system call for write (sys_write)
mov ebx, 1 ; File descriptor 1 - standard output
mov ecx, username ; Save the variable to write in ecx
int 80h
mov eax, 4
mov ebx,1
mov ecx, passwordText
int 80h
mov eax, 4 ; The system call for write (sys_write)
mov ebx, 1 ; File descriptor 1 - standard output
mov ecx, password ; Save the variable to write in ecx
int 80h
mov eax, 1 ; The system call for exit (sys_exit)
mov ebx, 0 ; Exit with return code of 0 (no error)
int 80h ; Exit program
But here's a sample run:
Code: ephan // I write "ephan"
mysecretpassword // I write "mysecretpassword"
Username: Passworephan
Password: ephan
mysecretpassword
I coded it so that the output would be:
Code:
Username: ephan
Password: mysecretpassword