The AND instruction
Bitwise logical AND.
The AND instruction format
| Instruction | Description |
|---|---|
| AND AL, imm8 | AL AND imm8. |
| AND AX, imm16 | AX AND imm16. |
| AND reg/mem8, imm8 | reg/mem8 AND imm8. |
| AND reg/mem16, imm16 | reg/mem16 AND imm16. |
| AND reg/mem16, imm8 | reg/mem16 AND imm8 (sign-extended). |
| AND reg/mem8, reg8 | reg/mem8 AND reg8. |
| AND reg/mem16, reg16 | reg/mem16 AND reg16. |
| AND reg8, reg/mem8 | reg8 AND reg/mem8. |
| AND reg16, reg/mem16 | reg16 AND reg/mem16. |
Performs a bitwise AND operation on the destination (first) and source (second) operands and stores the result in the destination operand location. The source operand can be an immediate value, a register or a memory location; the destination operand can be a register or a memory location. (Two memory operands, however, cannot be used in the same instruction.) Each bit of the result is set to 1 if both corresponding bits of the first and second operands are 1; otherwise, it is set to 0.
This instruction can be used with the lock prefix to allow it to execute atomically.
Usage example
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov al, 00101101b ; Copy the value 45 into the al register mov bl, 00101000b ; Copy the value 40 into the bl register and al, bl ; Clear all bits except bits 3 and 5 mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".
Processor status flags
CF
0PF
YesAF
?ZF
YesSF
YesTF
NoIF
NoDF
NoOF
0