code wiki / (root) / nx_smoke_repro3.nx

nx_smoke_repro3.nx source

↩ module page · 55 lines · 1178 B

1// smoke_repro3.nx -- adds the text[i] = c style write. 2 3// nx_safety_envelope: 4// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 5// sil_target: SIL1 6// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 7// verdict: NOT_YET_EVALUATED 8 9import "nx_syscalls.nx" 10 11struct S { 12 src: *u8, 13 pos: i64, 14} 15 16func peek3(L: *S) -> i64 { 17 let s: *u8 = L.src 18 return s[L.pos] 19} 20 21func is_alpha3(c: i64) -> i64 { 22 if c >= 0x41 { if c <= 0x5A { return 1 } } 23 if c >= 0x61 { if c <= 0x7A { return 1 } } 24 return 0 25} 26 27func advance3(L: *S) -> i64 { 28 L.pos = L.pos + 1 29 return 0 30} 31 32func work(L: *S) -> i64 { 33 let buf_raw: *u8 = sys_mmap(96) 34 let text: *u8 = buf_raw + 32 35 var i: i64 = 0 36 while i < 8 { 37 let c: i64 = peek3(L) 38 if is_alpha3(c) { 39 text[i] = c & 0xFF 40 advance3(L) 41 i = i + 1 42 } 43 if is_alpha3(c) == 0 { break } 44 } 45 return i 46} 47 48func main() -> i64 { 49 let raw: *u8 = sys_mmap(64) 50 let L: *S = raw as *S 51 L.src = "abcDEF" 52 L.pos = 0 53 let r: i64 = work(L) 54 return __syscall(93, r, 0, 0, 0, 0, 0) 55}