Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- PUBLIC @atobinom@4
- .model flat
- .data
- bin db 16 dup (?)
- revbin db 17 dup (?)
- .code
- @atobinom@4 proc
- lea esi,bin
- mov eax,ecx
- mov ecx,16
- beg_2_:
- cmp eax,0
- je EXIT
- cdq
- mov ebx,2
- idiv ebx
- cmp edx,0
- je EQL
- mov ebx,'1'
- mov [esi],ebx
- jmp SKIP2
- EQL:
- mov ebx,'0'
- mov [esi],ebx
- SKIP2:
- inc esi
- dec ecx
- jmp beg_2_
- EXIT:
- beg_3_:
- mov ebx,'0'
- mov [esi],ebx
- inc esi
- loop beg_3_
- lea esi,bin
- lea edi,revbin
- add esi,15
- mov ecx,16
- beg_4_:
- mov eax,[esi]
- mov [edi],eax
- dec esi
- inc edi
- loop beg_4_
- mov eax,'b'
- mov [edi],eax
- lea edi,revbin
- mov eax,edi
- ret
- @atobinom@4 endp
- PUBLIC @atohex@4
- .model flat
- .data
- hex db 5 dup (?)
- .code
- @atohex@4 proc
- mov eax,ecx
- call @atobinom@4
- cld
- mov edi,eax
- mov esi,0 ;sum
- mov ecx,4
- push 1
- push 2
- push 4
- push 8
- beg_2:
- mov eax,[edi]
- call @chtoint@1
- pop ebx
- imul ebx
- add esi,eax
- inc edi
- loop beg_2
- ;
- cmp eax,0
- jne NEXT_3_0
- mov ebx,'0'
- jmp END_3
- NEXT_3_0:
- ;
- cmp eax,1
- jne NEXT_3_1
- mov ebx,'1'
- jmp END_3
- NEXT_3_1:
- ;
- END_3:
- mov [edi],ebx
- mov ebx,'8'
- mov [edi+1],ebx
- mov [edi+2],ebx
- mov [edi+3],ebx
- mov ebx,'h'
- mov [edi+4],ebx
- mov eax,edi
- ret
- @atohex@4 endp
- PUBLIC @chtoint@1
- .model flat
- .code
- @chtoint@1 proc
- mov eax,ecx
- cmp eax,'1'
- je EQL_3
- mov eax,0
- jmp SKIP_3
- EQL_3:
- mov eax,1
- SKIP_3:
- ret
- @chtoint@1 endp
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement