Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. global _start
  2. extern ExitProcess
  3.  
  4. section .data
  5. section .text
  6.  
  7. factorial:  push ebp
  8.             mov ebp,esp
  9.            
  10.   my_loop:  mov ebx,eax
  11.             dec ebx
  12.             mul ebx
  13.             cmp ebx,1
  14.             jne my_loop
  15.            
  16.             mov  esp,ebp     ; stack-frame leave (obnoveni ESP)
  17.             pop  ebp         ; stack-frame leave (obnoveni EBP)
  18. ret
  19.  
  20. _subfact:   push ebp
  21.             mov ebp,esp
  22.  
  23.             mov eax,[ebp+8]
  24.             call factorial
  25.             mov ebx,eax
  26.             mov eax,[ebp+12]
  27.             call factorial
  28.             sub eax,ebx
  29.                        
  30.             mov  esp,ebp     ; stack-frame leave (obnoveni ESP)
  31.             pop  ebp         ; stack-frame leave (obnoveni EBP)
  32.             push eax
  33.             push ebx
  34. ret        
  35.            
  36. _start:
  37.             push dword 5
  38.             push dword 7
  39.             call _subfact
  40.            
  41. end:       
  42.                        
  43.         ;
  44.         ; VOID WINAPI ExitProcess( _In_  UINT uExitCode ) ;
  45.         ;
  46.         push    dword 0         ; Arg1: push exit code
  47.         call    ExitProcess
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement