Advertisement
Guest User

Ex 2 Laborator 11 abaetu

a guest
Jan 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include "pch.h"
  2. #include <stdio.h>
  3.  
  4. //Calculati suma elementelor pare dintr-un vector.
  5. int suma_pare_vector (int *, int )
  6. {
  7.  _asm
  8.  {
  9.     mov ecx, [ebp + 8]
  10.     mov ebx, [ebp + 12]
  11.     mov edx, 0
  12.     mov eax, 0
  13.     while1:
  14.     cmp edx, ebx
  15.     jge stopwhile1
  16.     mov esi, [ecx + 4 * edx]
  17.     test esi, 1
  18.     jnz done
  19.     add eax, esi
  20.     done:
  21.     inc edx
  22.     jmp while1
  23.     stopwhile1:
  24.  }
  25. }
  26.  
  27. void main()
  28. {
  29.  int v[5]={5,1,2,3,6};
  30.  int *p=v;
  31.  int s;
  32.  
  33.  _asm{
  34.    push 5
  35.    push p
  36.    call suma_pare_vector
  37.    mov s, eax
  38.    add esp, 8
  39.  }
  40.  
  41.  printf("Suma: %d", s);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement