Write an assembly program to find the largest element by searching an array int
ID: 3858228 • Letter: W
Question
Write an assembly program to find the largest element by searching an array int ary[] = {11, 15, -3, -4, 0, 60, 11, -9, 18} int index = 0: int max = ary[0]: int arraySize = sizeof array/sizeof max while (index max) max = ary[index]: } Use cmp instruction and the appropriate jump instruction (signed or unsigned) to translate the if and while statements Use S operator (see chapter 3) to calculate the size of the array, and ine instruction to increment the index of the array Run your program using the debugger to verify your answers (do this too for questions 2 and 3) Submit the following: Lastname1.asmExplanation / Answer
Answer: An assembly program to find the largest element by seraching an array
LXI H,4200 Set pointer for array
MOV B,M Load the Count
INX H Set 1st element as largest data
MOV A,M
DCR B Decrements the count
LOOP: INX H
CMP M f A- reg > M go to AHEAD
JNC AHEAD
MOVA,M Set the new value as largest
AHEAD:DCR B
JNZ LOOP Repeat comparisons till count = 0
STA 4300 Store the largest value at 4300
HLT
Save it by LastName1.asm and run it
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.