Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. char acFormatSaisie[] = "%f";
  4. char acFormatSaisie1[] = "%d";
  5. char acTxtSaisie[] = "\tEntrer le 1er nombre : ";
  6. char acTxtSaisie1[] = "\tEntrer le 2e nombre : ";
  7. char acTxtChoix[] = "\n\tQue voulez vous faire? \n\t1.Addition: \n\t2.Soustraction: \n\t3.Multiplication: \n\t4.Division: \n\t>";
  8. char acFormatAffichage[] = "\tVotre resultat vaut: %0.2f \n\tLe resultat arrondis est de: %d";
  9. float iVar, iVar1;
  10. int choix, resultatArrondis;
  11. double resultat;
  12.  
  13. void main()
  14. {
  15. _asm
  16. {
  17. //Saisie du premier nombre
  18. push offset acTxtSaisie
  19. call dword ptr printf
  20. add esp, 4
  21. push offset iVar
  22. push offset acFormatSaisie
  23. call dword ptr scanf
  24. add esp, 8
  25. //Saisie du second nombre
  26. push offset acTxtSaisie1
  27. call dword ptr printf
  28. add esp, 4
  29. push offset iVar1
  30. push offset acFormatSaisie
  31. call dword ptr scanf
  32. add esp, 8
  33. //Affichage et saisie du choix
  34. push offset acTxtChoix
  35. call dword ptr printf
  36. add esp, 4
  37. push offset choix
  38. push offset acFormatSaisie1
  39. call dword ptr scanf
  40. add esp, 8
  41.  
  42. movss xmm0, iVar
  43. movss xmm1, iVar1
  44. mov eax, choix
  45. //Switch
  46. cmp eax, 1
  47. je addition
  48. cmp eax, 2
  49. je soustraction
  50. cmp eax, 3
  51. je multiplication
  52. cmp eax, 4
  53. je division
  54. //Addition
  55. addition:
  56. addss xmm0, xmm1
  57. cvtss2sd xmm0, xmm0
  58. movsd resultat, xmm0
  59. cvtsd2si eax, xmm0
  60. mov resultatArrondis, eax
  61. push resultatArrondis
  62. push resultat+4
  63. push resultat
  64. jmp afficher
  65.  
  66. //Soustraction
  67. soustraction:
  68. subss xmm0, xmm1
  69. cvtss2sd xmm0, xmm0
  70. movsd resultat, xmm0
  71. cvtsd2si eax, xmm0
  72. mov resultatArrondis, eax
  73. push resultatArrondis
  74. push resultat+4
  75. push resultat
  76. jmp afficher
  77.  
  78. //multiplication
  79. multiplication:
  80. mulss xmm0, xmm1
  81. cvtss2sd xmm0, xmm0
  82. movsd resultat, xmm0
  83. cvtsd2si eax, xmm0
  84. mov resultatArrondis, eax
  85. push resultatArrondis
  86. push resultat+4
  87. push resultat
  88. jmp afficher
  89.  
  90. //division
  91. division:
  92. divss xmm0, xmm1
  93. cvtss2sd xmm0, xmm0
  94. movsd resultat, xmm0
  95. cvtsd2si eax, xmm0
  96. mov resultatArrondis, eax
  97. push resultatArrondis
  98. push resultat+4
  99. push resultat
  100. jmp afficher
  101.  
  102. //Affichage
  103. afficher:
  104. push offset acFormatAffichage
  105. call dword ptr printf
  106. add esp, 16
  107. }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement