2 ; Ullrich von Bassewitz, 11.06.1998
3 ; Christian Krueger: 08-Aug-2013, optimization
5 ; size_t strspn (const char* s1, const char* s2);
9 .import popptr1, _strlen
10 .importzp ptr1, ptr2, tmp1, tmp2
13 jsr _strlen ; get length in a/x and transfer s2 to ptr2
14 ; Note: It does not make sense to
15 ; have more than 255 test chars, so
16 ; we don't support a high byte here! (ptr2+1 is
17 ; also unchanged in strlen then (important!))
18 ; -> the original implementation also
21 sta tmp1 ; tmp1 = strlen of test chars
22 jsr popptr1 ; get and save s1 to ptr1
24 ldx #0 ; low counter byte
25 stx tmp2 ; high counter byte
29 lda (ptr1),y ; get next char from s1
30 beq leave ; handly byte of s1
32 inc ptr1 ; advance string position to test
35 dey ; correct next iny (faster/shorter than bne...)
39 check: cpy tmp1 ; compare with length of test character string
41 cmp (ptr2),y ; found matching char?
48 bne loadChar ; like bra...
50 leave: txa ; restore position of finding