uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 0c6b607f9146ca3428cbd1d1da973784204ee2e7
parent be2e01e9b3adca7c8b6a71b2e59c2f9612da25bd
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Wed,  6 Oct 2021 06:54:03 +0100

Extracted string library from asma

Diffstat:
Mprojects/library/binary-tree.tal | 17-----------------
Aprojects/library/string.tal | 28++++++++++++++++++++++++++++
Mprojects/software/asma.tal | 35+++++++++++------------------------
3 files changed, 39 insertions(+), 41 deletions(-)

diff --git a/projects/library/binary-tree.tal b/projects/library/binary-tree.tal @@ -54,20 +54,3 @@ found: STH2r ADD2 ( incoming-ptr* / search-key* ) ,&loop JMP -@strcmp ( a* b* -- a-end* b-end* order nonzero if strings differ - OR a-end* b-end* 00 00 if strings match ) - STH2 - ,&entry JMP - - &loop ( a* a b / b* ) - SUB ,&nomatch JCNk ( a* a-b nonzero / b* ) - POP2 ( a* / b* ) - INC2 INC2r - &entry ( a* / b* ) - LDAk LDAkr STHr ( a* a b / b* ) - ORAk ,&loop JCN - - &nomatch ( a* a-b flag / b* ) - STH2r SWP2 ( a* b* a-b flag ) - JMP2r - diff --git a/projects/library/string.tal b/projects/library/string.tal @@ -0,0 +1,28 @@ +@strcmp ( a* b* -- a-end* b-end* order nonzero if strings differ + OR a-end* b-end* 00 00 if strings match ) + STH2 + ,&entry JMP + + &loop ( a* a b / b* ) + SUB ,&nomatch JCNk ( a* a-b nonzero / b* ) + POP2 ( a* / b* ) + INC2 INC2r + &entry ( a* / b* ) + LDAk LDAkr STHr ( a* a b / b* ) + ORAk ,&loop JCN + + &nomatch ( a* a-b flag / b* ) + STH2r SWP2 ( a* b* a-b flag ) + JMP2r + +@strlen ( string-ptr* -- length^ ) + LIT2r 0000 + ,&entry JMP + + &loop + INC2 INC2r + &entry + LDAk ,&loop JCN + POP2 STH2r + JMP2r + diff --git a/projects/software/asma.tal b/projects/software/asma.tal @@ -423,7 +423,7 @@ include projects/library/file-read-chunks.tal @asma-parse-hex-string ( -- value* 06 if valid hex and length > 2 OR value* 03 if valid hex and length <= 2 OR 00 otherwise ) - ;asma/token LDA2 DUP2 ,asma-strlen JSR #02 GTH ROT ROT + ;asma/token LDA2 DUP2 ,strlen JSR #0002 GTH2 ROT ROT LIT2r 0000 &loop @@ -446,28 +446,22 @@ include projects/library/file-read-chunks.tal DUP EOR JMP2r -@asma-strlen ( string-ptr* -- length ) - LITr 00 - - &loop - LDAk - ,&not-end JCN - POP2 STHr - JMP2r - - &not-end - LITr 01 ADDr - INC2 - ,&loop JMP - %asma-SHORT-FLAG { #20 } %asma-RETURN-FLAG { #40 } %asma-KEEP-FLAG { #80 } +@asma-traverse-tree ( incoming-ptr* -- binary-ptr* 00 if key found + OR node-incoming-ptr* 01 if key not found ) + ;asma/token LDA2 + ( fall through to traverse-tree ) + +include projects/library/binary-tree.tal +include projects/library/string.tal + @asma-parse-opcode ( -- byte 00 if valid opcode OR 01 otherwise ) ;asma/token LDA2 - DUP2 ,asma-strlen JSR #03 LTH ,&too-short JCN + DUP2 ,strlen JSR #0003 LTH2 ,&too-short JCN ( truncate to three chars long ) #0003 ADD2 ( end* / ) @@ -561,13 +555,6 @@ include projects/library/file-read-chunks.tal include projects/library/heap.tal -@asma-traverse-tree ( incoming-ptr* -- binary-ptr* 00 if key found - OR node-incoming-ptr* 01 if key not found ) - ;asma/token LDA2 - ( fall through to traverse-tree ) - -include projects/library/binary-tree.tal - ( First character routines. The following routines (that don't have a FORTH-like signature) are called @@ -817,7 +804,7 @@ include projects/library/binary-tree.tal JMP2r &keep-going - DUP2k ;asma-strlen JSR2 #00 SWP INC2 ADD2 + DUP2k ;strlen JSR2 INC2 ADD2 SWP2 ;asma-assemble-token JSR2 asma-IF-ERROR ,&error JCN ,&macro-loop JMP