Re: How to prevent variable going below zero?
You can see when you reached zero the STATUS.Z reflected that. However, you alter the STATUS Register in your code. About the only thing you can change is the C bit. Delete the "status=1" line and try again.
your assertion is
If subtracting and want to see if it rolled from 0 to 255, "STATUS.C = 0". Look in your data sheet for the STATUS Register and how it works.
You don't state what PIC this is for, so I randomly grabbed the data sheet for a PIC16F1824; STATUS Register 3-1, page 24.
if your assertion was correct it would not matter but its a12f1840
i repeat
mike would you like to provide some pbp code that demonstrates use of status register following pbp addition or subtraction
for any chip
Warning I'm not a teacher
Bookmarks