Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program kalkulator;
- #include("stdlib.hhf");
- static
- zm: int32;
- x: int32;
- licznik: int8;
- wybor: int8 :=1;
- begin kalkulator;
- while(wybor!=0) do
- stdout.newln();
- stdout.put("Menu", nl, "1.Dodawanie", nl, "2.Odejmowanie", nl, "3.Mnozenie", nl, "4.Dzielenie", nl, "5.Potegowanie", nl, "0.Wyjscie", nl);
- stdin.get(wybor);
- if(wybor=1) then
- stdout.put("Podaj 1 liczbe", nl);
- stdin.geti32();
- stdout.put("Podaj 2 liczbe", nl);
- stdin.get(zm);
- add(zm, eax);
- stdout.put("Wynik dodawania to ", nl);
- stdout.puti32(eax);
- mov(0,eax);
- stdout.newln();
- endif;
- if(wybor=2) then
- stdout.put("Podaj 1 liczbe", nl);
- stdin.geti32();
- stdout.put("Podaj 2 liczbe", nl);
- stdin.get(zm);
- sub(zm, eax);
- stdout.put("Wynik odejmowania to ", nl);
- stdout.puti32(eax);
- mov(0,eax);
- stdout.newln();
- endif;
- if(wybor=3) then
- stdout.put("Podaj 1 liczbe", nl);
- stdin.geti32();
- stdout.put("Podaj 2 liczbe", nl);
- stdin.get(zm);
- cdq();
- imul(zm,eax);
- stdout.put("Wynik mnozenia to ", nl);
- stdout.puti64(edx:eax);
- mov(0,edx:eax);
- stdout.newln();//51
- endif;
- if(wybor=4) then
- stdout.put("Podaj 1 liczbe", nl);
- stdin.geti32();
- stdout.put("Podaj 2 liczbe", nl);
- stdin.get(zm);
- while(zm=0) do
- stdout.put("Nie mozna dzielic przez 0! Podaj inna liczbe", nl);
- stdin.get(zm);
- endwhile;
- cdq();
- idiv(zm,edx:eax);
- stdout.put("Wynik dzielenia to ", nl);
- stdout.puti32(eax);
- stdout.put(" reszty ");
- stdout.puti32(edx);
- mov(0,edx:eax);
- stdout.newln();
- endif;
- if(wybor=5) then
- stdout.put("Podaj podstawe",nl);
- stdin.get(x);
- stdout.put("Podaj potege",nl);
- stdin.get(licznik);
- mov(x,eax);
- if(licznik=0) then//80
- stdout.put("Wynik jest rowny 1",nl);
- endif;
- if(licznik>0) then
- while(licznik>1) do
- imul(x,eax);
- sub(1,licznik);
- endwhile;
- stdout.put("Wynik potegowania to ", nl);
- stdout.puti32(eax);
- endif;
- if(licznik<0) then
- while(licznik<-1) do
- imul(x,eax);
- add(1,licznik);
- endwhile;
- stdout.put("Wynik potegowania to 1/");
- stdout.puti32(eax);
- endif;
- mov(0,eax);
- stdout.newln();
- endif;
- endwhile;//106
- end kalkulator;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement