Guest User

Untitled

a guest
Apr 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. .386
  2. .model flat,stdcall
  3. option casemap:none
  4. include masm32includewindows.inc
  5. include masm32includeuser32.inc
  6. includelib masm32libuser32.lib
  7. include masm32includekernel32.inc
  8. includelib masm32libkernel32.lib
  9. include masm32includemasm32.inc
  10. includelib masm32libmasm32.lib
  11. .data
  12. textNum dd "c",0 ;variable i use to display every single digit (initialized with a casual character)
  13. num dd 25678 ;number to print
  14. divisor dd 10
  15. .code
  16. start:
  17. mov eax, num
  18. xor ecx,ecx ;ecx is the digits counter
  19. lea esi, textNum ;mov in esi the adress of textNum
  20. ciclo:
  21. cmp eax,0 ;when the dividend is 0 exit
  22. jbe print
  23.  
  24. xor edx,edx ;reset edx to take the remainder
  25. div divisor
  26. push edx ;push the remainder
  27.  
  28. add cl,1 ;increase digits counter
  29. jmp ciclo
  30.  
  31. print:
  32. cmp cl,0 ;since the counter is greater than 0
  33. jbe return
  34.  
  35. xor eax,eax
  36. pop eax ;pop in eax the digit i want to print
  37. add eax,48 ;add 48 (ascii value)
  38. mov [esi], eax ;move the digit inside the variable
  39.  
  40. invoke StdOut, addr textNum ;print the variable
  41.  
  42. sub cl, 1 ;dec counter
  43. jmp print
  44. return:
  45. invoke ExitProcess, 0
  46. end start
  47.  
  48. ;textNum dd "c",0 ;variable i use to display every single digit (initialized with a casual character)
  49. textNum dd 2 dup(0)
Add Comment
Please, Sign In to add comment