diff options
| author | B. Watson <urchlay@slackware.uk> | 2026-04-11 16:30:26 -0400 |
|---|---|---|
| committer | B. Watson <urchlay@slackware.uk> | 2026-04-11 16:30:50 -0400 |
| commit | aa82c562dbbbdabac2acc43d5002bfe8b46ca646 (patch) | |
| tree | 2241521e9d692d28c915a39d8aa83c05b0b50197 /src/strlen8.s | |
| parent | e42bd5b6042e7d3a5ee8c7643b379a606b986811 (diff) | |
| download | fujinet-chat-aa82c562dbbbdabac2acc43d5002bfe8b46ca646.tar.gz | |
strlen() => strlen8(), save a measly 4 bytes. 7597 bytes free.
Diffstat (limited to 'src/strlen8.s')
| -rw-r--r-- | src/strlen8.s | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/strlen8.s b/src/strlen8.s new file mode 100644 index 0000000..c622d73 --- /dev/null +++ b/src/strlen8.s @@ -0,0 +1,24 @@ + ; strlen() implementation that only looks at the first 256 + ; byte of the string. returns 255 if the length is >=255. + ; saves a measly 4 bytes over the cc65 strlen(). + + ; extern unsigned char strlen8(const char *str); + + .importzp ptr1 + .export _strlen8 + +_strlen8: + sta ptr1 + stx ptr1+1 + ldy #0 +@loop: + lda (ptr1),y + beq @done + iny + bne @loop + dey ; return(255) if Y rolls over +@done: + tya + ldx #0 ; sadly necessary even though we return a char... + rts + |
