Code:
section .bss
username: resb 128 ; Declare username input
usernameInputSize: resb 4 ; Declare username input size
password: resb 128 ; Declare password input
passwordInputSize: resb 4 ; Declare password input size
section .data
usernameText: db "Username: " ; Declare the text Username variable
usernameTextSize: equ $-usernameText ; Length of usernameText
passwordText: db "Password: " ; Declare the text Password variable
passwordTextSize: equ $-passwordText ; Length of passwordText
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 [usernameInputSize], 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 [passwordInputSize], eax
mov eax, 4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx, usernameText ; Save the variable to write in ecx
mov edx, usernameTextSize ; Length in bytes of the output
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
mov edx, [usernameInputSize]
int 80h
mov eax, 4 ; The system call for write (sys_write)
mov ebx,1 ; File descriptor 1 - standard output
mov ecx, passwordText ; Save the variable to write in ecx
mov edx, passwordTextSize ; Length in bytes of the output
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
mov edx, [passwordInputSize]
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
I managed to use variables now. I think the next thing I wanna code is something related to time, I found some linux system calls for it.
Do you think it's a good idea or I should try something else now?
Thanks
Also, @Kerm: Writing x86 ASM on the 8th grade? wow...