code wiki / _hdl_build / _team_ch_census.nx
_team_ch_census.nx source
↩ module page · 59 lines · 2024 B
1// _team_ch_census.nx -- the TEAM's lane in the CH-census autonomy race. THE CORE IS THE
2// EMITTER-AUTHORED _pe_tlv (WIRE_TLV shape, zero Claude walk logic); this file is the scaffold-
3// class boilerplate around it: read the staged input, call the authored core, print the census.
4// Contract (both lanes identical): read /tmp/race_input.bin; print EXTN= (entry count, -1 refused)
5// then SNI=/GR=/SG=/SV=/KS= (body offsets; -1 absent; -2 when the walk was refused).
6// license_tier: ORIGINAL
7import "_pe_tlv.nx"
8import "nx_syscalls.nx"
9
10func tc_dec(label: *u8, v: i64) -> i64 {
11 var n: i64 = 0
12 while label[n] != (0 as u8) { n = n + 1 }
13 sys_write(1, label, n)
14 var av: i64 = v
15 if av < 0 {
16 sys_write(1, "-" as *u8, 1)
17 av = 0 - av
18 }
19 if av == 0 { sys_write(1, "0" as *u8, 1) }
20 if av > 0 {
21 let buf: *u8 = sys_mmap(32)
22 var pos: i64 = 0
23 var x: i64 = av
24 while x > 0 { buf[pos] = (0x30 + (x % 10)) as u8; x = x / 10; pos = pos + 1 }
25 let out: *u8 = sys_mmap(32)
26 var oi: i64 = 0
27 while oi < pos { out[oi] = buf[pos - 1 - oi]; oi = oi + 1 }
28 sys_write(1, out, pos)
29 }
30 sys_write(1, "\n" as *u8, 1)
31 return 0
32}
33
34func tc_field(label: *u8, b: *u8, n: i64, t: i64) -> i64 {
35 tc_dec(label, _pe_tlv_find(b, n, t))
36 return 0
37}
38
39func main() -> i64 {
40 let lenp: *i64 = sys_mmap(16) as *i64
41 let b: *u8 = sys_read_file("/tmp/race_input.bin\x00" as *u8, lenp)
42 let n: i64 = lenp[0]
43 let c: i64 = _pe_tlv_count(b, n)
44 tc_dec("EXTN=\x00" as *u8, c)
45 if c < 0 {
46 tc_dec("SNI=\x00" as *u8, 0 - 2)
47 tc_dec("GR=\x00" as *u8, 0 - 2)
48 tc_dec("SG=\x00" as *u8, 0 - 2)
49 tc_dec("SV=\x00" as *u8, 0 - 2)
50 tc_dec("KS=\x00" as *u8, 0 - 2)
51 return 0
52 }
53 tc_field("SNI=\x00" as *u8, b, n, 0)
54 tc_field("GR=\x00" as *u8, b, n, 10)
55 tc_field("SG=\x00" as *u8, b, n, 13)
56 tc_field("SV=\x00" as *u8, b, n, 43)
57 tc_field("KS=\x00" as *u8, b, n, 51)
58 return 0
59}