Advertisement
berinkaq

Untitled

Apr 11th, 2021
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2.  
  3. section .bss
  4.     k resd 1
  5.     a resd 1
  6.  
  7. section .text
  8. f:
  9.     push ebp
  10.     mov ebp, esp
  11.     push ebx
  12.     push ecx
  13.     push edx
  14.     push esi
  15.     mov eax, [ebp + 8]
  16.     mov ecx, [ebp + 12]
  17.     xor ebx, ebx
  18.    
  19.     .l:
  20.         cdq
  21.         idiv ecx
  22.         xchg eax, ebx
  23.         mov esi, edx
  24.         imul ecx
  25.         add eax, esi
  26.         xchg eax, ebx
  27.         test eax, eax
  28.         jnz .l
  29.     mov eax, ebx
  30.     pop esi
  31.     pop edx
  32.     pop ecx
  33.     pop ebx
  34.     leave
  35.     ret
  36.  
  37. global CMAIN
  38. CMAIN:
  39.     mov ebp, esp; for correct debugging
  40.     GET_DEC 4, k
  41.     GET_DEC 4, ecx
  42.     GET_DEC 4, eax
  43.     mov ebx, 2011
  44.     cdq
  45.     idiv ebx
  46.     mov eax, edx
  47.     .loop:
  48.         imul eax
  49.         push dword[k]
  50.         push eax
  51.         call f
  52.         idiv ebx
  53.         mov eax, edx
  54.         dec ecx
  55.         jnz .loop
  56.     PRINT_DEC 4, eax
  57.     xor eax, eax
  58.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement