I have this short piece of code, its purpose is to sum negative values and count positive ones, the vector is initialized else where
;sum all negative values and count positive values
;let eax hold sum and ebx hold number of positives
CALL crlf
mov ecx, VectorSize
mov eax, 0
mov ebx, 0
mov edx, 0
sumMe:
cmp Vector[edx * TYPE Vector], 0
jge pos
;neg
add eax, Vector[edx * TYPE Vector]
INC edx
loop sumMe
pos:
INC ebx
INC edx
loop sumMe
The piece of code works correctly except when a negative value is the last value in the array, even something like -1 -1 -1 -1 5
works. However if I have a negative value in the last location the program crashes.
Any help would be appreciated