Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. ; constants
  2. cr equ 13 ;carriage return
  3. lf equ 10 ;linefeed
  4.  
  5. section .bss
  6. num resb 1
  7. tall resb 1
  8.  
  9. section .data
  10. en db "1"
  11. crlf db cr,lf
  12. crlflen equ $ - crlf
  13.  
  14. section .text
  15. global _start
  16. _start:
  17. mov ecx, 12
  18. mov eax, '1'
  19. l1:
  20. mov [num], eax ;num = value of eax
  21. mov eax, 4 ;sys_write
  22. mov ebx, 1 ;stndout
  23. push ecx ;push 12 to stack
  24. mov ecx, num ;save num in ecx (msg to write)
  25. mov edx, 1 ;length
  26. int 0x80 ;execute all previous
  27. call newline
  28.  
  29. mov eax, [num] ;eax = value of num
  30. sub eax, '0' ;convert to number
  31. inc eax ;increase eax with +1
  32. cmp eax, 10
  33. jge tosiffer
  34. add eax, '0' ;convert to ascii
  35. pop ecx ;pop 12 from stack
  36. loop l1
  37.  
  38. tosiffer:
  39. call skriven
  40. mov eax,'0'
  41.  
  42. tiltolv:
  43. mov [tall], eax
  44. mov ecx, tall
  45. mov edx,1
  46. mov ebx,1
  47. mov eax,4
  48. int 0x80
  49. call newline
  50. call skriven
  51. mov eax, [tall]
  52. sub eax,'0'
  53. inc eax
  54. cmp eax, 3
  55. jge done
  56. add eax,'0'
  57. loop tiltolv
  58.  
  59. skriven:
  60. mov edx,1
  61. mov ecx,en
  62. mov ebx,1
  63. mov eax,4
  64. int 0x80
  65. ret
  66.  
  67. newline:
  68. mov edx,crlflen
  69. mov ecx,crlf
  70. mov ebx,1
  71. mov eax,4
  72. int 0x80
  73. ret
  74.  
  75. done:
  76. mov eax,1 ;sys_exit
  77. int 0x80 ;execute all previous
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement