Assume LRC = 10.
LRC = 256 - LRC. Which works out to LRC = 246, but returns a warning message.
Now try this approach with LRC still = 10;
LRC = $FF - LRC ' LRC = 255 - 10. Now LRC = 245
LRC = LRC - 1. Now we have 245 - 1 which = 244. Oops! Not what we expected, although it
looked darn good at 1st glance.
Now try this, and see if you can figure out why it works & doesn't return the warning
message;
LRC = !256-LRC ' LRC = NOT 256 - LRC
Here's a short test to verify it;
Code:
LRC VAR BYTE
X VAR BYTE
Main:
FOR X = 0 TO 255
LRC = X ' We'll work with LRC = 0 to 255 to prove it works
HSEROUT ["256-",DEC X,"="]
LRC = !256-LRC
HSEROUT [DEC LRC,13,10]
NEXT X
Here:
GOTO Here ' done
END
Food for thought ehh....;o}
A more efficient approach would be to just promote LRC to a word variable,
and use the lower byte for your result, but this is pretty cool.
Bookmarks