I'm having difficulties in one of my first program in the assembler x86 I'm trying to avg an array like that:
code:
for(i = 0 ; i <20; i++)cin >> A[i];
_asm
{
lea edx, A[0]
mov ecx, 20
mov esi, 0
mov eax, 0
L2:
add eax, [edx + esi]
add esi, 4
loop L2
mov eax, eax// dividend
mov ebx, 20
div ebx
mov i, eax
printf("mean is: ");
cout << i;
and this div ebx showing me an overflow. what am i doing wrong? what is the correct way to da that?