code wiki / _hdl_build / _wb_lpc_test.nx
_wb_lpc_test.nx source
↩ module page · 39 lines · 1060 B
1// AUTHORED BY THE NISHI BUILDER (pattern: PREDICTOR_CODER test) -- KATs computed from the spec at emit time
2import "_wb_lpc.nx"
3import "nx_syscalls.nx"
4func main() -> i64 {
5 let x: *i64 = sys_mmap(256) as *i64
6 x[0] = 0 - 8191
7 x[1] = 0 - 4096
8 x[2] = 0 - 1
9 x[3] = 4094
10 x[4] = 8189
11 x[5] = 0 - 8191
12 x[6] = 0 - 4096
13 x[7] = 0 - 1
14 x[8] = 4094
15 x[9] = 8189
16 x[10] = 0 - 8191
17 x[11] = 0 - 4096
18 let u: *i64 = sys_mmap(256) as *i64
19 let w: *i64 = sys_mmap(64) as *i64
20 let y: *i64 = sys_mmap(256) as *i64
21 var ok: i64 = 1
22 if _wb_lpc_residuals(x, 12, u) != 10 { ok = 0 }
23 if u[0] != 0 { ok = 0 }
24 if u[1] != 0 { ok = 0 }
25 w[0] = x[0]
26 w[1] = x[1]
27 if _wb_lpc_restore(u, 10, w, y) != 12 { ok = 0 }
28 var i: i64 = 0
29 while i < 12 {
30 if y[i] != x[i] { ok = 0 }
31 i = i + 1
32 }
33 u[0] = u[0] + 262136
34 if _wb_lpc_restore(u, 10, w, y) != 0 - 2 { ok = 0 }
35 if _wb_lpc_residuals(x, 2, u) != 0 - 1 { ok = 0 }
36 if ok == 1 { sys_exit(0) }
37 sys_exit(1)
38 return 1
39}