Skip to content

Instantly share code, notes, and snippets.

@qnikst
Created April 23, 2013 04:25
Show Gist options
  • Save qnikst/5440842 to your computer and use it in GitHub Desktop.
Save qnikst/5440842 to your computer and use it in GitHub Desktop.
not very idiomatic haskell code
#include "Cmm.h"
#define W_TO_SHORT(x) %lobits32(x)
crc16u {
/* R1 uint32_t input,
R2 uint16_t data,
R3 Int size */
I32 c;
if (R3 == 0) goto end;
c = R1;
R4 = 0;
loop:
// R1 = (R1 + TO_W_(bits16[R2+R4]) % 0xFFFF) % 0xFFFFFFFF;
// R4 = R4 + 2;
// R1 = HALF_W_(HALF_W_(R1) + HALF_W_(bits32[R2+R4]));
c = c + W_TO_SHORT(bits16[R2+R4]);
R4 = R4 + 2;
if (R4<R3) goto loop;
if (R4>R3) {
c = c + W_TO_SHORT(bits8[R2+R3] << 8);
}
R1 = TO_W_(c);
end:
jump %ENTRY_CODE(Sp(0));
}
#if 0
crc16(uint32_t w,uint16_t *b,size_t l) {
while (l--) {
w += b;
}
return w;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment