Further optimizations in common/conio.
This commit is contained in:
@@ -6,40 +6,39 @@
|
||||
;
|
||||
|
||||
.export _strspn
|
||||
.import popax, _strlen
|
||||
.import popptr1, _strlen
|
||||
.importzp ptr1, ptr2, tmp1, tmp2
|
||||
|
||||
_strspn:
|
||||
jsr _strlen ; get length in a/x and transfer s2 to ptr1
|
||||
jsr _strlen ; get length in a/x and transfer s2 to ptr2
|
||||
; Note: It does not make sense to
|
||||
; have more than 255 test chars, so
|
||||
; we don't support a high byte here! (ptr1+1 is
|
||||
; we don't support a high byte here! (ptr2+1 is
|
||||
; also unchanged in strlen then (important!))
|
||||
; -> the original implementation also
|
||||
; ignored this case
|
||||
|
||||
sta tmp1 ; tmp1 = strlen of test chars
|
||||
jsr popax ; get and save s1
|
||||
sta ptr2 ; to ptr2
|
||||
stx ptr2+1
|
||||
jsr popptr1 ; get and save s1 to ptr1
|
||||
|
||||
ldx #0 ; low counter byte
|
||||
stx tmp2 ; high counter byte
|
||||
|
||||
loadChar:
|
||||
ldy #0
|
||||
lda (ptr2),y ; get next char from s1
|
||||
lda (ptr1),y ; get next char from s1
|
||||
beq leave ; handly byte of s1
|
||||
advance:
|
||||
inc ptr2 ; advance string position to test
|
||||
inc ptr1 ; advance string position to test
|
||||
bne check
|
||||
inc ptr2+1
|
||||
inc ptr1+1
|
||||
dey ; correct next iny (faster/shorter than bne...)
|
||||
|
||||
checkNext:
|
||||
iny
|
||||
check: cpy tmp1 ; compare with length of test character string
|
||||
beq leave
|
||||
cmp (ptr1),y ; found matching char?
|
||||
cmp (ptr2),y ; found matching char?
|
||||
bne checkNext
|
||||
|
||||
foundTestChar:
|
||||
|
||||
Reference in New Issue
Block a user