lang-bootstrap/03/in03

36 lines
451 B
Text
Raw Normal View History

2021-11-13 14:32:00 -05:00
; write to stdout
B=:hello_world
call :puts
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
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