CRC-32: Difference between revisions

Content added Content deleted
(added NOWUT)
Line 1,418: Line 1,418:
{{out}}
{{out}}
<pre>414FA339</pre>
<pre>414FA339</pre>

=={{header|NOWUT}}==
adapted from FreeBASIC
<lang NOWUT>; link with PIOxxx.OBJ

sectionbss

crctable.d: resd 256

sectiondata

havetable.b: db 0
string: db "The quick brown fox jumps over the lazy dog"
stringend:
db 13,10,0 ; carriage return and null terminator
sectioncode

start!
gosub initplatform

beginfunc
localvar crc.d

callex ,printnt,"input = ".a
callex ,printnt,string

callex ,printnt,"The CRC-32 checksum = ".a
callex crc,crc32,string,stringend
callex ,printhexr,crc

endfunc
end

crc32:
beginfunc bufend.d,buf.d
localvar i.d,j.d,k.d,k2.d,crc.d

ifunequal havetable,0,tabledone
i=0
whileless i,256

k=i > j=8
countdown j
k2=k > k=_ shr 1
ifequal k2 and 1,0,noxor > k=_ xor $EDB88320
noxor:
nextcount

crctable(i shl 2)=k
i=_+1
wend

havetable=1
tabledone:

crc=-1

whileless buf,bufend
crc=_ shr 8 xor crctable(crc and $FF xor [buf].b shl 2)
buf=_+1
wend

crc=_ xor -1
endfunc crc
returnex 8 ; clean off 2 parameters from the stack
</lang>
{{out}}
<pre>input = The quick brown fox jumps over the lazy dog
The CRC-32 checksum = 414FA339</pre>


=={{header|Oberon-2}}==
=={{header|Oberon-2}}==