mirror of
https://github.com/cc65/cc65.git
synced 2025-01-11 11:30:13 +00:00
Fix strnlen().
This commit is contained in:
parent
88fdaeb490
commit
3ee9b35080
@ -5,25 +5,25 @@
|
|||||||
.importzp ptr1, tmp1, tmp2, tmp3, tmp4
|
.importzp ptr1, tmp1, tmp2, tmp3, tmp4
|
||||||
|
|
||||||
.proc _strnlen
|
.proc _strnlen
|
||||||
|
; Get maximum length.
|
||||||
|
tay
|
||||||
|
iny
|
||||||
|
sty tmp3
|
||||||
|
inx
|
||||||
|
stx tmp4
|
||||||
|
|
||||||
; Fetch string pointer.
|
; Fetch string pointer.
|
||||||
|
jsr popax
|
||||||
sta ptr1
|
sta ptr1
|
||||||
stx ptr1+1
|
stx ptr1+1
|
||||||
|
|
||||||
; Clear return value.
|
; Clear return value.
|
||||||
lda #0
|
ldy #0
|
||||||
sta tmp1
|
sty tmp1
|
||||||
sta tmp2
|
sty tmp2
|
||||||
|
|
||||||
; Get maximum length.
|
|
||||||
jsr popax
|
|
||||||
sta tmp3
|
|
||||||
inc tmp3
|
|
||||||
inx
|
|
||||||
stx tmp4
|
|
||||||
|
|
||||||
;;; Loop over string.
|
;;; Loop over string.
|
||||||
ldy #0
|
|
||||||
|
|
||||||
; Decrement maximum length.
|
; Decrement maximum length.
|
||||||
next: dec tmp3
|
next: dec tmp3
|
||||||
bne l2
|
bne l2
|
||||||
@ -35,7 +35,7 @@ l2:
|
|||||||
beq done
|
beq done
|
||||||
|
|
||||||
; Step to next character.
|
; Step to next character.
|
||||||
inc ptr1
|
iny
|
||||||
bne l1
|
bne l1
|
||||||
inc ptr1+1
|
inc ptr1+1
|
||||||
l1:
|
l1:
|
||||||
@ -45,7 +45,7 @@ l1:
|
|||||||
bne next
|
bne next
|
||||||
inc tmp2
|
inc tmp2
|
||||||
|
|
||||||
jmp next
|
bne next ; (jmp)
|
||||||
|
|
||||||
|
|
||||||
done: lda tmp1
|
done: lda tmp1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user