Title NhapMang
 .model small
 .Stack 100h
 .Data
 tb1 db 'Moi nhap ki tu:$' 
 tb2 db 13,10,'ket qua:$'
 A db 200 dup(?) 
 dem dw 0
 .code
 main proc
    mov ax,@data
    mov ds,ax
    mov es,ax 

    mov ah,9
    lea dx,tb1 ;thong bao nhap gia tri tung phan tu cua mang
    int 21h 
 
    lea di, A
    cld 
  NhapKiTu: 
    mov ah,1
    int 21h
  
    CMP AL,0Dh ;so sanh Al voi ki tu'enter'
    Je ketthuc ;neu AL='enter' thi ket thuc

    Cmp Al, 'a' ;so sanh Al voi 'a'
    JB KiTuHoa ;Al<'a' thi HienKT
    Cmp Al,'z' ;so sanh Al voi 'z'
    JA NhapKiTu ;neu Al>'z' thi HienKT 
    sub al,60h     
  
    STOSB ;chuyen ki tu AL vao dau chuoi
    Inc dem
    JMP NhapKiTu ;lenh nhay khong dieu kien 

  KiTuHoa: 

    Cmp al,'A'
    JB NhapKiTu
    Cmp al,'Z'
    ja NhapKiTu
    sub al,40h   
    STOSB ;chuyen ki tu AL vao dau chuoi
    Inc dem  
    jmp NhapKiTu 
 
 ketthuc:
 

    mov ah, 9   
    lea dx,tb2
    int 21h   
    mov cx, dem 
    lea Si, A
    cld
    Lap:
    lodsb ;chuyen vao so vua nhap vao mang  
    call InSo ;goi thu tuc nhap so
    Loop Lap 
    mov ah, 4ch
    int 21h
 main endp
  
  
  InSo proc  
    
  mov ah,0 ;xoa bit cao dx  
  
  mov bl,10 ;gan bx=10 

  div bl ;lay ket qua chia cho 10 
  add al,30h
  add ah,30h
   
   
  mov bx,ax
  mov ah, 2   
  mov dl,bl
  int 21h
  mov dl,bh
  int 21h
  ret
  InSo endp  
  
End main
  
  
 





 