This commit is contained in:
pommicket 2022-01-06 14:02:30 -05:00
parent 8c6b19fdd3
commit db552a4dca
2 changed files with 34 additions and 14 deletions

View file

@ -140,6 +140,13 @@ call :string=
D=A D=A
?D!0:handle_byte ?D!0:handle_byte
I=:line
J=:"string"
C=x20
call :string=
D=A
?D!0:handle_string
; set delimiter to newline ; set delimiter to newline
C=xa C=xa
@ -227,6 +234,27 @@ align
:byte :byte
reserve d1 reserve d1
:handle_string
I=:line
; 7 = length of "string "
I+=d7
J=I
; find end of string
:string_loop
C=1J
D=xa
?C=D:string_loop_end
J+=d1
!:string_loop
:string_loop_end
; get length of string
D=J
D-=I
; output fd
J=d4
syscall x1
!:read_line
:handle_call :handle_call
J=I J=I
; just use the rvalue function call code ; just use the rvalue function call code
@ -1586,6 +1614,9 @@ align
:"byte" :"byte"
str byte str byte
x20 x20
:"string"
str string
x20
:"function" :"function"
str function str function
xa xa

View file

@ -43,26 +43,15 @@
; <term> < <term> (left shift) ; <term> < <term> (left shift)
; <term> > <term> (unsigned right shift) ; <term> > <term> (unsigned right shift)
syscall(1, 1, .str_hw, 14) syscall(1, 1, .str_hw, 14)
syscall(0x3c, 42) syscall(0x3c, 42)
:str_hw :str_hw
byte 'H string Hello, world!
byte 'e
byte 'l
byte 'l
byte 'o
byte ',
byte 32
byte 'w
byte 'o
byte 'r
byte 'l
byte 'd
byte '!
byte 10 byte 10
:syscall :syscall
function function
; I've done some testing, and this should be okay even if ; I've done some testing, and this should be okay even if