Advertisement
Guest User

Untitled

a guest
Oct 11th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    .global summ
  2.     .global everyday795
  3.     .intel_syntax noprefix
  4.     .text
  5.  
  6. summ:
  7.     push ebx
  8.     mov ecx, N
  9.  
  10. .loop:
  11.     mov edx, ecx
  12.     sub edx, 1 // edx - current position
  13.    
  14.     mov ebx, A
  15.     mov eax, [ebx + 4 * edx]
  16.     mov ebx, B
  17.     add eax, [ebx + 4 * edx]
  18.     mov ebx, R
  19.     mov [ebx + 4 * edx], eax
  20.  
  21.     loop .loop
  22.  
  23.     pop ebx
  24.     ret
  25.  
  26. everyday795:
  27.     push ebp
  28.     mov ebp, esp
  29.    
  30.     // n
  31.     sub esp, 4
  32.     push esp
  33.  
  34.     // scanf
  35.     mov eax, offset scanf_fmt // offset возвращает адрес метки
  36.     push eax
  37.     call scanf
  38.     add esp, 8
  39.    
  40.     //calc
  41.     mov eax, [esp] // eax = n
  42.     imul eax, [esp + 12] // stack : <-- n, ebp, адрес возврата, x, y
  43.     add eax, [esp + 16]
  44.  
  45.     //printf
  46.     push eax
  47.     mov eax, offset printf_fmt
  48.     push eax
  49.     call printf
  50.     add esp, 8
  51.  
  52.     mov esp, ebp
  53.     pop ebp
  54.     ret    
  55.  
  56. printf_fmt:
  57.     .string "%d\n"
  58.  
  59. scanf_fmt:
  60.     .string "%d"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement