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.
; Zero-App Golden #4: Interactive Mandelbrot Fractal (Q10 fixed-point, 32 iters)
; Bare 5-primitive ABI only (fb_ptr, stride, input_state, ticks_ms, exit)
; 160x120 logical viewport rendered as crisp 4x4 pixels (640x480 centered)
; Controls: A/D or Left/Right pan real, W/S or Up/Down pan imag, Q exits
mov r12, [rdi + 0x00]
mov r13, [rdi + 0x08]
mov r14, [rdi + 0x18]
mov r15, 0x10100000
mov dword [r15 + 0], -2048
mov dword [r15 + 4], -1200
mov dword [r15 + 8], 1
mov dword [r15 + 12], 0
main_loop:
mov eax, [r14 + 0x14]
cmp eax, 'q'
je do_exit
mov eax, [r14 + 0x1C]
cmp eax, [r15 + 12]
je check_dirty
mov [r15 + 12], eax
movzx eax, byte [r14 + 0x20 + 0x20]
movzx ebx, byte [r14 + 0x20 + 0x4D]
or eax, ebx
test eax, eax
jz chk_left
add dword [r15 + 0], 128
mov dword [r15 + 8], 1
chk_left:
movzx eax, byte [r14 + 0x20 + 0x1E]
movzx ebx, byte [r14 + 0x20 + 0x4B]
or eax, ebx
test eax, eax
jz chk_up
sub dword [r15 + 0], 128
mov dword [r15 + 8], 1
chk_up:
movzx eax, byte [r14 + 0x20 + 0x11]
movzx ebx, byte [r14 + 0x20 + 0x48]
or eax, ebx
test eax, eax
jz chk_down
sub dword [r15 + 4], 128
mov dword [r15 + 8], 1
chk_down:
movzx eax, byte [r14 + 0x20 + 0x1F]
movzx ebx, byte [r14 + 0x20 + 0x50]
or eax, ebx
test eax, eax
jz check_dirty
add dword [r15 + 4], 128
mov dword [r15 + 8], 1
check_dirty:
cmp dword [r15 + 8], 0
jne do_render
pause
jmp main_loop
do_render:
mov dword [r15 + 8], 0
mov r8d, 0
mov r11d, [r15 + 4]
row_lp:
cmp r8d, 120
jae main_loop
mov r9d, 0
mov r10d, [r15 + 0]
col_lp:
cmp r9d, 160
jae next_row
xor esi, esi
xor ebp, ebp
xor ecx, ecx
orbit:
mov eax, esi
imul eax, esi
mov edx, ebp
imul edx, ebp
mov ebx, eax
add ebx, edx
cmp ebx, 4194304
ja shade
imul ebp, esi
sar ebp, 9
add ebp, r11d
sub eax, edx
sar eax, 10
mov esi, eax
add esi, r10d
inc ecx
cmp ecx, 32
jb orbit
xor edx, edx
jmp draw_px
shade:
mov eax, ecx
shl eax, 3
mov edx, ecx
imul edx, edx, 13
and edx, 255
shl edx, 8
or edx, eax
mov eax, ecx
imul eax, eax, 7
and eax, 255
shl eax, 16
or edx, eax
draw_px:
mov eax, r8d
shl eax, 2
add eax, 128
imul rax, r13
mov ebx, r9d
shl ebx, 2
add ebx, 192
lea rdi, [r12 + rax]
lea rdi, [rdi + rbx*4]
xor ecx, ecx
blk_y:
cmp ecx, 4
jae blk_done
mov [rdi + 0], edx
mov [rdi + 4], edx
mov [rdi + 8], edx
mov [rdi + 12], edx
add rdi, r13
inc ecx
jmp blk_y
blk_done:
add r10d, 20
inc r9d
jmp col_lp
next_row:
add r11d, 20
inc r8d
jmp row_lp
do_exit:
exit 0