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 Y X AND Y
0 0 0
0 1 0
1 0 0
1 1 1
Code I: Lowercase 🡆 Uppercase Code II: Integer 🡆 ASCII
 INCLUDE Irvine32.inc
 .data
  p1  BYTE  "Enter a letter: ", 0
  p2  BYTE  "The letter is ", 0
  buffer  BYTE  64 DUP(0)
 .code
 main PROC
  mov   edx, OFFSET p1
  call  WriteString
  mov   edx, OFFSET buffer
  mov   ecx, SIZEOF buffer
  call  ReadString
  mov   ecx, eax
  mov   esi, OFFSET buffer
 L1:
  cmp   BYTE PTR [esi], 'a'
  jl    L2
  cmp   BYTE PTR [esi], 'z'
  jg    L2
 

L2: inc esi loop L1 mov edx, OFFSET p2 call WriteString mov edx, OFFSET buffer call WriteString exit main ENDP END main
 INCLUDE Irvine32.inc
 .data 
  p1  BYTE  "Enter a digit: ", 0
  p2  BYTE  "The ASCII is '", 0
  p3  BYTE  "' or ", 0
 .code
 main PROC
  call  Clrscr
  mov   edx, OFFSET p1
  call  WriteString
  call  ReadInt
 

mov edx, OFFSET p2 call WriteString call WriteChar mov edx, OFFSET p3 call WriteString call WriteInt exit main ENDP END main
An Execution Example
An Execution Example

  Enter a letter:  e 
  The letter is E

  Enter a digit:  7 
  The ASCII is '7' or +55

The italic white text with navy background is entered by users.



      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown