Last active
March 30, 2017 21:53
-
-
Save stryku/b7b39bb6a11c9d4c727d9f3aaef897d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "string.hpp" | |
#include "execute.hpp" | |
using code = decltype( | |
"mov ebp , esp " | |
"push eax " // declare four variables | |
"push eax " | |
"push eax " | |
"push eax " | |
"mov DWORD PTR [ ebp + 8 ] , 0 " | |
"mov DWORD PTR [ ebp + 12 ] , 1 " | |
"mov DWORD PTR [ ebp + 16 ] , 1 " | |
"mov DWORD PTR [ ebp + 4 ] , 1 " | |
":loop_label " | |
"mov eax , DWORD PTR [ ebp + 4 ] " | |
"mov ebx , 15 " //we want to get 15th fibonacci element | |
"cmp eax , ebx " | |
"jge .end_label " | |
"mov edx , DWORD PTR [ ebp + 8 ] " | |
"mov eax , DWORD PTR [ ebp + 12 ] " | |
"add eax , edx " | |
"mov DWORD PTR [ ebp + 16 ] , eax " | |
"mov eax , DWORD PTR [ ebp + 12 ] " | |
"mov DWORD PTR [ ebp + 8 ] , eax " | |
"mov eax , DWORD PTR [ ebp + 16 ] " | |
"mov DWORD PTR [ ebp + 12 ] , eax " | |
"mov eax , DWORD PTR [ ebp + 4 ] " | |
"mov ebx , 1 " | |
"add eax , ebx " | |
"mov DWORD PTR [ ebp + 4 ] , eax " | |
"jmp .loop_label " | |
":end_label " | |
"mov eax , DWORD PTR [ ebp + 16 ] " | |
"exit"_s); | |
int main() | |
{ | |
return cai::execute_code<code>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment