SHARE
TWEET

Untitled

a guest Oct 18th, 2019 117 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .global summ
  2.     .intel_syntax noprefix
  3.     .text
  4. summ:
  5.    
  6.     push ebx
  7.     mov ecx, N // counter
  8.  
  9. .Loop:
  10.    
  11.     mov ebx, ecx
  12.     dec ebx // N-1
  13.  
  14.     mov edx, A // &A
  15.     mov eax, [edx + 4*ebx]
  16.  
  17.     mov edx, B // &B
  18.     add eax. [edx + 4*ebx] // += B[N - 1]
  19.  
  20.     mov edx, R
  21.     mov [edx + 4*ebx], eax // R[n-1] = %eax
  22.  
  23.     loop .Loop
  24.  
  25.     pop ebx
  26.     ret
  27.  
  28.     .global everyday795
  29.  
  30. everyday795:
  31.    
  32.     push ebp // save ebp
  33.     mov ebp, esp
  34.     sub esp, 4 // int n; &n == [ebp-4]
  35.     push ebx
  36.  
  37.     mov ebx, ebp
  38.     sub ebx, 4 // ebx = &n
  39.  
  40.     push ebx
  41.     mob ebx, offset scanf_format // to get adress of the label
  42.     push ebx
  43.     call scanf
  44.     add esp, 8 // to clear
  45.  
  46.     mov ebx, [ebp - 4]  // ebp = n
  47.     imul ebx, [ebp + 8] // n *= x
  48.     add ebx, [ebp + 12] // n += y
  49.  
  50.     push ebx
  51.     mov ebx, offset printf_format
  52.     push ebx
  53.     call printf
  54.     add esp, 8
  55.  
  56.     pop ebx
  57.     mov esp, ebp
  58.    
  59.     pop ebp
  60.     ret
  61.  
  62. scanf_format:
  63.     .string "%d"
  64. printf_format:
  65.     .string "%d\n"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top