I wrote this code to get a standard deviation from inputs that are stored in an array.
I outputted all of my inputs and they are correct, and it's subtracting the mean correctly, hoever when i hit the check flag(if counter is equal to zero) i get a floating point error
any ideas?
it is looping correctly..... up until the counter hits zero
compute_variance:
pusha
mov ebx, [esp+36] ;starting location of array
mov esi, [esp+44] ;move the count value into esi
mov ebp, [esp+52] ;move mean value into edx
mov ecx, 0 ;set ecx to accumulator to 0
variance_loop:
mov edx, 0 ;set edx to 0
mov eax, [ebx] ;move value of array into eax
sub eax, ebp ;minus value by mean
mul eax ;multiply by itself to square the value
add ecx, eax ;add eax value into accumulator
add ebx, 4 ;increment memory location in array
dec esi ;decrement counter
cmp esi, 0 ;if 0 then exit loop
jz variance_done
jmp variance_loop
variance_done:
xor esi, edx ;zero out registers esi and edx
mov esi, [esp+44] ;move count value back onto esi
;mov edx, 0 ;initializing edx to zero
mov eax, ecx ;move accumulator into eax
idiv esi ;divide accumulator by the count value
mov [esp+56],eax ;move the accumulator back onto the stack
popa
ret