Thanks iSouvik, that link was very helpful.
My new question is quite complex:
Code:
section .data
hello: db 'Hello',10 ; 'Hello' plus a linefeed character
helloLen: equ $-hello ; Length of the 'Hello' string
theinput: db ''
section .text
global _start
_start:
mov eax, 4 ; The system call for write (sys_write)
mov ebx, 1 ; File descriptor 1 - standard output
mov ecx, hello ; Move the string 'Hello' to ecx to be printed
mov edx, helloLen ; Move the length of 'Hello' to edx to be printed
int 80h ; Display Hello
mov eax, 3 ; The system call for read (sys_read)
mov ecx, theinput ; Variable where input is saved
mov edx, 10 ; Length in bytes of the input
int 80h ; Get input
mov eax,4 ; The system call for write (sys_write)
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 can get the input and save it in the variable 'theinput'.
However, how would I display it after?
Code:
mov eax, 4 ; For the system call write
mov ecx, theinput ;Save the variable to write in ecx
mov edx, -----------------
Instead of all the dashes I need the size of the variable "theinput", but I'm not quite sure of how to get it.
Thanks
EDIT
I tried this but no luck, any ideas?:
Code: section .data
hello: db 'Hello',10 ; 'Hello' plus a linefeed character
helloLen: equ $-hello ; Length of the 'Hello' string
theinput: db '' ; Declare string input
section .text
global _start
_start:
mov eax, 4 ; The system call for write (sys_write)
mov ebx, 1 ; File descriptor 1 - standard output
mov ecx, hello ; Move the string 'Hello' to ecx to be printed
mov edx, helloLen ; Move the length of 'Hello' to edx to be printed
int 80h ; Display Hello
mov eax, 3 ; The system call for read (sys_read)
mov ecx, theinput ; Variable where input is saved
mov edx, 4 ; Length in bytes of the input
int 80h
mov eax,4 ; The system call for write (sys_write)
mov eax, 4 ; For the system call write
mov ecx, theinput ; Save the variable to write in ecx
mov edx, 4 ; Fixed input length
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
[/b]