2018-04-25 14:56:08 +00:00
|
|
|
;; Hello World Program #1
|
2018-04-26 02:40:23 +00:00
|
|
|
;; Compile with: nasm -f elf hello.s
|
2018-04-25 14:56:08 +00:00
|
|
|
;; Link with: ld -m elf_i386 -o hello hello.o
|
|
|
|
;; Run with: ./hello
|
|
|
|
|
2018-04-25 15:41:35 +00:00
|
|
|
;; sys/unistd_32.h
|
2018-04-25 14:56:08 +00:00
|
|
|
%define SYS_write 4
|
|
|
|
%define SYS_exit 1
|
|
|
|
|
|
|
|
;; 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 edx, len
|
2018-04-25 15:41:35 +00:00
|
|
|
mov ecx, msg ; Address of the message (not the content)
|
2018-04-25 14:56:08 +00:00
|
|
|
mov ebx, STDOUT ; using STDOUT (see definition above)
|
|
|
|
mov eax, SYS_write ; Using WRITE in 32-bit mode?
|
2018-04-25 15:41:35 +00:00
|
|
|
int 80h ; Interrupt target. The 'h' means 'hexidecimal'
|
2018-04-25 14:56:08 +00:00
|
|
|
|
|
|
|
mov ebx, 0
|
|
|
|
mov eax, SYS_exit
|
2018-04-25 15:41:35 +00:00
|
|
|
int 80h
|
2018-04-25 14:56:08 +00:00
|
|
|
|
|
|
|
|