DATAS SEGMENT
BUF DW 00000000B,00000000B,11110000B,00001111B
n =$-BUF
OUTPUT DB 'The number of zero is '
X DW 0
Y1 DB 0AH,0DH,'The number of Positive is '
Y DW 0
Z1 DB 0AH,0DH,'The number of Negative is '
Z DW 0
OUTEND DB '$'
DATAS ENDS
STACKS SEGMENT
DB 200 DUP(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
LEA BX,BUF
MOV CX,n
AGAIN:
TEST BX,BX
TEST BYTE PTR[BX],0FFH
JZ COUNTX
AND BYTE PTR[BX],80H
JZ COUNTY
JMP COUNTZ
JMP EXIT
OUTPUTN:ADD X,30H
ADD Y,30H
ADD Z,30H
LEA DX,OUTPUT
MOV AH,9
INT 21H
JMP EXIT
COUNTX: INC X
INC BX
DEC CX
JNZ AGAIN
JMP OUTPUTN
JMP EXIT
COUNTY: INC Y
INC BX
DEC CX
JNZ AGAIN
JMP OUTPUTN
JMP EXIT
COUNTZ: INC Z
INC BX
DEC CX
JNZ AGAIN
JMP OUTPUTN
JMP EXIT
EXIT: MOV AH,4CH
INT 21H
CODES ENDS
END START
为什么统计的0的个数有误?而且是比实际的数目大$-BUF个(上面的程序是比实际的大4)。
虚心请教!