5: BASIC Stamp Command Reference - DEBUG
BASIC Stamp Programming Manual 2.0c
•
www.parallaxinc.com
•
Page 101
Signed numbers are preceded with a space ( ) or a minus sign (-) to
indicate a positive or negative number, respectively. Normally, any
number displayed by the BASIC Stamp is shown in its unsigned (positive)
form without any indicator. The signed formatters allow you to display
the number as a signed (rather than unsigned) value. NOTE: Only Word-
sized variables can be used for signed number display.
The code below
demonstrates the difference in all three numbering schemes.
x VAR WORD
x = -65
DEBUG "Signed: ", SDEC x, " ", ISHEX x, " ", ISBIN x, CR
DEBUG "Unsigned: ", DEC x, " ", IHEX x, " ", IBIN x
This code will generate the display shown below:
Signed: -65 -$41 -%1000001
Unsigned: 65471 $FFBF %1111111110111111
The signed form of the number –65 is shown in decimal, hexadecimal and
then in binary on the top line. The unsigned form, in all three number
systems, is shown on the bottom line. If the unsigned form looks strange
to you, it's because negative numbers are stored in twos-compliment
format within the BASIC Stamp.
Suppose that your program contained several DEBUG instructions
showing the contents of different variables. You would want some way to
tell them apart. One possible way is to do the following:
x VAR BYTE
y VAR BYTE
x = 100
y = 250
DEBUG "X = ", DEC x, CR ' Show decimal value of x
DEBUG "Y = ", DEC y, CR ' Show decimal value of y
but typing the name of the variables in quotes (for the display) can get a
little tedious. A special formatter, the question mark (?), can save you a lot
of time. The code below does exactly the same thing (with less typing):
D
ISPLAYING SIGNED VS
.
UNSIGNED
NUMBERS
.
A
UTOMATIC NAMES IN THE DISPLAY
.
Summary of Contents for BASIC Stamp 2e
Page 1: ...BASIC Stamp Programming Manual Version 2 0c...
Page 34: ...Quick Start Guide Page 32 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 340: ...ASCII Chart Page 338 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 342: ...Reserved Words Page 340 BASIC Stamp Programming Manual 2 0b www parallaxinc com...
Page 346: ...Conversion Formatters Page 344 BASIC Stamp Programming Manual 2 0b www parallaxinc com...