I am practicing conditional jumps based on flags, Below is the program to get 1st -ve number.
While Debugging I am getting below error
When code is trying to return from found
subroutine then its showing the above info
; chapter -06
; find first negative number
.386
.model flat,stdcall
.stack 4096
.data
slist SWORD 0,1,2,3,-9,10,20
ExitProcess PROTO,dwExitCode:DWORD
.code
main PROC
mov ecx,LENGTHOF slist
mov esi,OFFSET slist
mov ebx,0
L1:
mov eax,0
add ax,[esi] ; if result is negative PL(sign flag will be set PL=1)
js found
pushfd ; backup 32 bit eflag to runtime stack
add esi,4 ; jump to next signed number in slist
popfd ; restore EFLAGS
LOOP L1
jns notfound
INVOKE ExitProcess,0
main endp
found PROC
mov bx,[esi] ; update ebx with 1st negative number found
mov ecx,0 ; set ECX to 0 to exit loop
ret
found endp
notfound PROC
mov ebx,0
ret
notfound endp
end main