'objective to add 2 vectors and save in 3 but the program in assembly so adds the first 4 digits
'assembly code'
PUBLIC add_float
add_float PROC
push ebp
mov ebp,esp
push eax
push ebx
push ecx
push edx
mov eax,[ebp+8]
mov ebx,[ebp+12]
mov ecx,[ebp+16]
mov edx,[ebp+20]
repeat:movdqu xmm0,[eax]
movdqu xmm1,[ebx]
addps xmm0,xmm1
movdqu [ecx],xmm0
add eax,16
add ebx,16
add ecx,16
sub edx, 4
jnz repeat
pop edx
pop ecx
pop ebx
pop eax
pop ebp
ret
add_float ENDP
END
the assembly code only add the first 4 digits
code c
extern "C" {
float add_float(float* a, float* b, float* c, int x);
}
}
int main(){
float vetor1[] = { 6,7,7,7,5,5,5,5 };
float vetor2[] = { 6.22,4,5,2,1,6,6,6 };
float vetor3[1024] = { };
int x = 8;
add_float(vetor1, vetor2, vetor3, x);
for (int i = 0; i < x; i++) {
printf("%f\n", vetor3[i]);
}
}
function assembly only sum the first 4 digit and the array have 8 i think its on the jump thats the problem my outuput is 12.219999 11.00 12.000 9.000 0.00 0.00 0.00 0.00 and that's my problem the program only add the first 4 numbers of array when i have 8 I use visual Studio
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
