From 2953b35cea6515a5de73bba798583bbb4146bdce Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 6 Apr 2026 07:28:16 -0400 Subject: Rewrite txbuf_append_chr() in asm. 6795 bytes free. --- src/main.c | 4 ---- src/txbuf.s | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/txbuf.s diff --git a/src/main.c b/src/main.c index 318654d..66ced7f 100644 --- a/src/main.c +++ b/src/main.c @@ -29,10 +29,6 @@ char reconnect_timeout = 1; extern void ih(); // defined in intr.s -void txbuf_append_chr(char c) { - tx_buf[txbuflen++] = c; -} - void txbuf_init(void) { txbuflen = tx_buf[0] = 0; } diff --git a/src/txbuf.s b/src/txbuf.s new file mode 100644 index 0000000..4783660 --- /dev/null +++ b/src/txbuf.s @@ -0,0 +1,29 @@ +;; void txbuf_append_chr(char c) { +;; tx_buf[txbuflen++] = c; +;; } + +; compiles to 45 bytes. routine below is 29 bytes (~33% smaller) + + tx_buf = $a200 ; MUST agree with src/rxtxbuf.h! + + .import _txbuflen + .export _txbuf_append_chr + .importzp sreg ; avoid ptr1 & friends, callers may use + +_txbuf_append_chr: + tax + lda #tx_buf + adc _txbuflen+1 + sta sreg+1 + ldy #0 + txa + sta (sreg),y + inc _txbuflen + bne @ret + inc _txbuflen+1 +@ret: + rts -- cgit v1.2.3