7.编程统计 NUM 字节单元中奇数的个数,将个数存入 RESULT 单元。
DATA SEGMENT
NUM DB 1,2,3,4,5,6,7,8,9,9
RESULT DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV DL,0
MOV BX,OFFSET NUM
MOV CX,10
AGAIN:MOV AL,[BX]
TEST AL,01H
JZ NEXT
INC DL
NEXT: INC BX
LOOP AGAIN
MOV RESULT,DL
MOV AH,4CH
INT 21H
CODE ENDS
END START
8.编程统计 NUM 字节单元中偶数的个数,将个数存入 RESULT 单元。
DATA SEGMENT
NUM DB 1,2,3,4,5,6,7,8,9,9
RESULT DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV DL,0
MOV BX,OFFSET NUM
MOV CX,10
AGAIN:MOV AL,[BX]
TEST AL,01H
JNZ NEXT
INC DL
NEXT: INC BX
LOOP AGAIN
MOV RESULT,DL
MOV AH,4CH
INT 21H
CODE ENDS
END START