strlen.asm 447 B

12345678910111213141516171819202122232425
  1. ; Returns len if a string
  2. ; If a string is NULL, its len is also 0
  3. ; Result returned in HL
  4. ;
  5. __STRLEN: ; Direct FASTCALL entry
  6. lda z80_h ;- ld a,h
  7. sta z80_a
  8. ora z80_l ;- or l
  9. bne *+3 ;- ret z
  10. rts
  11. ldy #$00 ;- ld a,(hl)
  12. lda (z80_hl),y
  13. sta z80_a
  14. inc z80_l ;- inc hl
  15. bne *+4
  16. inc z80_h
  17. ldy #$00 ;- ld h,(hl) ; LEN(str) in HL
  18. lda (z80_hl),y
  19. sta z80_h
  20. lda z80_a ;- ld l,a
  21. sta z80_l
  22. rts ;- ret