汇编一点点提高5

;汇编一点点提高5——编写一个程序实现将数据段中存储在STRING处到NUM处的字符串进行分类统计,然后将结果存入以lett;er、digit和other为名的存储单元中,并以十进制显示出来
DATAS SEGMENT ;此处输入数据段代码
string db '12ABCDE#3aaaa 456789143!@Y(78)=(1)' len equ $-string string1 db 'letter=$' string2 db 'digit=$' string3 db 'other=$' letter db 0 digit db 0 other db 0 DATAS ENDS STACKS SEGMENT ;此处输入堆栈段代码 STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX ;此处输入代码段代码 lea bx,string mov cx,len bagin: mov ax,[bx] cmp al,30h jb lower ;比0小就跳到lower cmp al,39h ja higher ;比9大就跳到higher jmp digit1 lower: cmp al,20h ja other1 jmp over higher: cmp al,41h ;比A小就跳到oher1 jb other1 cmp al,5ah ;比Z大就跳到higher1 ja higher1 jmp letter1 higher1: cmp al,61h jb other1 ;比a小就跳到oher1 cmp al,7ah ja other1 ;比z大就跳到higher1 jmp letter1 jmp over digit1: ;数字加1 inc digit jmp over letter1: ;字母加1 inc letter jmp over other1: ;其他加1 inc other jmp over over: inc bx loop bagin show: ;显示 lea dx,string1 mov ah,9 int 21h xor ax,ax ;等价于mov ax,0;将ax初始化为0 mov al,letter call display call newline lea dx,string2 mov ah,9 int 21h xor ax,ax mov al,digit call display call newline lea dx,string3 mov ah,9 int 21h xor ax,ax mov al,other call display call newline MOV AH,4CH INT 21H newline proc near ;输出换行子程序 mov ah,2 mov dl,13 int 21h mov ah,2 mov dl,10 int 21h ret newline endp display proc near ;输出十进制数子程序 push bx mov bl,10 ; 执行ax/bl,al存放商,ah存放余数 div bl push ax mov dl,al ;输出十进制十位 add dl,30h mov ah,2 int 21h pop ax mov dl,ah ;输出十进制个位 add dl,30h mov ah,2 int 21h pop bx ret display endp CODES ENDS END START
原文地址:https://www.cnblogs.com/mm-happy/p/3751344.html