Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. ;Calculatrice
  2. ;28/04/2017
  3. ;Verchain Hugo
  4.  
  5. bits 32
  6. extern printf, scanf, exit
  7.  
  8. segment .data
  9.  
  10. msg db "Selectionner une operation",00h
  11. msg2 db "1 - Addition ",0AH,"2 - Soustraction",0AH,"3 - Multiplication ",0AH,"4 - Division",00h
  12. msg4 db "Entrer un nombre : ",00h
  13. msg5 db "Ce nombre n'est pas dans le menu",00h
  14. msgresult db "Le resultat est : ",00h
  15. msgaddi db "----Addition---",00h
  16. msgsous db "---Soustraction---",00h
  17. msgmulti db "---Multiplication---",00h
  18. msgdivi db "---Division---",00h
  19. format db "%d",0
  20. nl db 0AH,00h
  21. nbaddi db 1
  22.  
  23. segment .bss
  24.  
  25. nbmenu resd 1
  26. nb1 resd 1
  27. nb2 resd 1
  28. result resd 1
  29.  
  30. segment .text
  31.  
  32. global main
  33.  
  34.  
  35. demander:
  36. push ebp
  37. mov ebp,esp
  38.  
  39. push msg
  40. call printf
  41. add esp,4
  42.  
  43. push nl
  44. call printf
  45. add esp,4
  46.  
  47. push msg2
  48. call printf
  49. add esp,4
  50.  
  51. push nl
  52. call printf
  53. add esp,4
  54.  
  55. push nbmenu
  56. push format
  57. call scanf
  58. add esp,8
  59.  
  60. mov al, [nbmenu]
  61. cmp al, [nbaddi]
  62. je addition
  63.  
  64. jmp inconnu
  65.  
  66. mov esp,ebp
  67. pop ebp
  68.  
  69.  
  70. addition:
  71. push ebp
  72. mov ebp,esp
  73.  
  74. push msgaddi
  75. call printf
  76. add esp,4
  77.  
  78. push nl
  79. call printf
  80. add esp,4
  81.  
  82. push msg4
  83. call printf
  84. add esp,4
  85.  
  86. push nb1
  87. push format
  88. call scanf
  89. add esp,8
  90.  
  91. push nl
  92. call printf
  93. add esp,4
  94.  
  95. push msg4
  96. call printf
  97. add esp,4
  98.  
  99. push nb2
  100. push format
  101. call scanf
  102. add esp,8
  103.  
  104. mov eax, [nb1]
  105. add eax, [nb2]
  106.  
  107. push msgresult
  108. call printf
  109. add esp,4
  110.  
  111.  
  112. jmp fin
  113. mov esp,ebp
  114. pop ebp
  115.  
  116.  
  117. Soustraction:
  118. push ebp
  119. mov ebp,esp
  120. push msgsous
  121. call printf
  122. add esp,4
  123. jmp fin
  124. mov esp,ebp
  125. pop ebp
  126.  
  127.  
  128. Division:
  129. push ebp
  130. mov ebp,esp
  131. push msgdivi
  132. call printf
  133. add esp,4
  134. jmp fin
  135. mov esp,ebp
  136. pop ebp
  137.  
  138.  
  139. Multiplication:
  140. push ebp
  141. mov ebp,esp
  142. push msgmulti
  143. call printf
  144. add esp,4
  145. jmp fin
  146. mov esp,ebp
  147. pop ebp
  148.  
  149.  
  150. inconnu:
  151. push ebp
  152. mov ebp,esp
  153. push msg5
  154. call printf
  155. add esp,4
  156. jmp fin
  157. ret
  158. mov esp,ebp
  159. pop ebp
  160.  
  161.  
  162. fin:
  163. push 0
  164. call exit
  165.  
  166. main:
  167. call demander
  168. push 0
  169. call exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement