In    -
Out   WildCard
Type  Utility

.scan
   STMFD   (sp)!,{r0-r5,link}            ; Stack registers
   ADR     r0,`base
   ADR     r1,`wildcarded
   BL      cmpwildcardi
   SWIEQ   &131
   SWINE   &130
   LDMFD   (sp)!,{r0-r5,pc}              ; Return from call

.`wildcarded
   EQUZ    "JU*TIN"
.`base
   EQUZ    "Justin"

#Library "Strings",cmpstring.cmpstringi.cmpwildcardi

; compare string using wildcards
; > r0 = base string
;   r1 = wildcard string
; < EQ if same, NE if different
.cmpwildcard
   STMFD   (sp)!,{r0-r3,link}            ; Stack registers
$trythis
   LDRB    r2,[r0]                       ; get base
   LDRB    r3,[r1]                       ; get wildcard
   CMP     r2,#32
   MOVLT   r2,#0
   CMP     r3,#32
   MOVLT   r3,#0

   CMP     r2,#0                         ; is base eol ?
   BNE     $notbaseeol                   ; if not the skip this
   CMP     r3,#ASC("*")                  ; is wild * ?
   ADDEQ   r1,r1,#1                      ; if so, inc wild ptr
   BEQ     $trythis                      ; and loop around
   CMP     r3,#0                         ; if wild eol ?
   B       $exit                         ; return with flags
$notbaseeol
   CMP     r3,#0                         ; is wild eol ?
   BEQ     $returnFALSE                  ; if so, =FALSE
   CMP     r2,r3                         ; are base and wild same ?
   CMPNE   r3,#ASC("#")                  ; or is wild # ?
   ADDEQ   r1,r1,#1                      ; if so, inc base
   ADDEQ   r0,r0,#1                      ; and wild
   BEQ     $trythis                      ; and try again
   CMP     r3,#ASC("*")                  ; is wild * ?
   BNE     $returnFALSE                  ; if not, then return
   ADD     r1,r1,#1                      ; inc wild
   BL      cmpwildcard                   ; try this
   SUBNE   r1,r1,#1                      ; if not found, reset wild
   ADDNE   r0,r0,#1                      ; inc base
   BLNE    cmpwildcard                   ; and try this
$exit
   LDMFD   (sp)!,{r0-r3,pc}              ; Return from call
$returnFALSE
   CMP     pc,#0
   LDMFD   (sp)!,{r0-r3,pc}

#Post
#Run <CODE>
