code segment
assume cs:code
org 100h
start:
jmp bbb
tab db 'qwertQWERTqwertQWERTQWERTQWERTQWERT',10,13,'$'
x db 0
y db 10,13,0,0,0,'$'
bbb:
push cs
pop ds
lea dx,tab
mov ah,9
int 21h
lea bx,tab
dec bx
l1:
inc bx
cmp byte ptr[bx],10 ;遇换行符结束扫描
je l3
cmp byte ptr[bx],'Q' ;检查是否Q
je l2
jmp l1
l2:
inc byte ptr[x] ;空格计数
jmp l1
l3:
mov al,byte ptr[x]
mov ah,0
mov cl,10
div cl
mov byte ptr[y+4],ah ;保存个位
mov ah,0
div cl
mov byte ptr[y+3],ah ;保存十位
mov ah,0
mov byte ptr[y+2],al ;保存百位
mov al,byte ptr[y+2]
add al,30h ;百位转ASC2
mov byte ptr[y+2],al
mov al,byte ptr[y+3]
add al,30h ;十位转ASC2
mov byte ptr[y+3],al
mov al,byte ptr[y+4]
add al,30h ;个位转ASC2
mov byte ptr[y+4],al
mov ah,9
lea dx,y
int 21h
mov ah,4ch
int 21h
code ends
end start