summaryrefslogtreecommitdiff
path: root/PGU/CHAP6_7/write-newline.s
blob: e916379208196178585c3e2b2e15b5c4b11253a5 (plain)
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
# Just write a newline (\n) to STDOUT

.include "linux.s"
.type write_newline, @function
.globl write_newline

.section .data

newline:
	.ascii "\n"

.section .text
	.equ ST_FILEDES, 16

write_newline:
	pushq %rbp
	movq %rsp, %rbp

	movq $SYS_WRITE, %rax
	movq ST_FILEDES(%rbp), %rdi
	movq $newline, %rsi
	movq $1, %rdx
	syscall

	movq %rbp, %rsp
	popq %rbp
	ret