Skip to content

Instantly share code, notes, and snippets.

@67hz
Created April 4, 2019 01:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 67hz/69f27fc9e0ed2a91f576d2bbbac8af9d to your computer and use it in GitHub Desktop.
Save 67hz/69f27fc9e0ed2a91f576d2bbbac8af9d to your computer and use it in GitHub Desktop.
x86 Assembly: Scanning an array for a non-zero value
; Scanning array for non-zero value
.386
.model flat
.data
;intArray SWORD 0,0,0,0,4,3,0,-34,-56,7,8
intArray SWORD 0,0,0,0,0,0,0,0,0,0,0,0
.code
main proc
mov ebx,OFFSET intArray
mov ecx,LENGTHOF intArray
L1:
cmp WORD PTR[ebx],0
jnz found
add ebx,2
loop L1
jmp notfound
found:
movsx eax,WORD PTR[ebx]
jmp quit
notfound:
mov eax,999999
quit:
ret
main endp
end main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment