That's his problem... he DOES want to use a byte but as he adds or subtracts to the byte value it wraps and gives false operation.if you want your number staying between 0 and 255 ... use a BYTE, instead of a WORD
The way I usually handle this sort of thing is to have a routine that does the addition or subtraction with a temp copy of the variable, and only update the variable if the operation is valid.
You don't have to detect a negative number... what you want to know is if you add X to Y will it be < Y (wrapped 255) and if you subtract X from Y will it be > Y (wrapped 0). Don't modify Y until you know the answer. You can have the routine limit the results to 255 or 0 if that's how you want it to work, or ignore the operation.




Bookmarks