Hey guys so I am having trouble with this problem for class. So the problem is to add the sum of an array with in a range. The issue I am having is that I can't get the second conditional statement to work, jumping to L4. I am sure there are other issues with the coding so I am completely open to know those issues as well. Thanks in advance guys.
; Program template
Include Irvine32.inc
.data
list DWORD 10, 20, 30, 40
ptrA SDWORD list
varj DWORD 25
vark DWORD 100
.code
main proc
mov esi, ptrA
mov ecx, LENGTHOF list
call ArraySum
call WriteDec
invoke ExitProcess,0
main endp
ArraySum Proc
push esi
push ecx
mov eax, 0
mov ebx, varj
mov edx, vark
top:
cmp [esi], ebx ; if esi > ebx
jg L2 ; jump to L2
jl L4 ; else jump to L4
L2:
cmp [esi], edx ;if esi < edx
jl L3 ; jump to L3
jg L4 ; else jump to L4
L3:
add eax, [esi] ;add the value in array into eax
add esi, TYPE DWORD ; move to next array index
loop top ; loop to top
L4:
add esi, TYPE DWORD ; move ot next array index
loop top ; loop to top
pop ecx
pop esi
ret
ArraySum endp
end main