AND
Instruction (Cont.)
The operands can be 8, 16, or 32 bits, and they must be the same size. For each matching bit in the two operands, the output bit is 1 when both of the input bits are 1; otherwise, it is 0. The table on the right describes the boolean expression X AND Y .
|
|
A
and lowercase a
, it becomes clear that only bit 5 is different:
0 1 1 0 0 0 0 1 = 61h ('a') 0 1 0 0 0 0 0 1 = 41h ('A')The rest of the alphabetic characters have the same relationship. If we
AND
any character with 11011111
binary, all bits are unchanged except for bit 5, which is cleared.
AL=05h
, you can OR
it with 30h
to convert it into the ASCII code for the digit 5 (35h
).
Code I: Converting Lowercase Letters into Uppercase Letters |
Code II: Converting an Integer Digit into an ASCII Digit |