code wiki / _hdl_build / nx_section_projection_gate_t239.nx

nx_section_projection_gate_t239.nx source

↩ module page · 36 lines · 1756 B

1import "nx_syscalls.nx" 2import "nx_section_projection.nx" 3func clear_hist(h:*i64,n:i64)->i64 { var i:i64=0; while i<n {h[i]=0;i=i+1} return 0 } 4func main(argc:i64,argv:*i64)->i64 { 5 let p:*i64=sys_mmap(64) as *i64 6 let h:*i64=sys_mmap(72) as *i64 7 if p == (0 as *i64) {return 1} 8 if h == (0 as *i64) {return 2} 9 p[0]=0;p[1]=80 10 clear_hist(h,9) 11 if section_project_x_pairs(p,0,2,0,80,h,9)!=0{return 3} 12 var i:i64=0;while i<9{if h[i]!=1{return 4}i=i+1} 13 p[0]=80;p[1]=0;clear_hist(h,9) 14 if section_project_x_pairs(p,0,2,0,80,h,9)!=0{return 5} 15 i=0;while i<9{if h[i]!=1{return 6}i=i+1} 16 p[0]=0;p[1]=20;p[2]=60;p[3]=80;clear_hist(h,9) 17 if section_project_x_pairs(p,0,4,0,80,h,9)!=0{return 7} 18 i=0;while i<9{var want:i64=1;if i>2{if i<6{want=0}}if h[i]!=want{return 8}i=i+1} 19 p[0]=80;p[1]=60;p[2]=20;p[3]=0;clear_hist(h,9) 20 if section_project_x_pairs(p,0,4,0,80,h,9)!=0{return 9} 21 i=0;while i<9{var want:i64=1;if i>2{if i<6{want=0}}if h[i]!=want{return 10}i=i+1} 22 p[2]=40;p[3]=40;clear_hist(h,9) 23 if section_project_x_pairs(p,2,2,0,80,h,9)!=0{return 11} 24 i=0;while i<9{var want:i64=0;if i==4{want=1}if h[i]!=want{return 12}i=i+1} 25 clear_hist(h,9) 26 if section_project_x_pairs(p,0,3,0,80,h,9)==0{return 13} 27 if section_project_x_pairs(p,0,0-2,0,80,h,9)==0{return 14} 28 if section_project_x_pairs(p,0-1,2,0,80,h,9)==0{return 15} 29 if section_project_x_pairs(p,0,2,0,0,h,9)==0{return 16} 30 if section_project_x_pairs(p,0,2,0,80,h,0)==0{return 17} 31 i=0;while i<9{if h[i]!=0{return 18}i=i+1} 32 if section_project_x_pairs(p,0,0,0,80,h,9)!=0{return 19} 33 let msg:*u8="section projection gate PASS: sparse connected, reversed, disconnected, permutation, offset, degenerate, invalid and empty\n" as *u8 34 var n:i64=0;while msg[n]!=(0 as u8){n=n+1}sys_write(1,msg,n) 35 return 0 36}