Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. segment data
  2.     nl: db 10,13,'$'
  3.     message: db 10,13,'Enter 2 hexadecimal numbers: $'
  4.  
  5. segment stack stack
  6.     resb 256
  7.  
  8. segment code
  9.     ..start:
  10.         mov cx,2
  11.     LOOP_TWO:
  12.         push cx
  13.         mov ax,data
  14.         mov ds,ax
  15.        
  16.         mov dx,message
  17.         mov ah,9
  18.         int 21h
  19.  
  20.         xor ax,ax
  21.         mov ah,1h
  22.         int 21h
  23.         mov dl,al
  24.         sub dl,30h
  25.         cmp dl,31h
  26.         jl to_upper_1
  27.         sub dl,20h
  28.     to_upper_1:
  29.         cmp dl,9h
  30.         jle m1
  31.         sub dl,7h
  32.     m1:
  33.         mov cl,4h
  34.         shl dl,cl
  35.         int 21h
  36.         sub al,30h
  37.         cmp al,31h
  38.         jl to_upper_2
  39.         sub al,20h
  40.     to_upper_2:
  41.         cmp al,9h
  42.         jle m2
  43.         sub al,7h
  44.     m2:
  45.         add dl,al
  46.     jmp outbin
  47.  
  48.     ; OUTPUT BINARY AHEAD ;
  49.     outbin:
  50.        
  51.         push dx
  52.         mov dx,nl
  53.         mov ah,9h
  54.         int 21h
  55.         pop dx
  56.        
  57.        
  58.         mov cx,8
  59.        
  60.         shl dx,8h
  61.         mov bx,dx
  62.         mov ah,2h
  63.         l1:
  64.             xor dx,dx
  65.             sal bx,1
  66.             adc dl,30h
  67.             int 21h
  68.             loop l1
  69.     pop cx
  70.     cmp cx,2
  71.     dec cx
  72.     jnz LOOP_TWO
  73.     exit:
  74.         mov ax,4c00h
  75.         int 21h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement