Advertisement
MaksNew

Untitled

Mar 1st, 2021
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. format PE console
  2. entry start
  3.  
  4. include 'win32a.inc'
  5.  
  6. section '.data' data readable writable
  7. formatNum db '%d', 0
  8. a dd ?
  9. b dd ?
  10. c dd ?
  11. d dd ?
  12. buf dd ?
  13. what db "This program calculate ((a-8)*b+c)/d+4 ",0
  14. strEnterA db 13,10,'Enter A: ',0
  15. strEnterB db 13,10,'Enter B: ',0
  16. strEnterC db 13,10,'Enter C: ',0
  17. strEnterD db 13,10,'Enter D: ',0
  18. result db 'Result: %d', 0
  19. NULL = 0
  20. section '.code' code readable executable
  21.  
  22. start:
  23. push what
  24. call [printf]
  25.  
  26. push strEnterA;;1
  27. call [printf]
  28.  
  29. push a
  30. push formatNum
  31. call [scanf] ;
  32.  
  33.  
  34. sub [a], 8
  35.  
  36. push strEnterB;;2
  37. call [printf]
  38.  
  39. push b
  40. push formatNum
  41. call [scanf] ;
  42.  
  43. mov eax, [a]
  44. mul [b]
  45. mov [buf], eax
  46.  
  47. push strEnterC
  48. call [printf]
  49.  
  50. push c
  51. push formatNum
  52. call [scanf] ;
  53.  
  54. mov eax, [buf]
  55. add eax, [c]
  56. mov [buf], eax
  57.  
  58. push strEnterD;;
  59. call [printf]
  60.  
  61. push d
  62. push formatNum
  63. call [scanf] ;
  64.  
  65. add [d], 4
  66.  
  67. mov eax, [buf]
  68. mov ecx, [d]
  69. mov edx, 0
  70. div ecx
  71.  
  72. push eax
  73. push result
  74. call[printf]; итоговый ответ
  75.  
  76. call[getch]
  77.  
  78.  
  79. push NULL
  80. call[ExitProcess]
  81.  
  82. section '.idata' import data readable
  83.  
  84. library kernel, 'kernel32.dll', \
  85. msvcrt, 'msvcrt.dll'
  86.  
  87. import kernel, \
  88. ExitProcess, 'ExitProcess'
  89. import msvcrt,\
  90. printf, 'printf',\
  91. getch, '_getch',\
  92. scanf, 'scanf'
  93.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement