It depends on what you're doing with the number(s).
If your displaying them using LCDOUT/SEROUT/HSEROUT/ARRAYWRITE you can use the SDEC modifier to display the value 65535 as -1.
If you're doing further math with the numbers you need check the highest bit, if it's set the value is negative and you can use the ABS operator to retrieve the actual value, do whatever needs done (like a division) and then restore the sign.
Code:
X VAR WORD
Sign VAR BIT
X = -5000
HSEROUT["Raw: ", DEC X, " Signed: ", SDEC X, 13]
Sign = X.15 ' Preserve sign
X = ABS(X) / 5 ' Divide absolute value
X.15 = Sign ' Restore sign
HSEROUT[SDEC X, 13]
If all you want to do is cap the value at 0 then
Bookmarks