code wiki / _hdl_build / nx_huffcdic_gate.nx

nx_huffcdic_gate.nx

buildroot/runtime/_hdl_build/nx_huffcdic_gate.nx

6738 B98 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_huffcdic.nx nx_huffcdic_gate.nx

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

main gp sys_write sys_mmap put32 put16 huff_load hc_be32 cdic_load hc_be32 ↻ hc_be16 hc_unpack sys_mmap ↻ hc_be64 hc_unpack ↻ gnum sys_write ↻ sys_mmap ↻ sys_write ↻ sys_exit

structs

none

consts

none

functions

12func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
13func 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 }
called by 1: main calls 2: sys_writesys_mmap
15func 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
16func 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
18func main() -> i64