tsb: beat the first-pass size floors (tricks 666, pure 842)

tricks 778->666: always_inline every single-call handler into the
[[noreturn]] reset entry (which pays no prologue, so their push/pop of
call-saved registers vanishes), walk the page pointer in Y (adiw, base
recovered as g_addr-page) instead of recomputing Z=base+offset, bring
the UART up in the two registers that are not already at their reset
value, and seed the activation counter as __uint24.

pure 896->842: TU-local internal linkage (proper hygiene, and it lets
the compiler inline the one-call handlers), a byte-wide activation
count, __uint24 timeout. Still one readable function per command.

asm unchanged at 498: its C++-expressible parts are already C++; the
core stays asm (the 666 B all-tricks tier is 168 B over — per-call ABI
tax, not a feature). All three cross-mode byte-identical, protocol green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-19 20:15:49 +02:00
parent fc5433fd7d
commit 2b705ad130
3 changed files with 55 additions and 31 deletions

View File

@@ -54,11 +54,15 @@ endif()
# section, beating the hand-written oracle (500 B) at its own
# feature set. The core is asm because C++ cannot reach it under
# 512 (the tricks tier is the proof).
# tsb_tricks — compiler trickery, no asm (global-register page walk, forced
# flash/EEPROM path sharing, streaming stores, arithmetic command
# decode): 778 B in the 1 KB section (BOOTSZ=10).
# tsb_pure — pure idiomatic libavr, one function per command, streaming (no
# SRAM page buffer): 896 B in the 1 KB section.
# tsb_tricks — compiler trickery, no asm: the hot page pointer is walked in Y
# (adiw), flash/EEPROM paths share one runtime-flag body, every
# single-call handler is always_inline'd into the no-prologue
# reset entry, pages stream straight to SPM/EEPROM, and the
# bring-up is the two reset-non-default registers only. 666 B in
# the 1 KB section (BOOTSZ=10).
# tsb_pure — pure idiomatic libavr, one function per command, TU-local
# (internal linkage), streaming (no SRAM page buffer): 842 B in
# the 1 KB section.
#
# add_tsb_variant(<name> <boot-section-bytes>)
function(add_tsb_variant name bytes)