# fun(%rdi, %rsi, %rdx)

# execve cat /etc/passwd
# execve(path, argv, envp)
movq $59, %rax

# argp should contain 2 values: {"/bin/cat", "/etc/passwd", NULL}
# this is argp:
leaq 2(%rip), %rbx
jmp args_after

args:
        .ascii "/etc/passwd\0"
args_after:

pushq	$0 # null-terminated
pushq	%rbx

# this is command:
leaq  2(%rip), %rdi
jmp cat_after

cat:
        .ascii "/bin/cat\0"
cat_after:

pushq	%rdi # so that the top of stack (which will be argv) points to a pointer to cat first
movq	%rsp, %rsi

movq %rsp, %rsi
xorq %rdx, %rdx

syscall

# A wait loop when the arguments to the syscall are wrong and it fails, so I can attach a debugger...
loop:
	jmp loop


