In gcc assembly, the main function can either return or exit, where both work. Here I have two programs, where one exits with a syscall int $0x80
, and the other simply calls ret. What is the difference?
.data
hello: .string "Hello, World!"
.globl main
main:
push %rbx
movq $hello, %rdi
call puts
pop %rbx
ret
and
.data
hello: .string "Hello, World!"
.globl main
main:
push %rbx
movq $hello, %rdi
call puts
pop %rbx
movq $1, %rax
movq $0, %rbx
int $0x80
I am aware that ret pops the instruction pointer off the stack, but what does that really do in this case?