43 Program to count odd number from 8 bit array in 8086 Microprocessor

Code:

; Program to count odd number from 8 bit array
.MODEL SMALL
.STACK 100h
.DATA
   COUNT DB 0
   ARR DB 10H,23H,6H,11H,13H
.CODE
  MOV AX , @DATA       ; Initializing Data Segment
  MOV DS , AX

  MOV CX , 5           ; Initializing loop counter
                     
  MOV SI , OFFSET ARR  ; Initializing Base Address

 NEXT:
    MOV AL , [SI]      ; STORING EACH VALUE
    ROR AL , 1         ; ROTATING CONTENT OF AL BY 1 BIT
    JNC UP             ; JUMP IF NOT CARRY
     INC COUNT
  UP:
     INC SI
     LOOP NEXT         ; DECREMENT CX  IF CX == 0 THEN EXIT

  MOV BL , COUNT       ; STORING RESULT

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

END





Ouput:

Count odd number from 8 Bit array

Previous
Next Post »