Assembly Language Array Program using LOOPZ instruction
$10-30 USD
Ukończony
Opublikowano ponad 10 lat temu
$10-30 USD
Płatne przy odbiorze
Application: Sequential Search of an Array
Example:
The following program looks for the first nonzero value in an array of 16-bit integers.
If it finds one, it displays the value; otherwise, it displays a message stating that a nonzero value
was not found:
This assembly program is done with Visual Studio 2010 using MASM. I need to change the code and implement this search using a LOOPZ instruction. Can anyone help with this? It just needs some small changes.
Here is the code.
TITLE Scanning an Array ([login to view URL])
; Scan an array for the first nonzero value.
INCLUDE [login to view URL]
.data
intArray SWORD 0, 0, 0, 0, 1, 20, 35, -12, 66, 4, 0
noneMsg BYTE "A non-zero value was not found",0
.code
main PROC
mov ebx,OFFSET intArray ; point to the array
mov ecx,LENGTHOF intArray ; loop counter
L1: cmp WORD PTR [ebx],0 ; compare value to zero
jnz found ; found a value
add ebx,2 ; point to next
loop L1 ; continue the loop
jmp notFound ; none found
found: ; display the value
movsx eax,WORD PTR[ebx] ; sign-extend into EAX
call WriteInt
jmp quit
notFound: ; display "not found" message
mov edx,OFFSET noneMsg
call WriteString
quit:
call Crlf
exit
main ENDP
END main
Hi
I can write the program to run with MASM using Irvine32 library.
Thanks
---
I can give you a solution:
L1: cmp WORD PTR [ebx],0 ; compare value to zero
add ebx,2 ; point to next
LOOPZ L1 ; loop while the number is zero
$10 USD w 0 dzień
4,8 (52 opinii)
5,2
5,2
3 freelancerzy składają oferty o średniej wysokości $21 USD dla tej pracy