DATA SEGMENT
STR1 DB 'ADFAJXNXNEIUTYDFHRIFOFJAFLKDXZA'
N EQU $-STR1
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:MOV AX,DATA
MOV DS,AX
MOV DX,N-1
MOV DI,0
MOV BX,0
MOV BP,0 ;控制外循环
LOOP1:MOV CX,DX
MOV SI,0
JMP STR1[BP],# ;判断是否重复
JE NEXT2
LOOP2:MOV AL,STR1[SI]
CMP AL,STR1[SI+1]
JNE NEXT1
INC DI
MOV STR1[SI+1],# ;后面有相同的就至#
NEXT1:INC SI
LOOP LOOP2
DEC DX
CMP BX,DI
JNG NEXT2
MOV AH,AL ;存字符
MOV BX,DI ;存个数
NEXT2:CMP BP,N-1
JE OVER
INC BP
JMP LOOP1
OVER :MOV AH,4CH
INT 21H
CODE ENDS
END START
没有调试过,可能有不少错误,大概算法都是对的