From 2dbd3c449e4e48093e6e7550ca0b9abd8c5a3bcc Mon Sep 17 00:00:00 2001 From: Arpit Batra Date: Sun, 1 Oct 2017 23:42:55 +0530 Subject: [PATCH] Create hello_world.asm --- hello_world.asm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 hello_world.asm diff --git a/hello_world.asm b/hello_world.asm new file mode 100644 index 0000000..cd4953a --- /dev/null +++ b/hello_world.asm @@ -0,0 +1,26 @@ +; +;"hello, world" in assembly language for Linux +; +;to compile: +; +;nasm -f elf hello.asm +;ld -s -o hello hello.o + +section .text + global _start ;must be declared for linker (ld) + +_start: ;tell linker entry point + + mov edx,len ;message length + mov ecx,msg ;message to write + mov ebx,1 ;file descriptor (stdout) + mov eax,4 ;system call number (sys_write) + int 0x80 ;call kernel + + mov eax,1 ;system call number (sys_exit) + int 0x80 ;call kernel + +section .data + +msg db 'Hello, world!',0xa ;our dear string +len equ $ - msg ;length of our dear string