Ok, this is *way* strange. I'm trying to use this CRC code from the PIC lists' web site: http://www.piclist.com/techref/microchip/crc16ca.htm I'm trying to verify the CRC16.ASM file and I'm getting strange results. I've made some minor modifications to the code, like set p=16f877, include "p16f877.inc", and add some debugging code to print the CRC out the serial port when entering CRC16. In other words, nothing that should affect the CRC. When I run the code through the simulator (gpsim under Linux), I get correct results. The CRC matches the ones in the comments as I step through the code. However, when run on a real PIC (16F877 @ 4MHz), the results are wrong. Note: the results in comments appear to be correct. I've verified it with some C code on the desktop. Here are the results from a real PIC from the serial port: 80 6000 75 27A0 8A 1FA7 0B 7D1F 75 2FFD C7 D3AE AA 03D3 75 7A83 C7 337A 55 DC72 43 141C 1C 0014 14 0000 Note the bizarre behavior. The end CRC is actually correct. However some (but not all) of the intermediate CRCs are incorrect. What could possibly cause this code to act differently on the simulator from a real PIC? It's not interacting with any port registers or any outside stimulus. It's not time dependent. There are no interrupts or anything happening, so nothing could be corrupting the CRC in between invocations. I dunno. This is really strange. I won't even consider a bug in gpsim because it's actually producing expected results. I've run other code on the PIC and it all works, which suggests the chip is a fully functional PIC. Maybe it's time to rewrite this code anyways. I never heard back from him and I'm not sure the copyright status, so it may be better to just start over. But I'd still like to get to the bottom of this strange behavior. -Dave -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu