Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. format PE console
  2. entry main
  3.  
  4. include 'macro/import32.inc'
  5. include 'macro/proc32.inc'
  6.  
  7. section '.data' data readable writeable
  8. msg1 db 'Tauras Steponavicius IIF-15',0
  9. msg2 db 'kuri uzdavini norite sprest? (1/2, 3-iseiti)',0
  10. msg4 db 'Iveskite pradines valandas: ',0
  11. msg5 db 'Iveskite pradines minutes: ',0
  12. msg6 db 'Iveskite pradines sekundes: ',0
  13. msg7 db 'Iveskite galines valandas: ',0
  14. msg8 db 'Iveskite galines minutes: ',0
  15. msg9 db 'Iveskite galines sekundes: ',0
  16. msg10 db ' Val ',0
  17. msg11 db ' Min ',0
  18. msg12 db ' Sek ',0
  19. msg3 db 0xa,0
  20. formatas dd '%d',0
  21. msg db '%d ',0
  22. choice dd ?
  23. val1 dd ?
  24. min1 dd ?
  25. sek1 dd ?
  26. val2 dd ?
  27. min2 dd ?
  28. sek2 dd ?
  29. val dd ?
  30. min dd ?
  31. sek dd ?
  32. multi dd ?
  33. space db ',',0
  34.  
  35. p db "pause>nul",0
  36.  
  37. section '.code' code readable executable
  38.  
  39. func1:
  40. push ebp
  41. mov ebp, esp
  42.  
  43. mov [val], 0
  44. mov [min], 0
  45. mov [sek], 0
  46.  
  47. push msg4
  48. call [printf]
  49. push val1
  50. push formatas
  51. call [scanf]
  52. push msg5
  53. call [printf]
  54. push min1
  55. push formatas
  56. call [scanf]
  57. push msg6
  58. call [printf]
  59. push sek1
  60. push formatas
  61. call [scanf]
  62.  
  63. mov eax, [val1]
  64. imul eax, 3600
  65. mov ebx, [min1]
  66. imul ebx, 60
  67. mov ecx, [sek1]
  68. add ecx, eax
  69. add ecx, ebx
  70. mov [sek], ecx
  71.  
  72. push msg7
  73. call [printf]
  74. push val2
  75. push formatas
  76. call [scanf]
  77. push msg8
  78. call [printf]
  79. push min2
  80. push formatas
  81. call [scanf]
  82. push msg9
  83. call [printf]
  84. push sek2
  85. push formatas
  86. call [scanf]
  87.  
  88. mov eax, [val2]
  89. imul eax, 3600
  90. mov ebx, [min2]
  91. imul ebx, 60
  92. mov ecx, [sek2]
  93. add ecx, eax
  94. add ecx, ebx
  95. sub [sek], ecx
  96.  
  97. mov eax, [sek]
  98. mov ebx, [min]
  99. mov ecx, [val]
  100.  
  101. @minloop:
  102.         cmp eax, 60
  103.         jl @valloop
  104.         sub eax, 60
  105.         mov ebx, [min]
  106.         add ebx, 1
  107.         mov [min], ebx
  108.         jmp @minloop
  109.  
  110. @valloop:
  111.         cmp ebx, 60
  112.         jl @output
  113.         sub ebx, 60
  114.         mov ecx, [val]
  115.         add ecx, 1
  116.         mov [val], ecx
  117.         jmp @valloop
  118.  
  119. @output:
  120.         mov [sek], eax
  121.         mov [min], ebx
  122.         mov [val], ecx
  123.         push [val]
  124.         push formatas
  125.         call [printf]
  126.         push msg10
  127.         call [printf]
  128.         push [min]
  129.         push formatas
  130.         call [printf]
  131.         push msg11
  132.         call [printf]
  133.         push [sek]
  134.         push formatas
  135.         call [printf]
  136.         push msg12
  137.         call [printf]
  138.  
  139.  
  140. mov esp, ebp
  141. pop ebp
  142. ret
  143.  
  144. func:
  145. push ebp
  146. mov ebp, esp
  147.  
  148. push msg1
  149. call [printf]
  150. push msg3
  151. call [printf]
  152.  
  153. mov esp, ebp
  154. pop ebp
  155. ret
  156.  
  157. func2:
  158. push ebp
  159. mov ebp, esp
  160.  
  161. mov eax, -10
  162. @looper:
  163.         cmp eax, 12
  164.         je @endlooper
  165.         mov ebx, eax
  166.         mov [multi], eax
  167.         imul eax, [multi]
  168.         imul eax, [multi]
  169.         imul eax, [multi]
  170.         imul eax, [multi]
  171.         imul eax, 5
  172.         add eax, [multi]
  173.         mov [multi], eax
  174.         push [multi]
  175.         push formatas
  176.         call [printf]
  177.         push msg3
  178.         call [printf]
  179.         add ebx, 2
  180.         mov eax, ebx
  181.         jmp @looper
  182. @endlooper:
  183.  
  184. mov esp, ebp
  185. pop ebp
  186. ret
  187.  
  188. funcmenu:
  189. push ebp
  190. mov ebp, esp
  191.  
  192. @start:
  193.         push msg2
  194.         call [printf]
  195.         push choice
  196.         push formatas
  197.         call [scanf]
  198.         mov eax, [choice]
  199.         cmp eax, 1
  200.         je @func1
  201.         cmp eax, 2
  202.         je @func2
  203.         cmp eax, 3
  204.         je @pab
  205.         jmp @start
  206. @func1:
  207. call func1
  208. jmp @start
  209. @func2:
  210. call func2
  211. jmp @start
  212. call func2
  213. @pab:
  214. mov esp, ebp
  215. pop ebp
  216. ret
  217.  
  218. main:
  219. call func
  220. call funcmenu
  221.  
  222. invoke system, p ;Calling function with invoke command
  223. invoke exit, 0
  224.  
  225. section '.idata' import data readable
  226. library msvcrt,'msvcrt.dll'
  227. import msvcrt,\
  228. printf,'printf',\
  229. scanf, 'scanf',\
  230. system,'system',\
  231. exit,'exit'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement