System calls
write(1, msg, 14)
kernel
memory
cpu
source
hello.c
11
write(
1
, msg,
14
);
mov
eax, 1
mov
edi, 1
lea
rsi, [msg]
mov
edx, 14
syscall
12
return
0
;
registers
x86-64
0
0
0
0
5
5
d
4
a
1
c
0
1
1
5
c
rip
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
rax
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
rdi
0
0
0
0
5
5
d
4
a
1
c
0
2
0
0
4
rsi
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
e
rdx
which call
1st
2nd
3rd
four registers, read by the kernel
memory
read-only data
a1c0
2004
H
48
e
65
l
6c
l
6c
o
6f
,
2c
20
w
77
a1c0
200c
o
6f
r
72
l
6c
d
64
!
21
\n
0a
00
14 bytes, read by the kernel
user
kernel
syscall
the bytes
what it runs
tty_write
vfs_write
ksys_write
write
system call 1
rdi
fd
1
the terminal
rsi
buf
5
5
d
4
a
1
c
0
2
0
0
4
rdx
count
14
bytes
rax
returns
not yet
the terminal's buffer
H
e
l
l
o
,
w
o
9 of 14 copied
The program cannot reach the terminal. It leaves four numbers
in registers, and syscall hands them to the kernel.