-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_char.s
More file actions
43 lines (38 loc) · 705 Bytes
/
print_char.s
File metadata and controls
43 lines (38 loc) · 705 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
.intel_syntax noprefix
.global print_char
.data
char:
.byte 0
.align 2
str:
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.align 2
.text
print_char:
mov [char + rip], rdi # mov char from resistor to memory
mov rax, 0x1 # write
mov rdi, 0x1 # file discriptor
lea rsi, [char + rip] # address of char
mov rdx, 0x1 # length
syscall
ret
/*
prints:
# rdi : const void * (char)
# rsi : str_length
mov rcx, 0 # file discriptor
prints_loop:
add rax, str
add rax, rcx
mov [rax], rdi
cmp rcx, rsi
je prints_call
inc rcx
jmp prints_loop
prints_call:
mov rdx, rsi # length
lea rsi, [str + rip] # pointer of first address
mov rax, 0x1 # write
syscall
ret
*/