;从键盘输入一系列字符(以回车键结束),并按字母、数字及其它
;字符分类统计,最后显示这三类的统计结果
DATA SEGMENT
BUFFER DB 128,?,128 DUP(0)
NUM DB 0
WORDS DB 0
OTHER DB 0
CRLF DB 0AH,0DH,'$'
DATA ENDS
STACK SEGMENT PARA STACK
DW 128 DUP(?)
TOP LABEL WORD
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,SS:STACK,DS:DATA
MAIN PROC FAR
START:
MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
LEA SP,TOP
XOR BL,BL
XOR BH,BH
XOR DH,DH
LEA DX,BUFFER
MOV AH,0AH
INT 21H
MOV AH,9
LEA DX,CRLF
INT 21H
LEA SI,BUFFER
INC SI
MOV CL,[SI]
XOR CH,CH
L0: INC SI
MOV AL,[SI]
CMP AL,30H
JL L1
CMP AL,39H
JA L1
INC BL
JMP L4
L1: CMP AL,'A'
JL L2
CMP AL,'Z'
JA L2
INC BH
JMP L4
L2: CMP AL,'a'
JL L3
CMP AL,'z'
JA L3
INC BH
JMP L4
L3: INC DH
L4: LOOP L0
LEA DI,NUM
MOV [DI],BL
INC DI
MOV [DI],BH
INC DI
MOV [DI],DH
MOV CX,3
LEA SI,NUM
L5: MOV AH,2
MOV DL,[SI]
ADD DL,30H
INT 21H
INC SI
MOV AH,9
LEA DX,CRLF
INT 21H
LOOP L5
MOV AH,4CH
INT 21H
CODE ENDS
MAIN ENDP
END START