Checksum help
Don M
Posts: 1,652
I am trying to calculate a checksum from a series of bytes. The check byte is limited to 8 bits so the carry bit is ignored.
This code works:
chk & s are longs
chk = 36 which is correct.
However this one does not work:
chk & s are longs
chk should be 18 but it shows 4E and then next time 66
What am I doing wrong?
Thanks.
Don
This code works:
chk & s are longs
repeat pos from 0 to 22 s := byte[@array1][pos] pst.tx(s) chk += s pst.tx(chk) dat array1 byte $03, $00, $01, $05, $02, $00, $0F, $01, $02, $05, $14, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
chk = 36 which is correct.
However this one does not work:
chk & s are longs
repeat pos from 0 to 32 s := byte[@array1][pos] pst.tx(s) chk += s pst.tx(chk) dat array1 byte $4D, $45, $49, $30, $31, $38, $38, $59, $53, $30, $31, $30, $37, $30, $20, $43, $46, $37, $35, $30, $30, $4D, $44, $42, $20, $20, $20, $01, $18, $00, $00, $00, $07
chk should be 18 but it shows 4E and then next time 66
What am I doing wrong?
Thanks.
Don
Comments
No it wasn't. It is now and it works. Thanks. You're a genius. I feel rather silly about this.
Thanks again.
Don