Extracted string library from asma
This commit is contained in:
parent
be2e01e9b3
commit
0c6b607f91
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
||||
,¬-end JCN
|
||||
POP2 STHr
|
||||
JMP2r
|
||||
|
||||
¬-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
|
||||
,¯o-loop JMP
|
||||
|
||||
|
|
Loading…
Reference in New Issue