42 Program to find number is odd or even in 8086 Microprocessor

Code:

; Program to find number is odd or even
.MODEL SMALL
.STACK 100H
.DATA
    MSG1 DB "ODD$"
    MSG2 DB "EVEN$"
    NUM DB ?

.CODE
   MOV AX , @DATA  ; Initializing Data Segment
   MOV DS , AX

   MOV AH , 1h      ; Taking 1 number as input
   INT 21H
   MOV NUM , AL    ; Storing input result

   ROR AL , 1      ; Rotate Right by 1 bit
   JC EL           ; Jump If Carry   i.e odd
    LEA DX , MSG2  ; Even
    JMP EXIT       ; JUMP FOR EXIT
 EL:
    LEA DX , MSG1  ; Odd

EXIT:
   MOV AH , 09H    ; Service routine to display Result
   INT 21H

   MOV AH , 4CH    ; Service Routine for exit
   INT 21H
END





Ouput:


Odd or Even in 8086 Microprocessor



Previous
Next Post »