Professional Documents
Culture Documents
Acsoexam Templates
Acsoexam Templates
mov edx, 0;
mov edi, 0;
mov esi, 0;
_loop:
cmp ecx, eax;
je _final;
mov edx, 0;
push eax;
push ecx;
mov eax, [ebx + ecx * 4];
mov ecx, 2;
div ecx;
pop ecx;
pop eax;
cmp edx, 0;
je _sumpar;
jne _sumimpar;
_sumpar:
add edi, [ebx + ecx * 4];
inc ecx;
jmp _loop;
_sumimpar:
add esi, [ebx + ecx * 4];
inc ecx;
jmp _loop;
_final:
mov eax, esi;
}
}
void vectorparimpar()
{
int v[] = { 15, 22, 28, 33, 11 };
int dimensiune = 5;
_asm
{
mov eax, dimensiune;
push eax;
lea eax, v;
push eax;
call vectorparimpar_rez;
mov dimensiune, eax;
add esp, 8;
}
cout << dimensiune<<'\n';
}
*/
/*
void numarvocale_implementare(char *,char *)
{
_asm
{
mov ebx, [ebp + 8];
mov edi, [ebp + 16];
push 0; //count
push 0; //j
push 0; //i
_loop1:
mov ecx, [esp];
inc [esp];
mov[esp + 4], 0;
movzx eax, byte ptr[ebx+ecx];
cmp eax, NULL;
je _final;
jne _loop2;
_loop2:
mov ecx, [esp+4];
movzx esi, byte ptr[edi + ecx];
inc[esp + 4];
cmp eax, esi;
je _add;
_add:
inc [esp+8];
jmp _loop2;
_final:
mov eax, [esp + 8];
add esp, 12;
}
}
void numarvocale()
{
char sir[] = "Numarul de vocale";
char vocale[] = "aeiouAEIOU";
int l=16;
_asm {
lea eax, vocale;
push eax;
lea eax, sir;
push eax;
call numarvocale_implementare;
add esp, 8;
mov l, eax;
}
/*
void sumamatrice_implementare(int *, int *, int)
{
_asm {
mov ebx, [ebp + 8]; //iau prima matrice
mov ecx, [ebp + 12]; //iau a doua matrice
mov esi, [ebp + 16]; //iau nr lin si col
push 4; //sizeof(int)
push 0; //initializez contor 2 cu 0 j
push 0; //initializez contor 1 cu 0 i
//atentie, stiva!
_for1:
cmp[esp], esi; //comparam i cu nrmax
jge _outside_for_1; //stop
mov[esp + 4], 0; //fac j-ul 0
_for2:
cmp[esp + 4], esi; //comparam j cu nrmax
jge _outside_for_2;
_outside_for_2:
inc[esp]; //incrementez i
jmp _for1;
_outside_for_1:
add esp, 12; //am avut 3 variabile locale
}
}
void sumamatrice()
{
int n = 3;
int A[3][3] = { { 1,0,1 },{ 0,1,0 },{ 1,0,1 } };
int B[3][3] = { { 2,1,2 },{ 1,2,1 },{ 2,1,2 } };
_asm
{
mov eax, n;
push eax;
lea eax, B;
push eax;
lea eax, A;
push eax;
call sumamatrice_implementare;
add esp, 12;
}