From 94abf75cfb9668bbb008dca31659b89d6a5fd274 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Tue, 9 Jan 2024 20:21:14 -0800 Subject: [PATCH] (stdlib) Updated string routines --- cli/stdlib/stdlib.tal | 70 ++++++++++++++----------------------------- 1 file changed, 22 insertions(+), 48 deletions(-) diff --git a/cli/stdlib/stdlib.tal b/cli/stdlib/stdlib.tal index 3abd5c3..5496280 100644 --- a/cli/stdlib/stdlib.tal +++ b/cli/stdlib/stdlib.tal @@ -72,42 +72,33 @@ ( @|stdlib ) -@scap ( str* -- end* ) - LDAk ?&w - JMP2r - &w ( -- ) - INC2 LDAk ?&w +@scap ( str* -: end* ) + INC2 & LDAk ?scap JMP2r -@sput ( chr str* -- ) - scap INC2k #00 ROT ROT STA +@slen ( str* -: len* ) + DUP2 scap/ SWP2 SUB2 JMP2r + +@ ( src* dst* -: ) + STH2 + &w ( src* `dst* -- ) + LDAk #00 STH2kr STA2 + INC2r INC2 LDAk ?&w + POP2 POP2r JMP2r + +@ ( chr str* -: ) + STH2 + #00 STH2r scap/ STA2 + JMP2r + +@ ( str* -: ) + STH2 + #00 STH2r + &w ( -- ) + STAk INC2 LDAk ?&w STA JMP2r -@slen ( str* -- len* ) - DUP2 scap SWP2 SUB2 JMP2r - -@scat ( src* dst* -- ) - scap - -@scpy ( src* dst* -- ) - OVR2 LDA ?&e - POP2 POP2 JMP2r - &e STH2 - &w ( -- ) - LDAk STH2kr STA - INC2r INC2 LDAk ?&w - POP2 #00 STH2r STA - JMP2r - -@sclr ( str* -- ) - LDAk ?&w - POP2 JMP2r - &w ( -- ) - STH2k #00 STH2r STA - INC2 LDAk ?&w - POP2 JMP2r - @scmp ( a* b* -- f ) STH2 &l ( -- ) @@ -116,23 +107,6 @@ LDAk LDAkr STHr NEQ ?&d INC2 INC2r !&l -@scmp-fast ( a* b* -- f ) - STH2 - &l ( -- ) - LDAk ?{ - &d LDA LDAr STHr EQU JMP2r } - LDA2k LDA2kr STH2r NEQ2 ?{ - INC2 INC2 INC2r INC2r !&l } - LDA2 LDA2r STH2r EQU2 JMP2r - -@scmp-old ( a* b* -- f ) - STH2 - &l ( -- ) - LDAk LDAkr STHr ANDk #00 EQU ?&e - NEQk ?&e - POP2 INC2 INC2r !&l - &e NIP2 POP2r EQU JMP2r - @sdec ( str* -- val* ) [ LIT2r 0000 ] &w ( -- )