mmicroprocessor.blogspot.com
.MODEL SMALL
.DATA
DATA1 DW 1000H, 0A0BH, 0005H, 2012H, 0A13H
MSG1 DB 0AH, "The number of even numbers in the list
are: ", "$"
MSG2 DB 0AH, "The number of odd numbers in the list
are: ", "$"
.CODE
.STARTUP
XOR AL, AL
XOR AH, AH
MOV BX, OFFSET DATA1
MOV CX, 5
L1:
MOV DX, [BX]
AND DX, 0001H
CMP DX, 0
JZ L2
INC AH
JMP L3
L2:
INC AL
L3:
ADD BX, 2
LOOP L1
MOV CL, AL
MOV CH, AH
MOV DX, OFFSET MSG1
MOV AH, 09H
INT 21H
ADD CL, 30H
MOV DL, CL
MOV AH, 02H
INT 21H
MOV DX, OFFSET MSG2
MOV AH, 09H
INT 21H
ADD CH, 30H
MOV DL, CH
MOV AH, 02H
INT 21H
MOV AH, 4CH
INT 21H
END
Output:
The number of even numbers in the list are: 2
The number of odd numbers in the list are: 3
No comments:
Post a Comment