Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int v[1001];
- void fibonacci(int *, int)
- {
- _asm {
- mov eax, [ebp + 8];
- mov ebx, [ebp + 12];
- mov ecx, 0;
- cmp ebx, 1;
- je _one_element;
- cmp ebx, 2;
- je _two_elements;
- mov[eax], 0;
- mov[eax + 4], 1;
- mov ecx, 2;
- _loop:
- cmp ecx, ebx;
- jg _final;
- mov edx, [eax + 4 * ecx - 4];
- mov esi, [eax + 4 * ecx - 8];
- add edx, esi;
- mov[eax + 4 * ecx], edx;
- inc ecx;
- jmp _loop;
- _one_element:
- mov[eax], 0;
- jmp _final;
- _two_elements:
- mov[eax], 0;
- mov[eax + 4], 1;
- jmp _final;
- _final:
- }
- }
- int main()
- {
- int n;
- cin >> n;
- _asm {
- mov eax, n;
- push eax;
- lea eax, v;
- push eax;
- call fibonacci;
- add esp, 8;
- }
- int i;
- for (i = 0; i < n; i++)
- cout << v[i] << ' ';
- cout << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement