From 173ceddcaa470b926db2a5d8c5ccc817a1ce2544 Mon Sep 17 00:00:00 2001 From: Tai Husk <171867146+TaiHusk@users.noreply.github.com> Date: Sat, 29 Jun 2024 11:13:05 +0300 Subject: [PATCH] Pull Request: `nasm-hello.asm` -> `hello_nasm.asm` (#6667) --- examples/assembly/hello_nasm.asm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/assembly/hello_nasm.asm diff --git a/examples/assembly/hello_nasm.asm b/examples/assembly/hello_nasm.asm new file mode 100644 index 000000000..b9bc79ad4 --- /dev/null +++ b/examples/assembly/hello_nasm.asm @@ -0,0 +1,30 @@ +; ------------------------------------------------------------------- +; hello.asm +; +; Simple "Hello, world!" program for NASM 2.16.01 (32-bit) +; +; Assemble and link with: +; nasm -f elf32 hello.asm -o hello.o +; ld -m elf_i386 hello.o -o hello +; ------------------------------------------------------------------- + +global _start + +section .text +_start: + ; Write "Hello, world!" to stdout (file descriptor 1) + mov eax, 4 ; sys_write + mov ebx, 1 ; stdout + mov ecx, msg ; message address + mov edx, len ; message length + int 0x80 ; call kernel + + ; Exit program + mov eax, 1 ; sys_exit + mov ebx, 0 ; exit code 0 + int 0x80 ; call kernel + +section .data + msg: db "Hello, world!", 0xa + len: equ $ - msg ; Calculate message length + \ No newline at end of file