Skip to content

Qwen3-0.6B inference (12 KB), bare-metal bootable OS (22 KB), and from-scratch Mini-GPT trainer with live Braille TUI (32 KB) in 100% pure x86-64 NASM assembly. Zero C, zero libc, zero dependencies.

asm-llm: clamp -n to the capacity of the generated-token buffer

Leo Camus9c13f6b400a3
diff --git a/01-qwen3-inference/main.asm b/01-qwen3-inference/main.asm
index a48d020..f0fe890 100644
--- a/01-qwen3-inference/main.asm
+++ b/01-qwen3-inference/main.asm
@@ -110,6 +110,9 @@ _start:
jae .usage
mov rdi, [r13 + rbx*8]
call parse_u64
+ mov ecx, MAX_GEN_TOKENS ; capacity of CTX_BUF_GEN
+ cmp rax, rcx
+ cmova rax, rcx
mov [rel opt_max_tok], rax
jmp .arg_next