2022-03-27 18:53:24 +00:00
|
|
|
( File:
|
|
|
|
Creates a temporary file called file-output.txt,
|
|
|
|
then read it back in console, print length and delete it. )
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
|a0 @File0 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
|
|
|
|b0 @File1 &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
|0100 ( -> )
|
2021-04-21 12:45:17 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
( write a file with file0 )
|
|
|
|
;filepath-txt .File0/name DEO2
|
|
|
|
;part1 ,append JSR
|
|
|
|
;part2 ,append JSR
|
|
|
|
( read a file with file1 )
|
|
|
|
;filepath-txt .File1/name DEO2
|
|
|
|
,stream JSR
|
|
|
|
( delete file with file0 )
|
|
|
|
;filepath-txt .File0/delete DEO2
|
2021-04-21 12:45:17 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
BRK
|
2021-04-21 12:45:17 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@append ( part* -- )
|
2021-04-21 12:45:17 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
DUP2 ;print-str JSR2
|
|
|
|
DUP2 ;slen JSR2 STH2k .File0/length DEO2
|
|
|
|
.File0/write DEO2
|
|
|
|
( print result )
|
|
|
|
;saved-txt ;print-str JSR2
|
|
|
|
STH2r ;print JSR2 #2018 DEO
|
|
|
|
;bytes-txt ;print-str JSR2 #0a18 DEO
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
JMP2r
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@stream ( -- )
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
#0001 .File1/length DEO2
|
|
|
|
LIT2r 0000
|
|
|
|
&stream
|
|
|
|
;&buf DUP2 .File1/read DEO2 LDA #18 DEO INC2r
|
|
|
|
.File1/success DEI2 #0000 NEQ2 ,&stream JCN
|
|
|
|
( print result )
|
|
|
|
;loaded-txt ;print-str JSR2
|
|
|
|
STH2r ;print JSR2 #2018 DEO
|
|
|
|
;bytes-txt ;print-str JSR2 #0a18 DEO
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
JMP2r
|
|
|
|
&buf $1
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@slen ( str* -- len* )
|
2021-04-21 18:38:30 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
DUP2 ,scap JSR SWP2 SUB2
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
JMP2r
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@scap ( str* -- end* )
|
|
|
|
|
|
|
|
LDAk #00 NEQ JMP JMP2r
|
|
|
|
&while INC2 LDAk ,&while JCN
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@print ( short* -- )
|
|
|
|
|
|
|
|
&short ( short* -- ) SWP ,&byte JSR
|
|
|
|
&byte ( byte -- ) DUP #04 SFT ,&char JSR
|
|
|
|
&char ( char -- ) #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO
|
|
|
|
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@print-str ( str* -- )
|
|
|
|
|
|
|
|
&while
|
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 LDAk ,&while JCN
|
|
|
|
POP2
|
2021-04-21 12:37:59 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
JMP2r
|
2021-07-07 20:20:14 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@saved-txt "Saved 20 $1
|
|
|
|
@loaded-txt "Loaded 20 $1
|
|
|
|
@bytes-txt "bytes. $1
|
|
|
|
@filepath-txt "file-output.txt $1
|
2021-07-07 20:20:14 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@part1
|
|
|
|
476f 6420 6865 6c70 2074 6865 2064 7265
|
|
|
|
616d 6572 2077 686f 7365 206d 6164 2076
|
|
|
|
6973 696f 6e73 2073 6865 770a 00
|
2021-04-21 18:38:30 +00:00
|
|
|
|
2022-03-27 18:53:24 +00:00
|
|
|
@part2
|
|
|
|
5468 6f73 6520 6465 6164 2065 7965 7320
|
|
|
|
7365 7420 696e 2063 7279 7374 616c 2067
|
|
|
|
756c 6673 2062 656c 6f77 210a 00
|