Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc ConvertBinTodec
- mov cx,0
- mov cl,strBin[1]
- mov si, 2
- add si, cx
- dec si
- mov ax, 0
- mov bx, 1
- binToDec:
- cmp strBin[si], '0'
- JE if_0
- add ax,bx
- if_0: shl bx,1
- dec si
- cmp si,1
- jNE binToDec
- mov bx, 10
- mov si, 6
- mov strDec[7], '$'
- setCharDec: mov dx,0
- div bx
- add dx,'0'
- mov strDec[si], dl
- dec si
- cmp si, 1
- JNE setCharDec
- ret
- endp ConvertBinTodec
- proc ConvertBinToOct
- mov cx,0
- mov cl,strBin[1]
- mov si, 2
- add si, cx
- mov strOct[6], '$'
- dec si
- mov di,5
- get_num_oct:
- mov cx, 3
- mov ax, 0
- mov bx, 1
- next_o:
- cmp strBin[si], '0'
- JE if_0_
- add ax,bx
- if_0_: shl bx,1
- dec si
- cmp si,1
- jE set_oct_num
- loop next_o
- set_oct_num:
- add ax, '0'
- mov strOct[di],al
- dec di
- mov bx, 1
- cmp si,1
- jne get_num_oct
- add_0_O: cmp di,1
- JE endOct
- mov strOct[di],'0'
- dec di
- jmp add_0_O
- endOct:
- ret
- endp ConvertBinToOct
- proc ConvertBinHex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement