2018-04-25 14:56:08 +00:00
|
|
|
;; Hello World Program #1
|
2018-04-26 02:40:23 +00:00
|
|
|
;; Compile with: nasm -f elf64 hello.s
|
|
|
|
;; Link with: ld -o hello hello.o
|
2018-04-25 14:56:08 +00:00
|
|
|
;; Run with: ./hello
|
|
|
|
|
2018-04-25 15:41:35 +00:00
|
|
|
;; sys/unistd_64.h
|
2018-04-25 14:56:08 +00:00
|
|
|
%define SYS_write 1
|
|
|
|
%define SYS_exit 60
|
|
|
|
|
|
|
|
;; unistd.h
|
|
|
|
%define STDOUT 1
|
|
|
|
|
|
|
|
section .data
|
|
|
|
msg db "Hello You Beautiful Human", 0Ah
|
2018-04-26 02:40:23 +00:00
|
|
|
len equ $-msg ; NASM-supplied macro
|
2018-04-25 14:56:08 +00:00
|
|
|
|
|
|
|
section .text
|
|
|
|
global _start
|
|
|
|
|
|
|
|
_start:
|
2018-04-26 02:40:23 +00:00
|
|
|
mov rdx, len ; Length of the message
|
2018-04-25 14:56:08 +00:00
|
|
|
mov rsi, msg ; Address of the message
|
|
|
|
mov rdi, STDOUT ; using STDOUT (see definition above)
|
|
|
|
mov rax, SYS_write ; Using WRITE in 32-bit mode?
|
|
|
|
syscall
|
|
|
|
|
|
|
|
mov rdi, 0
|
|
|
|
mov rax, SYS_exit
|
|
|
|
syscall
|
|
|
|
|