Mikroelektronika MIKROE-742 데이터 시트

다운로드
페이지 532
$1234 
and $5678          // equals $1230 
{ because ..
$1234 : 0001 0010 0011 0100
$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 a number is converted from less complex to more complex data type, the upper
bytes are filled with zeroes. If a number is converted from more complex to less
complex data type, the data is simply truncated (the upper bytes are lost).
For example:
var a : byte; b : word;
...
a := $AA;
b := $F0F0;
b := b 
and a;
{ a is extended with zeroes; b becomes $00A0 }
Signed and Conversions
If number is converted from less complex data type to more complex, upper bytes
are filled with ones if sign bit is 1 (number is negative); upper bytes are filled with
zeroes if sign bit is 0 (number is positive). If number is converted from more com-
plex data type to less complex, data is simply truncated (upper bytes are lost).
For example:
var a : byte; b : word;
...
a := -12;
b := $70FF;
b := b 
and a;
{ a is sign extended, with the upper byte equal to $FF;
b becomes $70F4 }
159
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroPASCAL PRO for AVR
CHAPTER 5