Mikroelektronika MIKROE-350 Fiche De Données
$1234
and $5678 ' equals $1230
' because ..
' $1234 : 0001 0010 0011 0100
' $5678 : 0101 0110 0111 1000
' ----------------------------
' and : 0001 0010 0011 0000
' $5678 : 0101 0110 0111 1000
' ----------------------------
' and : 0001 0010 0011 0000
' .. that is, $1230'
Similarly:
$1234
or
$5678 ' equals $567C
$1234
xor $5678 ' equals $444C
not $1234 ' equals $EDCB
Unsigned and Conversions
If number is converted from less complex to more complex data type, the upper
bytes are filled with zeroes. If number is converted from more complex to less com-
plex data type, the data is simply truncated (upper bytes are lost).
bytes are filled with zeroes. If number is converted from more complex to less com-
plex data type, the data is simply truncated (upper bytes are lost).
For example:
dim a as byte
dim b as word
' ...
dim b as word
' ...
a = $AA
b = $F0F0
b = b and a
' a is extended with zeroes; b becomes $00A0
b = $F0F0
b = b and a
' a is extended with zeroes; b becomes $00A0
Signed and Conversions
If number is converted from less complex to more complex data type, the upper
bytes are filled with ones if sign bit is 1 (number is negative); the upper bytes are
filled with zeroes if sign bit is 0 (number is positive). If number is converted from
more complex to less complex data type, the data is simply truncated (the upper
bytes are lost).
bytes are filled with ones if sign bit is 1 (number is negative); the upper bytes are
filled with zeroes if sign bit is 0 (number is positive). If number is converted from
more complex to less complex data type, the data is simply truncated (the upper
bytes are lost).
For example:
dim a as byte
dim b as word
' ...
dim b as word
' ...
a = -12
b = $70FF
b = b
b = $70FF
b = b
and a
' a is sign extended, upper byte is $FF;
' b becomes $70F4
' b becomes $70F4
149
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroBasic PRO for AVR
CHAPTER 5