Guest User

Untitled

a guest
Oct 18th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. %include "asm_io.inc"
  2.  
  3. segment .bss
  4. string resb 32
  5.  
  6.  
  7. segment .text
  8. global main
  9.  
  10. main:
  11.  
  12. enter 0,0 ; setup stack frame
  13. pusha
  14.  
  15. mov edx, 0
  16. mov ecx, 0
  17. mov ebx, 0
  18.  
  19. repeat: call read_char
  20.  
  21. sub eax, 48
  22. mov esi, eax
  23. mov eax, ecx
  24. mov ebx, 10
  25. mul ebx
  26. mov ecx, eax
  27. add ecx, esi
  28. mov byte [string+edx], al
  29.  
  30. cmp al, 0x0a
  31. jne repeat
  32. mov byte [string+edx-1], 0
  33.  
  34. mov eax, ecx
  35. call print_int
  36. call print_nl
  37.  
  38. popa
  39. mov eax, 0 ; return value
  40. leave ; leave stack frame
  41. ret
  42.  
  43. repeat:
  44. call read_char
  45. cmp al, 0x0a
  46. je exit_loop // exit the loop if enter
  47. //code as before
  48. jmp repeat //jump unconditionally to the beginning of the loop
  49. exit_loop:
  50. mov byte [string+edx-1], 0
Add Comment
Please, Sign In to add comment