Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- extern double ciag(unsigned int x);
- int main() {
- int x = 5;
- double wynik = ciag(x);
- printf("%lf", wynik);
- getchar();
- return 0;
- }
- ////////////////////////////////////////////////
- .686
- .model flat
- public _ciag
- .code
- _ciag PROC
- push ebp
- mov ebp,esp
- FINIT
- sprawdz_czy_jeden:
- mov eax, [ebp+8]
- cmp eax, 1
- jne sprawdz_czy_dwa
- mov eax, 5
- push eax
- FILD dword PTR[esp]
- add esp, 4
- jmp koniec
- sprawdz_czy_dwa:
- cmp eax, 2
- jne rekurencja
- mov eax, 6
- push eax
- FILD dword PTR [esp]
- add esp, 4
- jmp koniec
- rekurencja:
- dec eax ; x-1 (oryginal pozostaje w ebp+8 )
- push eax
- call _ciag ; wynik w st0
- add esp, 4
- push 3
- FILD dword PTR [esp] ; push 3
- add esp,4
- fsub st(0), st(1) ; 3 - ciag(x)
- fxch st(1) ; zamiana st0 z st1 zeby mozna bylo pop
- sub esp, 4
- fstp dword PTR [esp] ; pop ciag(x)
- add esp, 4
- fild dword PTR [ebp+8] ; push x
- fdivp st(1), st(0) ; (3 - ciag(x)) / x
- koniec:
- pop ebp
- RET
- _ciag ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement