Advertisement
YauhenMardan

asm_Hex_Bin

Jun 5th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. .386
  2. PUBLIC @atobinom@4
  3. .model flat
  4. .data
  5. bin db 16 dup (?)
  6. revbin db 17 dup (?)
  7. .code
  8. @atobinom@4 proc
  9. lea esi,bin
  10. mov eax,ecx
  11. mov ecx,16
  12. beg_2_:
  13. cmp eax,0
  14. je EXIT
  15.  
  16. cdq
  17. mov ebx,2
  18. idiv ebx
  19. cmp edx,0
  20. je EQL
  21. mov ebx,'1'
  22. mov [esi],ebx
  23. jmp SKIP2
  24. EQL:
  25. mov ebx,'0'
  26. mov [esi],ebx
  27. SKIP2:
  28. inc esi
  29. dec ecx
  30. jmp beg_2_
  31. EXIT:
  32.  
  33. beg_3_:
  34. mov ebx,'0'
  35. mov [esi],ebx
  36. inc esi
  37. loop beg_3_
  38.  
  39. lea esi,bin
  40. lea edi,revbin
  41.  
  42. add esi,15
  43. mov ecx,16
  44.  
  45. beg_4_:
  46. mov eax,[esi]
  47. mov [edi],eax
  48. dec esi
  49. inc edi
  50. loop beg_4_
  51.  
  52. mov eax,'b'
  53. mov [edi],eax
  54.  
  55. lea edi,revbin
  56. mov eax,edi
  57. ret
  58. @atobinom@4 endp
  59.  
  60. PUBLIC @atohex@4
  61. .model flat
  62. .data
  63. hex db 5 dup (?)
  64. .code
  65. @atohex@4 proc
  66. mov eax,ecx
  67. call @atobinom@4
  68. cld
  69.  
  70. mov edi,eax
  71. mov esi,0 ;sum
  72. mov ecx,4
  73. push 1
  74. push 2
  75. push 4
  76. push 8
  77.  
  78. beg_2:
  79. mov eax,[edi]
  80. call @chtoint@1
  81. pop ebx
  82. imul ebx
  83. add esi,eax
  84. inc edi
  85. loop beg_2
  86. ;
  87. cmp eax,0
  88. jne NEXT_3_0
  89. mov ebx,'0'
  90. jmp END_3
  91. NEXT_3_0:
  92. ;
  93. cmp eax,1
  94. jne NEXT_3_1
  95. mov ebx,'1'
  96. jmp END_3
  97. NEXT_3_1:
  98. ;
  99. END_3:
  100. mov [edi],ebx
  101. mov ebx,'8'
  102. mov [edi+1],ebx
  103. mov [edi+2],ebx
  104. mov [edi+3],ebx
  105. mov ebx,'h'
  106. mov [edi+4],ebx
  107. mov eax,edi
  108. ret
  109. @atohex@4 endp
  110.  
  111. PUBLIC @chtoint@1
  112. .model flat
  113. .code
  114. @chtoint@1 proc
  115. mov eax,ecx
  116. cmp eax,'1'
  117. je EQL_3
  118. mov eax,0
  119. jmp SKIP_3
  120. EQL_3:
  121. mov eax,1
  122. SKIP_3:
  123. ret
  124. @chtoint@1 endp
  125. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement