终于搞定了,你看看应该没什么问题
DATAS SEGMENT
STR DB "please input a string:$"
STR1 DB "0 numbers:$"
STR2 DB "1 numbers:$"
BUF DB 20
DB ?
DB 20 DUP (?)
CRLF DB 0AH,0DH,"$"
X DB 30H ;存储0的个数
Y DB 30H ;存储1的个数
DATAS ENDS
STACKS SEGMENT STACK
DB 200 DUP(?)
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START: MOV AX,DATAS
MOV DS,AX
LEA DX,STR ;显示字符串
MOV AH,9
INT 21H
MOV AH,10 ;字符串输入
LEA DX,BUF
INT 21H
LEA DX,CRLF ;输出换行回车
MOV AH,9
INT 21H
MOV CL,BUF+1 ;第二个字节保存着字符个数
LEA SI,BUF+2 ;存储字符串的地址从第3个字节开始
DEC SI
INC CL
NEXT: DEC CL
INC SI
CMP CL,0
JE VIE
MOV DL,[SI]
CMP DL,30H
JE XX
CMP DL,31H
JE YY
JNZ NEXT
XX:INC X
JMP NEXT
YY:INC Y
JMP NEXT
VIE: LEA DX,STR1
MOV AH,9
INT 21H
;MOV BL,X
MOV DL,X
MOV AH,2
INT 21H
LEA DX,CRLF ;输出换行回车
MOV AH,9
INT 21H
LEA DX,STR2
MOV AH,9
INT 21H
;MOV BL,Y
MOV DL,Y
MOV AH,2
INT 21H
MOV AH,4CH
INT 21H
CODES ENDS
END START