I have written a quick script in basic to create a XOR checksum but now I'm working on CRC-CCITT
http://en.wikipedia.org/wiki/Computation_of_CRC
http://www.lammertbies.nl/comm/info/crc ... ation.html
If I could address individual bits I'd be on my way. Is there any way to do this?
At the moment I'm defining variables as BYTE as doing LOTS of XOR and manually checking bytes, doing >> and adding 128
Has anyone implemented CRC-CCITT (0xFFFF) before? I'm not sure I'm going down the correct avenue.
Computing CRC-CCITT (0xFFFF)
Re: Computing CRC-CCITT (0xFFFF)
C and BASIC manipulate bits pretty much the same way. Mask a bit with & (C) AND (BASIC) with a hex value x AND (1<<5) chooses bit 5. Or you could write x AND 0x20
You could write functions to do it, but that would slow you down.
There are lots of examples of calculating different CRC and it should be fairly easy to move them over to BASIC.
You could write functions to do it, but that would slow you down.
There are lots of examples of calculating different CRC and it should be fairly easy to move them over to BASIC.
Re: Computing CRC-CCITT (0xFFFF)
You could always create a macro to do bit set, clear or test -- I'm just so use to seeing the AND (1<<x) in code
Code: Select all
#define BITSET(x,bit) (x OR (1<<bit))
#define BITCLEAR(x,bit) (x AND NOT(1<<bit))
#define TESTBIT(x,bit) (x AND (1<<bit))
Re: Computing CRC-CCITT (0xFFFF)
That clear thing up. Now to port and post the function. Cheers