Hello World in Assembly x86


Hello World in assembly language. How much fun is in that! For starters, here’s what we’re going to dig into in asm, the classics:

#include <stdio.h>
int main(void)
{
    printf("Hello, world\n");
    return 0;
}

On GNU assembly it would be something like this:

######### write(1, message, 13) -> exit(0)

.data

msg:
    .ascii "Hello, world\n"


.text

.global _start
_start:                 # entry point

    mov     $1, %eax    # syscall 1 (write)
    mov     $1, %edi    # file handle 1 (stdout)
    mov     $msg, %esi  # string address
    mov     $13, %edx   # size in bytes
    syscall             # OS syscall

    mov     $60, %eax   # syscall 60 (exit)
    xor     %edi, %edi  # return 0
    syscall             # OS syscall

My vid about it:


This entry was posted in Assembly. Bookmark the permalink.

Leave a Reply

🇬🇧 Attention! Comments with URLs/email are not allowed.
🇷🇺 Комментарии со ссылками/email удаляются автоматически.