Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. program kalkulator;
  2. #include("stdlib.hhf");
  3.  
  4. static
  5.  
  6. zm: int32;
  7. x: int32;
  8. licznik: int8;
  9. wybor: int8 :=1;
  10.  
  11. begin kalkulator;
  12. while(wybor!=0) do
  13. stdout.newln();
  14. stdout.put("Menu", nl, "1.Dodawanie", nl, "2.Odejmowanie", nl, "3.Mnozenie", nl, "4.Dzielenie", nl, "5.Potegowanie", nl, "0.Wyjscie", nl);
  15. stdin.get(wybor);
  16.  
  17. if(wybor=1) then
  18. stdout.put("Podaj 1 liczbe", nl);
  19. stdin.geti32();
  20. stdout.put("Podaj 2 liczbe", nl);
  21. stdin.get(zm);
  22. add(zm, eax);
  23. stdout.put("Wynik dodawania to ", nl);
  24. stdout.puti32(eax);
  25. mov(0,eax);
  26. stdout.newln();
  27. endif;
  28.  
  29. if(wybor=2) then
  30. stdout.put("Podaj 1 liczbe", nl);
  31. stdin.geti32();
  32. stdout.put("Podaj 2 liczbe", nl);
  33. stdin.get(zm);
  34. sub(zm, eax);
  35. stdout.put("Wynik odejmowania to ", nl);
  36. stdout.puti32(eax);
  37. mov(0,eax);
  38. stdout.newln();
  39. endif;
  40.  
  41. if(wybor=3) then
  42. stdout.put("Podaj 1 liczbe", nl);
  43. stdin.geti32();
  44. stdout.put("Podaj 2 liczbe", nl);
  45. stdin.get(zm);
  46. cdq();
  47. imul(zm,eax);
  48. stdout.put("Wynik mnozenia to ", nl);
  49. stdout.puti64(edx:eax);
  50. mov(0,edx:eax);
  51. stdout.newln();//51
  52. endif;
  53.  
  54. if(wybor=4) then
  55. stdout.put("Podaj 1 liczbe", nl);
  56. stdin.geti32();
  57. stdout.put("Podaj 2 liczbe", nl);
  58. stdin.get(zm);
  59. while(zm=0) do
  60. stdout.put("Nie mozna dzielic przez 0! Podaj inna liczbe", nl);
  61. stdin.get(zm);
  62. endwhile;
  63. cdq();
  64. idiv(zm,edx:eax);
  65. stdout.put("Wynik dzielenia to ", nl);
  66. stdout.puti32(eax);
  67. stdout.put(" reszty ");
  68. stdout.puti32(edx);
  69. mov(0,edx:eax);
  70. stdout.newln();
  71. endif;
  72.  
  73. if(wybor=5) then
  74. stdout.put("Podaj podstawe",nl);
  75. stdin.get(x);
  76. stdout.put("Podaj potege",nl);
  77. stdin.get(licznik);
  78. mov(x,eax);
  79.  
  80. if(licznik=0) then//80
  81. stdout.put("Wynik jest rowny 1",nl);
  82. endif;
  83.  
  84. if(licznik>0) then
  85. while(licznik>1) do
  86. imul(x,eax);
  87. sub(1,licznik);
  88. endwhile;
  89. stdout.put("Wynik potegowania to ", nl);
  90. stdout.puti32(eax);
  91.  
  92. endif;
  93.  
  94. if(licznik<0) then
  95. while(licznik<-1) do
  96. imul(x,eax);
  97. add(1,licznik);
  98. endwhile;
  99. stdout.put("Wynik potegowania to 1/");
  100. stdout.puti32(eax);
  101.  
  102. endif;
  103.  
  104. mov(0,eax);
  105. stdout.newln();
  106. endif;
  107.  
  108.  
  109.  
  110.  
  111. endwhile;//106
  112. end kalkulator;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement