-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.asm
More file actions
67 lines (53 loc) · 742 Bytes
/
hello.asm
File metadata and controls
67 lines (53 loc) · 742 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
60
61
62
63
64
65
66
67
section .data
text1 db "what is your name?",10
len1 equ $ - text1
text2 db "Hello ",10
len2 equ $ - text2
section .bss
name resb 16
msg resb 32
section .text
global _start
_start:
call _copy
call _print_hello
mov rax, 60
mov rdi, 0
syscall
_copy:
mov rsi, text2
mov rdi, msg
mov rcx, len2
dec rcx
rep movsb
call _ask_name
push rcx
mov rsi, name
lea rdi, [msg+len2]
dec rcx
rep movsb
mov byte [rdi],10
pop rcx
ret
_ask_name:
mov rax, 1
mov rdi, 1
mov rsi, text1
mov rdx, len1
syscall
mov rax, 0
mov rdi, 0
mov rsi, name
mov rdx, 16
syscall
mov rcx, rax
ret
_print_hello:
mov rax, 1
mov rdi, 1
mov rsi, msg
mov rdx, len2
add rdx, rcx
inc rdx
syscall
ret