Guest User

Untitled

a guest
Nov 10th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. .intel_syntax noprefix
  2. .text
  3. .globl main
  4.  
  5. main:
  6. mov ecx, 3
  7. mov eax, 1
  8. xor edx, edx
  9. xor ebx, ebx
  10. push eax
  11. call function
  12. add esp, 4
  13. push edx
  14. push offset msg
  15. call printf
  16. add esp, 8
  17. mov eax, 0
  18. ret
  19.  
  20. function:
  21. mov edx,0
  22. push ebp
  23. mov ebp, esp
  24. push eax
  25. push ecx
  26. push ebx
  27. mov eax,[ebp+8]
  28. cmp ecx,0
  29. jne f1
  30. mov edx,eax
  31. add edx,1
  32. jmp final
  33.  
  34. f1:
  35. cmp ecx,1
  36. jne f2
  37. mov edx, eax
  38. jmp final
  39.  
  40. f2:
  41. cmp ecx, 2
  42. jne fnext
  43. mov edx, eax
  44. add edx,2
  45. jmp final
  46.  
  47. fnext:
  48. push ecx
  49. sub ecx,1
  50. push edx
  51. push eax
  52. call function
  53. add esp, 4
  54. pop ebx
  55. add edx,edx
  56. pop ecx
  57. push ecx
  58. sub ecx, 2
  59. push edx
  60. push eax
  61. add eax,1
  62. call function
  63. add esp, 4
  64. pop ebx
  65. sub edx,ebx
  66. sub edx,ebx
  67. pop ecx
  68. push ecx
  69. sub ecx,3
  70. push ecx
  71. push eax
  72. call function
  73. add esp, 4
  74. pop ebx
  75. sub ebx,edx
  76. mov edx,ebx
  77. pop ecx
  78.  
  79. final:
  80. pop ebx
  81. pop ecx
  82. pop eax
  83. pop ebp
  84. ret
  85.  
  86.  
  87. .data
  88. msg:
  89. .asciz "Wynik = %d\n"
  90. .byte 0
Advertisement
Add Comment
Please, Sign In to add comment