ASSUME CS:C, DS:D
;----------------------------------
D SEGMENT
MSG DB 'Please input: ', 13, 10, 36
XXX DB 96 DUP(0)
III DB 121, ?, 121 DUP(?) ;可输入120个字符
D ENDS
;----------------------------------
C SEGMENT
BEG:
MOV AX, D
MOV DS, AX
LEA DX, MSG
MOV AH, 9
INT 21H
LEA DX, III
MOV AH, 10 ;输入字符串
INT 21H
CMP III + 1, 0
JZ EXIT
MOV DL, 13
MOV AH, 2
INT 21H
MOV DL, 10
INT 21H
MOV CL, III + 1
MOV CH, 0
MOV SI, 0
LP1:
MOV BL, III[SI + 2]
SUB BL, 32
MOV BH, 0
INC BYTE PTR XXX[BX]
INC SI
LOOP LP1
;------------------------------
MOV BL, III + 1
LP3:
MOV SI, 0
LP2:
CMP BL, XXX[SI]
JNZ NEXT
MOV DX, SI
ADD DL, 32
MOV AH, 2
INT 21H
NEXT:
INC SI
CMP SI, 96
JB LP2
SUB BL, 1
JNZ LP3
EXIT:
MOV AH, 4CH
INT 21H
;------------------------------
C ENDS
END BEG
可以了。