Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo
I'm getting a strange problem. When I use ADDWF to add two numbers and by chance both numbers are zero the status.z goes high (but not the status.c). Is this normal?
Well that was unexpected. I was checking for an overflow after an increment using status.z.
Unfortunately just before the status.z check there was a MOVF and occasionally the number in the MOVF was zero which also sets the status.z to 1.
So the result was occasional very bad errors.
This behavior of MOVF does not seem well documented.
You should use status.c to check for overflow not status.z.
status.z only tests if the last operation resulted in a zero value.
status.c tests if the last operation overflowed beyond 8 bits.
If a register contains 255 decimal and you add 1 then it will roll over to 0.
This will set the status.c and the status.z.
If the register contains 255 decimal and you add 2 then it will roll over to 1.
This will set the status.c but not the status.z (because its not zero).