title Min
.model small
.stack 100h
.data
    tb db 'Nhap So(khong lon qua 2559): $'
    tapso db 200 dup (?)
    dem dw ?
    min db ?
    so dw ?
.code
    main proc
        mov ax,@data
        mov ds,ax
        mov es,ax
        
        mov ah,9
        lea dx,tb
        int 21h
        
        call nhapso
        mov ax,so
        mov bl,10
        div bl
        mov bl,ah
        mov cx,8
        Lap:
        shl bl,1
        jc inso1
        mov ah,2
        mov dl,30h
        int 21h
        loop lap
        jmp het
        inso1:
        mov al,2
        mov dl,31h
        int 21h
        loop lap
        het:
        mov ah,4ch
        int 21h
        
      
   main endp
    
    nhapso proc
        push cx
        mov ax,0
        mov so,ax
      nhapso1:
        mov ah,1
        int 21h
        cmp al,13         
        je ketthuc1
        CMP AL,'0'
        JB xoakitu
        CMP AL,'9'
        JA xoakitu          
        sub al,30h        
        mov ah,0         
        mov cx,ax       
        mov ax,so      
        mov bx,10       
        mul bx          
        add ax,cx      
        mov so,ax      
        jmp nhapso1
    xoakitu:            
        Mov ah,2        
        mov dl,08h      	; chuyen ki tu backspace vao DL de hien thi
        int 21h
        mov dl,20h      	; chuyen ki tu cach vao hien thi de xoa ki tu khac vua nhap
        int 21h 
        mov dl,08h
        int 21h
        JMP nhapso1
    ketthuc1:
    pop cx
    mov ah,2
    mov dl,13
    int 21h
    mov dl,10
    int 21h
    ret
    nhapso endp
End main
        