ref: f708628b4300a4625e9b3cf2dbe870dac95121ac
parent: fdb251d1136d8b8a92c520fc0bf6ae7adbcfe154
author: grobe0ba <grobe0ba@tcp80.org>
date: Sun May 12 16:23:44 CDT 2024
fix broken code and examples
--- a/cmd/tblgen/crctbl.ha
+++ b/cmd/tblgen/crctbl.ha
@@ -26,33 +26,24 @@
// uint16_t upper = 0;
//
// for (uint32_t i = 0; i < sizeof(p) / sizeof(unsigned char); ++i) {
-// poly |= 1UL << (15 - p[i]);
+// poly |= 1UL << (31 - p[i]);
// }
//
-// lower = poly & ((1U << 16) - 1);
-// upper = poly >> 16;
-// poly = (lower << 16) | upper;
use fmt;
export fn main() void = {
-// let poly: u32 = 0;
-// let lower: u32 = 0;
-// let upper: u32 = 0;
-//
-// const p: []u32 = [ 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 ];
-//
-// for (let i = 0z; i < len(p); i += 1) {
-// poly |= (1: u32) << (15 - p[i]);
-// };
-//
-// lower = poly & ((1 << 16) - 1);
-// upper = poly >> 16;
-// poly = (lower << 16) | upper;
-//
-// assert(poly == 0xedb88320);
+ let poly: u32 = 0;
+ let lower: u32 = 0;
+ let upper: u32 = 0;
- const poly: u32 = 0xedb88320;
+ const p: []u32 = [ 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 ];
+
+ for (let i = 0z; i < len(p); i += 1) {
+ poly |= (1: u32) << (31 - p[i]);
+ };
+
+ assert(poly == 0xedb88320);
let t: [256]u32 = [0...];