[Assembly 8086] How To Check Odd And Even Number in Assembly 8086

The Following Program will take a single digit or character from user and if digit it will print odd or even else it will convert Case








.model small
.stack 100h
.data
msg db 10,13,'Enter number=$'
msg1 db 10,13,'Number is even$'
msg2 db 10,13,'Number is odd$'
msg3 db 10,13, 'Case Convertion=$'






.code

   mov ax,@data
   mov ds,ax
   lea dx,msg
   mov ah,9
   int 21h
   
   mov ah,1
   int 21h
    
   
   mov bl,al
   
   cmp bl,'9'
   ja cc 
   
   
   sar bl,1  
   jc odd
   
   
   lea dx,msg1
   mov ah,9
   int 21h
     
   
   jmp exit
   
   odd:
      
   lea dx,msg2
   mov ah,9
   int 21h
   
   
   jmp exit
   
     
   
   cc:  
   
   lea dx,msg3
     mov ah,9
     int 21h  
   
   cmp bl,'A'
   jnle next
   
   
   
   next:
   
    cmp bl,'Z'
    jnge con
    
    jmp lower
   
   
   
   
   con:
   
     add bl,32d
     mov dl,bl
     mov ah,2
     int 21h
     
     jmp exit 
     
     
   lower:
      
      cmp bl,'a'
      jnle ln
      
      
    
    ln:
       cmp bl,'z'
       jnge conl
    
      
      
   conl:
      sub bl,32d
     mov dl,bl
     mov ah,2
     int 21h
     
     jmp exit 
     
     
   

   exit:

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment