As the title suggests, I want to better understand the following assembly code:
section .text
global main ; must be declared for linker (gcc)
main: ; tell linker entry point
mov edx, len ; message length
mov ecx, msg ; message to write
mov ebx, 1 ; file descriptor (stdout)
mov eax, 4 ; syscall for write (sys_write)
int 0x80 ; call kernel
mov edx, 9 ; message length
mov ecx, s2 ; message to write
mov ebx, 1 ; file descriptor (stdout)
mov eax, 4 ; syscall number for write (sys_write)
int 0x80 ; call kernel
mov eax, 1 ; system call (sys_exit)
int 0x80 ; call kernel
section .data
msg db 'Displaying 9 stars', 0xa ; a message
len equ $ - msg ; length of message
s2 times 9 db '*'
As you can see I already have descriptions in the comments from the tutorial I found here. Here are some of the things I don't understand:
-
- What is s2? Is this just a variable or a register I know nothing about?
-
When '1' is moved into ebx, is this a parameter to the sys_exit later called in eax? I found a listing of Linux syscalls here and it does seem sys_exit does take one parameter in ebx that's an integer. If this is the case why not exit cleanly with zero?
I just want to make sure I understand everything correctly in this. Thanks in advance!