I see what you did there, cool.
Speaking of calling programs in terminal, I tried to get arguments to a program. I read online that the first element in stack is the number of arguments (argc) and after it there are argc elements.
I tried the following to print out the first argument, but it failed:
Code:
The comments should help you understand it. I would like to know if any of you knows why it doesn't work, I called it "./arguments hello".
Speaking of calling programs in terminal, I tried to get arguments to a program. I read online that the first element in stack is the number of arguments (argc) and after it there are argc elements.
I tried the following to print out the first argument, but it failed:
Code:
section .text
global _start
_start:
pop rax ; Pop rax (argc)
pop rax ; Pop rax (first argument)
mov ecx, eax ; Move first argument to ecx, to be printed
mov eax, 4 ; sys_write
mov edx, 1 ; File descriptor: 1
int 80h ; Display first argument
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
The comments should help you understand it. I would like to know if any of you knows why it doesn't work, I called it "./arguments hello".