2021-11-13 14:32:00 -05:00
|
|
|
; write to stdout
|
2021-11-13 17:24:45 -05:00
|
|
|
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
|
2021-11-13 13:56:26 -05:00
|
|
|
str Hello, world!
|
2021-11-13 13:48:27 -05:00
|
|
|
xa
|
2021-11-13 17:24:45 -05:00
|
|
|
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
|