Title ChuanHoa
.Model Small
.Stack 100h
.Data
    chuoi1 db 'Nhap chuoi: ',10,13,'$'
    chuoi2 db 10,13,'Ket qua:$'
    chuoi db 128 dup (?)
    i dw 0
    dem dw 0
    thu db ?

.Code
    Main proc
        Mov ax,@data
        Mov ds,ax
        mov es,ax
        mov ah,9
        lea dx,chuoi1
        int 21h
        lea DI,chuoi
    
    LapNhap:
        mov ah,1
        int 21h
        cmp al,1Bh
        je kt
        stosb
        Inc i
        cmp i,128
        je kt
        jmp LapNhap
        
    kt: 
        cmp i,0
        je xong
        lea SI,chuoi
        mov cx,i
    kt1:    
        lodsb
        cmp al,20h
        je het
        xor ah,ah
        PUSH AX
        inc dem
        cmp cx,1
        je het
        loop kt2
    kt2:
        lodsb
        cmp al,20h
        je daucach
        xor ah,ah
        push ax
        inc dem
        loop kt2
    daucach:
        xor ah,ah
        push ax
        inc dem
    het:    
        loop kt1
        
        mov ah,9
        lea dx,chuoi2
        int 21h
        
        mov cx,dem
    hienthi:
        mov ah,2
        POP DX
        int 21h
        Loop hienthi
    xong:    
        mov ah,4ch
        int 21h
 main ENDP    
           
END Main        

