Skip to content

Instantly share code, notes, and snippets.

@siviae
Created March 1, 2014 12:35
Show Gist options
  • Select an option

  • Save siviae/9289171 to your computer and use it in GitHub Desktop.

Select an option

Save siviae/9289171 to your computer and use it in GitHub Desktop.
Factorial in assembly
section .text
global _fact
_fact:
mov ecx, [esp+4]
mov eax,1
jmp for
for:
mul ecx
dec ecx
jnz for
ret
#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