summaryrefslogtreecommitdiff
path: root/03/in03
blob: a8d874410f8ec96304aaa5d78e2faf25de7f0cd9 (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
30
31
32
33
34
35
B=:hello_world
call :puts
; exit code 0
J=d0
syscall x3c

:hello_world
str Hello, world!
xa
x0

; output null-terminated string in rbx
:puts
	R=B
	call :strlen
	D=A
	I=R
	J=d1
	syscall d1
	return

; calculate length of string in rbx
:strlen
	; keep pointer to start of string
	D=B
	I=B
	:strlen_loop
	C=1I
	?C=0:strlen_loop_end
	I+=d1
	!:strlen_loop
	:strlen_loop_end
	I-=D
	A=I	
	return