Skip to content

Commit

Permalink
Add README
Browse files Browse the repository at this point in the history
Signed-off-by: 0x4248 <60709927+0x4248@users.noreply.github.com>
  • Loading branch information
0x4248 committed Dec 12, 2024
1 parent 03cba24 commit 94dc2a6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions asm/x64-linux/return/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
return
======

Returning 0 from main using basic assembly

Source code structure
---------------------

In the program we only run three instructions


We first move the value 60 to the rax register, this will tell linux that we
want to exit the program.

mov rax, 60

We then move the value 0 to the rdi register, this is the argument that we pass
into the exit syscall. The RDI register stores the code that's being used to exit.

mov rdi, 0

We then run the syscall instruction to exit the program.

syscall

The program will return 0 to the shell. We can confirm this by running the
program and then using echo $? to see the return value.


./return
echo $?

0 comments on commit 94dc2a6

Please sign in to comment.