-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.asm
More file actions
59 lines (47 loc) · 865 Bytes
/
Copy pathmain.asm
File metadata and controls
59 lines (47 loc) · 865 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
format elf64 executable
include "macros.inc"
macro syscall1 number, arg1 {
mov rax, number
mov rdi, arg1
syscall
}
macro syscall2 number, arg1, arg2 {
mov rax, number
mov rdi, arg1
mov rsi, arg2
syscall
}
macro syscall3 number, arg1, arg2, arg3 {
mov rax, number
mov rdi, arg1
mov rsi, arg2
mov rdx, arg3
syscall
}
macro exit code {
sys_exit = 60
syscall1 sys_exit, code
}
macro write fd, buf, len {
sys_write = 1
syscall3 sys_write, fd, buf, len
}
STDIN_FILENO = 0
STDOUT_FILENO = 1
STDERR_FILENO = 2
EXIT_SUCCESS = 0
EXIT_FAILURE = 1
entry _start
_start:
for r14, 10, 0, -1
for r15, 0, 5, 1
write STDOUT_FILENO, hello, hello.len
endfor
endfor
exit EXIT_SUCCESS
struc cstr [data] {
common
. db data,0
.len = $ - . - 1
}
hello cstr 'hello',10