code wiki / _hdl_build / nx_probe_hexesc.nx
nx_probe_hexesc.nx source
↩ module page · 26 lines · 896 B
1// nx_probe_hexesc -- MEASURE whether a high-byte \xNN escape inside a string literal is a lexer contract.
2// Prints len= and the first two byte values of "\xC3\xA9". Expected if supported: len=2 b0=195 b1=169.
3// Written 2026-09-02 for the lang board (LN25); a claim about the lexer is published only after this runs.
4import "nx_syscalls.nx"
5func pd(v: i64) -> i64 {
6 let d: *u8 = sys_mmap(8)
7 d[0] = (48 + (v / 100)) as u8
8 d[1] = (48 + ((v / 10) % 10)) as u8
9 d[2] = (48 + (v % 10)) as u8
10 d[3] = 32 as u8
11 sys_write(1, d, 4)
12 return 0
13}
14func main() -> i64 {
15 let s: *u8 = "\xC3\xA9" as *u8
16 var n: i64 = 0
17 while s[n] != (0 as u8) { n = n + 1 }
18 sys_write(1, "len=" as *u8, 4)
19 pd(n)
20 sys_write(1, "b0=" as *u8, 3)
21 pd((s[0] as i64) & 255)
22 sys_write(1, "b1=" as *u8, 3)
23 pd((s[1] as i64) & 255)
24 sys_write(1, "\n" as *u8, 1)
25 return 0
26}