(base64) Housekeeping

This commit is contained in:
neauoire 2023-09-05 15:44:49 -07:00
parent 584508fda5
commit 35d9b5a357
2 changed files with 28 additions and 19 deletions

View File

@ -21,37 +21,41 @@
@on-ready ( -> )
;src .File/name DEO2
#0001 .File/length DEO2
;&buf
&stream ( -- )
DUP2 .File/read DEO2
&s ( -- )
;&b .File/read DEO2
.File/success DEI2 #0000 EQU2 ?&eof
LDAk append !&stream
&eof POP2
[ LIT &b $1 ] b64enc !&s
&eof
( | pad )
.queue LDZ #00 EQU ?&>no-pad
#00 append &>no-pad
#00 b64enc &>no-pad
#0a18 DEO
#010f DEO
BRK &buf $1
BRK
(
@|core )
@append ( byte -- )
@b64enc ( byte -- )
,&buf STR
#0800
&l ( -- )
( ) [ LIT &buf $1 ] OVR #07 SWP SUB SFT #01 AND
( ) [ LIT &inc $1 ] INCk #06 DIVk MUL SUB ,&inc STR
( bit id -- ) SWP .queue LDZ ORA DUP ADD .queue STZ
#05 NEQ ?&>no-cap
[ LIT2 00 -queue ] DUP2 LDZ #01 SFT ;MIME ADD2 LDA #18 DEO
STZ &>no-cap
[ LIT &buf $1 ] OVR #07 SWP SUB SFT #01 AND
[ LIT &inc $1 ] INCk #06 DIVk MUL SUB ,&inc STR
( bit id -- )
SWP .queue LDZ ORA DUP ADD .queue STZ
#05 NEQ ?{
[ LIT2 00 -queue ]
DUP2 LDZ #01 SFT ;MIME ADD2 LDA #18 DEO
STZ }
INC GTHk ?&l
POP2 JMP2r
@MIME
[ "ABCDEFGHIJKLMNOP "QRSTUVWXYZabcdef "ghijklmnopqrstuv "wxyz0123456789+/ ]
@MIME [
"ABCDEFGHIJKLMNOP
"QRSTUVWXYZabcdef
"ghijklmnopqrstuv
"wxyz0123456789+/ ]
(
@|stdlib )
@ -62,12 +66,11 @@
&eval POP2 #01 JMP2r
@scap ( str* -- end* )
!&a
&w ( -- )
INC2 &a LDAk ?&w
INC2 & LDAk ?&w
JMP2r
@sput ( chr str* -- )
scap ROT #00 SWP2 STA2
scap/ ROT #00 SWP2 STA2
JMP2r

View File

@ -21,5 +21,11 @@ then
cp $DST $CPY
fi
echo -n "source: "
cat test.txt
echo ""
echo "target: TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcmsu"
echo -n "result: "
$EMU $DST $ARG