Download Print this page

ICS Advent ADIO1600 Series Product Manual page 71

Advertisement

Appendix C: Basic Integer Variable Storage
Data are stored in integer variables (% type) in 2's complement form. Each integer variable uses 16
bits or two bytes of memory. Sixteen bits of binary data is equivalent to 0 to 65,535 decimal but the
2's complement convention interprets the most significant bit as the sign bit so the actual range is
-32,768 to +32,767. Numbers are represented as follows:
N
u
m
b
r e
+
3
7 2
7 6
+
1
0 0
0 0
+
1
0
1 -
1 -
0 0
0 0
3 -
7 2
8 6
Note: Bit 7 (B7) of the high byte is the sign bit. (1=negative, 0=positive)
Integer variables are the most compact form of storage for the 12-bit data from the A/D converter
and the 16-bit data from the interval timer. Therefore, to conserve memory and disk space and to
optimize execution time, all data exchange via the CALL is through integer type variables.
This poses a programming problem when handling unsigned numbers in the range 32,768 to 65,535.
If you wish to input or output an unsigned integer greater than 32,767, then it is necessary to work
out what its 2's complement signed equivalent is. For example, if 50,000 decimal is to be loaded into
a 16-bit counter, an easy way to convert this to binary is to enter BASIC and execute PRINT
HEX$(50000). This returns C350 which, in binary form is: 1100 0011 0101 0000. Since the most
significant bit is a one, this would be stored as a negative integer and, in fact, the correct integer
variable value would be 50,000 - 65,536 = -15,536.
Manual Number: 00650-004-5
i H
h g
B
y
e t
B
7
B
6
B
5
B
4
B
3
0
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
1
1
1
0
0
0
0
Appendix C: Basic Integer Variable Storage
B
2
B
1
B
0
B
7
B
6
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
1
1
0
0
0
0
0
L
o
w
B
y
e t
B
5
B
4
B
3
B
2
B
1
1
1
1
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
0
0
0
0
0
0
0
Page C-1
B
0
1
0
1
0
1
0
0

Advertisement

loading