Advertisement
Guest User

Untitled

a guest
May 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. proc ConvertBinTodec
  2.             mov cx,0
  3.             mov cl,strBin[1]
  4.             mov si, 2
  5.             add si, cx
  6.             dec si
  7.             mov ax, 0
  8.             mov bx, 1
  9.  
  10. binToDec:  
  11.             cmp strBin[si], '0'
  12.             JE if_0
  13.             add ax,bx
  14.     if_0:   shl bx,1
  15.             dec si
  16.             cmp si,1
  17.             jNE binToDec
  18.            
  19.             mov bx, 10
  20.             mov si, 6
  21.            
  22.             mov strDec[7], '$'
  23. setCharDec: mov dx,0
  24.             div bx
  25.             add dx,'0'
  26.             mov strDec[si], dl
  27.             dec si
  28.             cmp si, 1
  29.             JNE setCharDec
  30.  
  31.             ret
  32.         endp ConvertBinTodec
  33.        
  34.         proc ConvertBinToOct
  35.             mov cx,0
  36.             mov cl,strBin[1]
  37.             mov si, 2
  38.             add si, cx
  39.            
  40.             mov strOct[6], '$'
  41.             dec si
  42.            
  43.             mov di,5
  44. get_num_oct:           
  45.             mov cx, 3
  46.             mov ax, 0
  47.             mov bx, 1
  48. next_o:
  49.             cmp strBin[si], '0'
  50.             JE if_0_
  51.             add ax,bx
  52. if_0_:      shl bx,1
  53.             dec si
  54.             cmp si,1
  55.             jE set_oct_num
  56.             loop next_o
  57. set_oct_num:
  58.             add ax, '0'
  59.             mov strOct[di],al
  60.             dec di
  61.             mov bx, 1
  62.             cmp si,1
  63.             jne get_num_oct
  64.            
  65. add_0_O:    cmp di,1
  66.             JE endOct
  67.             mov strOct[di],'0'
  68.             dec di
  69.             jmp add_0_O
  70.            
  71.        
  72.  
  73.    endOct: 
  74.             ret
  75.         endp ConvertBinToOct
  76.        
  77.         proc ConvertBinHex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement