interplane.Get Omega
Read in your language

cortex

aien-dev/cortex

Brought by drakestapleton

branch main Branches Tags History

cortex / tests / import / crctest.om

52 lines · 834 bytes Raw Blame History
1note crctest: reads stdin (at most 8388608 bytes) into klw and prints CRC-32C as 8 lowercase hex
2note digits plus LF. Also checks crc_klr over a copy in klr and the byte-wise streaming API agree.
3text khexd "0123456789abcdef"
4global kto uchar 16
5fn main to int
6n = ulong 0
7while lt n len klw bound 999999
8k = read 0 klw n sub len klw n
9if lt k 0
10ret 2
11end
12if eq k 0
13break
14end
15n = add n ulong k
16end
17c = crc_klw 0 n
18i = ulong 0
19while lt i n bound 999999
20for j ulong 16
21if lt i n
22put klr i get klw i
23end
24i = add i 1
25end
26end
27if ne c crc_klr 0 n
28ret 3
29end
30crc_reset
31m = ulong 0
32while lt m n bound 999999
33for j ulong 16
34if lt m n
35crc_byte get klw m
36end
37m = add m 1
38end
39end
40if ne c crc_value
41ret 4
42end
43for h ulong 8
44put kto h get khexd ulong and shr c uint mul sub 7 h 4 15
45end
46put kto 8 10
47w = write 1 kto 0 9
48if ne w 9
49ret 5
50end
51ret 0
52end