lang-bootstrap/03/in03

36 lines
388 B
Text
Raw Permalink Normal View History

B=:hello_world
call :puts
2021-11-14 00:33:40 -05:00
; exit code 0
J=d0
2021-11-12 22:00:46 -05:00
syscall x3c
2021-11-13 13:00:35 -05:00
2021-11-13 13:48:27 -05:00
:hello_world
str Hello, world!
2021-11-13 13:48:27 -05:00
xa
x0
; output null-terminated string in rbx
:puts
2021-11-14 00:33:40 -05:00
R=B
call :strlen
D=A
2021-11-14 00:33:40 -05:00
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