Code:
; Program to add only even number in the array
.MODEL SMALL
.STACK 100H
.DATA
SUM DB 0
ARR DB 10H,15H,12H,4H,7H
.CODE
MOV AX , @DATA ; Initializing Data Segment
MOV DS , AX
MOV SI , OFFSET ARR ;Storing Base Address of ARR
MOV CX ,5 ; Initializing Loop Counter
NEXT:
MOV AL , [SI]
ROR AL , 01 ; Rotate right by 1 bit
JC DN ; Jump if not carry
ROL AL , 01 ; Rotating to get original number
ADD SUM , AL
DN:
INC SI
LOOP NEXT
MOV DL , SUM
MOV AH , 4CH ; Service routine for exit
INT 21H
END
Ouput:
.MODEL SMALL
.STACK 100H
.DATA
SUM DB 0
ARR DB 10H,15H,12H,4H,7H
.CODE
MOV AX , @DATA ; Initializing Data Segment
MOV DS , AX
MOV SI , OFFSET ARR ;Storing Base Address of ARR
MOV CX ,5 ; Initializing Loop Counter
NEXT:
MOV AL , [SI]
ROR AL , 01 ; Rotate right by 1 bit
JC DN ; Jump if not carry
ROL AL , 01 ; Rotating to get original number
ADD SUM , AL
DN:
INC SI
LOOP NEXT
MOV DL , SUM
MOV AH , 4CH ; Service routine for exit
INT 21H
END
Ouput: