summaryrefslogtreecommitdiff
path: root/nasm/helloworld.asm
diff options
context:
space:
mode:
authorgarhve <git@garhve.com>2022-12-14 19:55:37 +0800
committergarhve <git@garhve.com>2022-12-14 19:55:37 +0800
commit600bef43c9d67dfcd6a884306c19121bec0235a7 (patch)
treed515a887f3a438a8156f960379bd89795ebd675b /nasm/helloworld.asm
parente654642d76e08a6a6b0517022eaeab29c5819c46 (diff)
remove a.out
Diffstat (limited to 'nasm/helloworld.asm')
-rwxr-xr-xnasm/helloworld.asm31
1 files changed, 14 insertions, 17 deletions
diff --git a/nasm/helloworld.asm b/nasm/helloworld.asm
index 3016f58..48755fb 100755
--- a/nasm/helloworld.asm
+++ b/nasm/helloworld.asm
@@ -1,17 +1,14 @@
-SECTION .data
-msg db "Hello World!", 0Ah ;
-
-SECTION .text
-global _start
-
-_start:
-
- mov edx, 13 ; number of bytes to write
- mov ecx, msg ; move memory address of 'msg' to ecx
- mov ebx, 1 ; write to the file STDOUT
- mov eax, 4 ; invoke SYS_WRITE (kernel opcode 4)
- int 80h
-
- mov ebx, 0 ;
- mov eax, 1 ;
- int 80h
+ global _start
+
+ section .text
+_start: mov rax, 1 ; system call for write
+ mov rdi, 1 ; file handle 1 is stdout
+ mov rsi, msg ; address of string to output
+ mov rdx, 13 ; number of bytes
+ syscall ; invoke operating system to do the write
+ mov rax, 60 ; system call for exit
+ xor rdi, rdi ; exit code 0;
+ syscall ; invoke operating system to exit
+
+ section .data
+msg db "hello, world",10 ; note the new line at end