working on a 32bit architecture and i'm adding two arrays together slot by slot into a third array so if I have 3,4,4 and 4,4,4 in the arrays the third array should contain 7,8,8 at the end of the function
I was able to pass in the arrays correctly and the amount of items into the function arleady, i know this because I ran test code
now i'm working on the addition part of it, here is what I have, the logic makes sense to me but it's still seg faulting...ideas?
;*************************************ADD ARRAY**********************************************
segment .bss
;
segment .data
summessage db "The Sum is: ", 0
segment .text
extern readdouble,print_string, read_int, writedouble, print_nl, print_int
global addarray
addarray:
pusha
mov edi, 0 ;initialize counter to 0
mov ecx, 0 ;zero out ecx and edx
mov edx, 0
mov ebx, [esp+48] ;moves starting location of array1 into ebx
mov edi, [ebp+40] ;move quantity into edi
mov ebp, [esp+60] ;move the starting location of array2 into ebp
mov esi, [esi] ;move starting locatino of array3 into esi
;mov ecx, [ebp]
;mov edx, [ebp+4]
;call writedouble
;call print_nl
add_loop:
fld qword [ebx] ;The second input is now in a floating point register, specifically st0.
fld qword [ebp]
fadd ;The first input is added to the second input and the sum
;replaces the second input in st0
fstp qword [ecx] ;copy top of stack onto ecx
mov ecx,[ecx]
mov edx,[edx+4]
mov [esi], ecx
mov [esi+4], ecx
add esi, 8 ;increment to the next loaction of esi
add ebx,8 ;increment location of ebx to the next floating point value of array1
;add ebp,8 ;increment location of ebp to the next floating point value of array2
dec edi ;increment counter
cmp edi, 0 ;compare to see if all values have been added
jz add_done
jmp add_loop
add_done:
popa
ret