# run the assembly file in command-line;
$ nasm -f elf64 -o hello_wrld.o hello_wrld.asm
$ ld -m elf_x86_64 -o hello_wrld hello_wrld.o
$ ./hello_wrld
Hello, World!
$
Last active
April 24, 2024 04:31
-
-
Save janymuong/7f3ab96dd7fc61b3f230dea70d347fef to your computer and use it in GitHub Desktop.
print text to stdout in assembly: a sequence of four ASCII-encoded strings in x86 assembly.
This file contains 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
section .data | |
hello_msg db "Hello, World!", 10 ; define the message string with a newline | |
section .text | |
global _start | |
_start: | |
; prepare the arguments for the write system call | |
mov eax, 4 ; set the syscall number for write | |
mov ebx, 1 ; set the file descriptor to stdout | |
mov ecx, hello_msg ; set the message to print | |
mov edx, 14 ; set the message length | |
; invoke the write syscall to print the message | |
int 0x80 | |
; exit the program | |
mov eax, 1 ; set the syscall number for exit | |
xor ebx, ebx ; set the exit code to 0 | |
int 0x80 ; invoke the exit system call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment