PROGRAMMING CONCEPTS–II 3-39
This gives AL = 08H in the AL register. The upper nibble of 78H has been masked. As
another example, see below where 16-bit data is ANDed with 0FFFH, so as to mask the
upper 4 bits. This is a particular case when only 12 bits of this data are needed.
MOV AX, 9876H
AND AX, 0FFFH
AX now has a content of 0876H.
Typical Applications of Logical Instructions Now, let us use these logical instructions
in some simple applications.
AND To convert an ASCII number to a binary number, mask the number with 0FH.
MOV AH, 01 ;get in the number through the keyboard
INT 21H
AND AL, 0FH ;mask the upper nibble
OR To convert an 8-bit binary number (from 0 to 9) to ASCII, OR with 30H.
MOV AL, 9 ;AL = 09
OR AL, 30H ;AL = 39H ...