diff options
author | pommicket <pommicket@gmail.com> | 2021-11-13 17:24:45 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2021-11-13 17:24:45 -0500 |
commit | 8bbacdc3316a54b5ef5805701098eb8e81d17986 (patch) | |
tree | 0ee2ef75141c7ce0b43072e9c277a0f251bb4584 /03/in03 | |
parent | eb2aadf9bfd14d95e27050bc24c6fb70c10d885e (diff) |
corrections in 03 compiler, better hello world program!
Diffstat (limited to '03/in03')
-rw-r--r-- | 03/in03 | 37 |
1 files changed, 29 insertions, 8 deletions
@@ -1,14 +1,35 @@ ; write to stdout -J=d1 -I=:hello_world -D=:hello_world_end -; calculate length by subtracting end from start -D-=I -syscall d1 -J=d42 +B=:hello_world +call :puts +J=d0 syscall x3c :hello_world str Hello, world! xa -:hello_world_end +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 |