-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.asm
40 lines (32 loc) · 932 Bytes
/
example.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
; fasm example.asm
; chmod +x example.bin
include 'elf_x86.inc'
include 'syscall.inc'
include 'unistd.inc'
empty_section_header = 0x0 ; Offset to section header
program_base = 0x700000
org program_base
use32
file_header:
elf elf_file_header entry_point,\
program_header,\
empty_section_header,\
elf_program_header_entry_size,\
program_header_size / elf_program_header_entry_size,\
0, 0
program_header:
ph elf_program_header program_base, program_end, bss, PF_RWX
program_header_size = $ - program_header
entry_point:
mov ecx, msg
mov edx, msg_size
mov eax, sys_write
mov ebx, STDOUT
int 0x80
mov eax, sys_exit
xor ebx, ebx
int 0x80
msg db 'Hello world!', 0x0A
msg_size = $ - msg
bss:
program_end: