Created
January 20, 2020 15:43
-
-
Save LevitatingBusinessMan/ec86df253369d6f2090aae9155c22c4f to your computer and use it in GitHub Desktop.
My attempt to make a hello world program in Assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Sources: | |
| ; https://youtu.be/HgEGAaYdABA | |
| ; Hello World Program - asmtutor.com | |
| ; Compile with: nasm -f elf32 -o hello_world.o hello_world.asm | |
| ; Link with (64 bit systems require elf_i386 option): ld -m elf_i386 hello_world.o -o hello_world | |
| ; Run with: ./helloworld | |
| ; #define __NR_exit 1 | |
| ; #define __NR_write 4 | |
| section .data: | |
| ; Define string in bytes (Hello world string + newline) | |
| msg db "Hello World!", 0xA | |
| ; equeals message length | |
| msg_len equ $-msg | |
| section .text: | |
| global _start | |
| _start: | |
| mov eax, 0x4 ; use the write syscall | |
| mov ebx, 0x1 ; use stdout as the file descriptor (fd) | |
| mov ecx, msg ; supply pointer to message | |
| mov edx, msg_len ; supply the length | |
| int 0x80 ; run syscall | |
| ; exit | |
| mov eax, 0x1 | |
| mov ebx, 0x0 | |
| int 0x80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment