Implemented contains subroutine.
h3rald h3rald@h3rald.com
Thu, 06 Aug 2026 20:24:56 +0000
2 files changed,
46 insertions(+),
1 deletions(-)
A
examples/lib/contains.xyw
@@ -0,0 +1,44 @@
+; <str> <fragment> contains -> $00|$01 +; xw -> index of string +; yw -> index of fragment +; y -> internal index within fragment +; a16 b16 -[xxwyw]- a8 +.label contains + POPyw POPxw ; save both addresses to xw and yw + $00 POPy ; set y to zero + .label contains.checks + ; if at end of fragment, all good + LDByw $00 EQU contains.ok JCNw + ; if at end of string, fail + LDBxw $00 EQU contains.fail JCNw + ; check if contents of indexes are different + LDBxyw NEQ contains.different JCNw + ; otherwise they are matching + ; increment internal fragment index + INCy + ; increment both indexes + INCxyw + contains.checks JMPw + .label contains.str.incr + ; increment only string + INCxw + contains.checks JMPw + .label contains.different + ; letters are different + ; if started matching fragment, reset + PSHy contains.reset JCNw + ; otherwise increment string index + contains.str.incr JMPw + .label contains.reset + ; reset fragment scan + PSHyw $00 PSHy SUBw POPyw + ; reset string scan + PSHxw $00 PSHy SUBw POPxw + $00 POPy + contains.str.incr JMPw + .label contains.fail + ; no match + $00 RTS + .label contains.ok + ; fragment is contained in string + $01 RTS