code wiki / _hdl_build / nx_huffcdic_gate.nx
nx_huffcdic_gate.nx
buildroot/runtime/_hdl_build/nx_huffcdic_gate.nx
about
nx_huffcdic_gate.nx -- liar-kill gate for the sovereign HUFF/CDIC decompressor (MOBI compression 17480).
Builds a MINIMAL but spec-exact fixture in memory: a HUFF record whose 256 dict1 entries all encode (codelen=1,
term, maxcode-raw=1) -> a 1-bit Huffman code where bit '1' selects dictionary phrase 0 and bit '0' selects
phrase 1; a CDIC record carrying phrase0="Alice" + phrase1=" " (both terminal); and a 1-byte stream 0x80 =
'10000000'. Decoding MUST yield "Alice" + 7 spaces (the '1' then seven '0' bits). Asserts the HUFF table parse
(codelen/term/maxcode formula), the CDIC phrase parse (len/flag/bytes), AND the decoded output byte-exact.
This proves the core decode plumbing + record formats; the multi-codelen mincode-walk + recursive (non-terminal)
phrase paths get a richer encoder-fixture in the next rung. expect_exit: 0 license_tier: ORIGINAL
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_huffcdic.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 12 | func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 13 | func gnum(v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(1,"-" as *u8,1); v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0 {b[0]=48 as u8;k=1} while v>0 {b[k]=(48+(v%10)) as u8; v=v/10; k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k {o[j]=b[k-1-j];j=j+1} sys_write(1,o,k); return 0 } |
| 15 | func put32(b: *u8, o: i64, v: i64) -> i64 { b[o]=((v>>24)&0xff) as u8; b[o+1]=((v>>16)&0xff) as u8; b[o+2]=((v>>8)&0xff) as u8; b[o+3]=(v&0xff) as u8; return 0 } called by 1: main |
| 16 | func put16(b: *u8, o: i64, v: i64) -> i64 { b[o]=((v>>8)&0xff) as u8; b[o+1]=(v&0xff) as u8; return 0 } called by 1: main |
| 18 | func main() -> i64 |