Thanks Mike,

My IQ diminishes in the afternoon! Is coffee a remedy?

Here is a more pedantic, though verified o2 version:

` int reflect(int r,n)`

{

xor edx,edx

mov cl,n

.ri

dec cl

jl fwd ni

mov eax,r

and eax,1

jz fwd nd

mov eax,1

shl eax,cl

or edx,eax

.nd

shr r,1

jmp ri

.ni

mov eax,edx

return

}

'print hex ( reflect (0x2,32), 8)

'http://wiki.osdev.org/CRC32

'https://www.lammertbies.nl/comm/info/crc-calculation.html

int t[0x100]

void init_crc32_table(int*t)

{

int a,i,j

% Polynomial = 0x04c11db7

for i=0 to 255

t=reflect(i,8)

t=t<<24

for j=0 to 7

a=t and 0x80000000

t=t<<1

if a then t xor= Polynomial

next

t = reflect(t, 32)

@t+=4

next

}

init_crc32_table t

'def v +", "+mid(hex(t[%1],8),-8)

'print "crctable... " v 0 v 1 v 2 v 255

int crc32(sys p,le)

{

byte b at p

int v

byte i

int crc=0xffffffff

while le

le--

i=crc xor b

v=t[i]

crc=(crc>>8) xor v

@b++

end while

return not(crc)

}

'string s="A" 'crc32 should be: D3D99E8B

'string s="a" 'crc32 should be: E8B7BE43

string s="123456789" 'crc32 should be: CBF43926

print hex crc32 strptr s, len s