Created
March 1, 2014 12:35
-
-
Save siviae/9289171 to your computer and use it in GitHub Desktop.
Factorial in assembly
This file contains hidden or 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
| section .text | |
| global _fact | |
| _fact: | |
| mov ecx, [esp+4] | |
| mov eax,1 | |
| jmp for | |
| for: | |
| mul ecx | |
| dec ecx | |
| jnz for | |
| ret |
This file contains hidden or 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 <stdio.h> | |
| #include <conio.h> | |
| int __cdecl fact(int); | |
| int main(){ | |
| int num=10; | |
| printf("%d", fact(num)); | |
| _getch(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment