Created
April 4, 2019 01:40
-
-
Save 67hz/69f27fc9e0ed2a91f576d2bbbac8af9d to your computer and use it in GitHub Desktop.
x86 Assembly: Scanning an array for a non-zero value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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