aboutsummaryrefslogtreecommitdiffstats
path: root/usr/libc.s
diff options
context:
space:
mode:
Diffstat (limited to 'usr/libc.s')
-rw-r--r--usr/libc.s26
1 files changed, 18 insertions, 8 deletions
diff --git a/usr/libc.s b/usr/libc.s
index 2366cd8..fbca836 100644
--- a/usr/libc.s
+++ b/usr/libc.s
@@ -33,18 +33,28 @@ _putc:
rst #0x30
ret
- ;; void puts(const char *s /*DE*/) - write until NUL (no newline)
+ ;; void puts(const char *s /*DE*/) - write until NUL (no newline).
+ ;; ONE SYS_WRITE for the whole string instead of a SYS_PUTC per char:
+ ;; a single trap, and the kernel defers tile rendering for the whole
+ ;; run (sys_write batching), so a line paints each tile once.
_puts:
-1$: ld a, (de)
+ push de
+ ld h, d
+ ld l, e
+ ld b, #0
+1$: ld a, (hl)
+ or a
+ jr z, 2$
+ inc hl
+ inc b
+ jr 1$
+2$: pop de
+ ld a, b
or a
ret z
- push de
- ld e, a
- ld c, #16 ; SYS_PUTC
+ ld c, #3 ; SYS_WRITE (DE=buf, B=len)
rst #0x30
- pop de
- inc de
- jr 1$
+ ret
;; void nl(void) - CRLF via stdout
_nl: