blob: ef0640ae570b6458549201bd48e8686d80a4f43b (
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
|
; write to stdout
B=:hello_world
call :puts
J=d0
syscall x3c
:hello_world
str Hello, world!
xa
x0
; output null-terminated string in rbx
:puts
call :strlen
I=D
D=A
J=d1
syscall d1
return
; calculate length of string in rbx
; keeps pointer to start of string in rdx, end of string in rsi
: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
|