        .MODEL  SMALL, os_dos
.data
    Buff        db      10
    Lenth       db      0
    Num         db      8 DUP (0)
    BuffOut	db 	4 DUP (0),'$'
    Hexes       db      "ABCDEF"
    
    Mess1       db      "Enter a Number less than 65535 :",10,13,'$'
    
    Result      db      "The Number in HEX is :  $" 
    NewLine     db      10,13,'$' 
.code
;******  Program wich will change asci number to an integer **********
AsciToInt:
;********* Get an entered String Number **********
    lea dx,Buff
    mov ah,0Ah
    int 21h
;*************************************************    
    mov Temp,1
    xor bx,bx
    xor di,di
    mov bl,Lenth
    inc dx
    mov si,dx
NextChar:    
    xor ax,ax
    mov al,[si+bx] ; Get the first digit it is the right char
    sub al,30h      ;; change ascii char to its number
    mov cx,Temp
    mul cx          ; multiply first by 1 , second by 10 ,third by 100 etc ...
    add di,ax       ;add in di what we've got
    mov ax,10
    mul cx          ; mul ax by 10 for next char
    mov Temp,ax
    dec bx
    jnz NextChar

    lea dx,NewLine
    mov ah,9
    int 21h

    ret        
start:  
;  int 3

          mov ax,seg Buff  
          mov ds,ax  
          mov es,ax
;******  Print first Message *************
      lea dx,Mess1
      mov ah,9
      int 21h
;******************************************
    call AsciToInt  ; Change the entered string number to an integer
    mov ax,di       ; the number is returned in di
    lea si,BuffOut	;Buffer wich will contains Hex Chars
    lea di,Hexes	; Offset to ascii Hexes from A to F
    add si,4		; We suppose we 'll have only 4 hex digits
    mov dx,4		; We will compute the 4 digits
    mov cl,4		; we will use it for the rotate 
Continue:    
    dec si
    push ax
    and al,0Fh		;Get in al the right kex digit
    cmp al,9		; see if it is a number 0->9 or a char A->B
    jg ItsChar		; if big than 9 it is a char
    add al,30h
    jmp PutChar
ItsChar:
    xor bx,bx
    mov bl,al
    sub bl,0Ah
    mov al,[di + bx]
PutChar:
    mov [si],al
    pop ax
    shr ax,cl
    dec dx
    jnz Continue
;***************************************    
lea dx,Result
mov ah,9
int 21h
mov dx,si
mov ah,9
int 21h
lea dx,NewLine
mov ah,9
int 21h

TheEnd:
          ; Terminate the program
          mov ax,04c00h
          int 21h
end start
