avrdudes / avr-libc

The AVR-LibC package provides a subset of the standard C library for AVR 8-bit RISC microcontrollers.
https://avrdudes.github.io/avr-libc/
Other
266 stars 57 forks source link

[patch #10101] util/crc16.h: improved _crc_xmodem_update (smaller & faster) #831

Closed avrs-admin closed 8 months ago

avrs-admin commented 2 years ago

Sun 29 Aug 2021 11:20:55 PM CEST

The attached patch improves the _crc_xmodem_update algorithm.  The improved algorithm uses 14 instructions instead of the original 25.  Additionally the temporary variables have less strict constraints (=r instead of =d), and r0 is not clobbered.

I have successfully tested the new algorithm with all possible inputs (65536 * 256) against the original algorithm.  The test was run in simulavr.  See attached files main.c, orig_crc.c and run_test.sh

file #51833: run_test.sh file #51832: orig_crc.c file #51831: main.c file #51830: patch_crc_xmodem_update.txt

This issue was migrated from https://savannah.nongnu.org/patch/?10101

sprintersb commented 8 months ago

Applied as https://github.com/avrdudes/avr-libc/commit/6009ae60f0b46aef601f4b8586a51240966dee53.