in x86 Assembly pls 1. (7 points) Write an assembly program to find the largest
ID: 3741435 • Letter: I
Question
in x86 Assembly pls
1. (7 points) Write an assembly program to find the largest element by searching an array int array[ 10, 5,-1, 0, 12, 18, 11, -13, 40 int index = 0 ; int max-array[0]; int arraySize-sizeof array / sizeof max while (index max) max- array[index]; indext+ 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 inc instruction to increment the index of the array Run your program using the debugger to verify your answers (do this too for questions 2) - Submit the following: o Lastname1.asmExplanation / Answer
SOurceCode:
DATA SEGMENT //data segment .data are initialized
ARY DB 1,5,-3,-4,0,6,11,-9,18 // input array
SIZE DW $ARY /size of array
MAX DB ? //large no find
DATA ENDS /data segments ends
CODE SEGMENT /code segments
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA /data moved to AX register
MOV DS,AX
LEA SI,ARY /starting address of array is loaded to SI register
MOV AL,ARY[SI]
MOV MAX,AL /array[0] is moved to max
MOV BL,SIZE
LOOP1:
MOV AL,ARY[SI]
CMP MAX,AL /comparison to find large no
JG LOOP2
MOV MAX,AL
LOOP2:
INC SI /index of array is incremented
LOOP LOOP1
MOV AH,4CH
INT 21H
CODE ENDS /code ends here
END START
OUTPUT:
ARY 1,5,-3,-4,0,6,11,-9,18
SIZE 9
MAX 18
//Hi, if you have any quiries please comment in here, and do rate the solution if it is helpful to you...Thanks
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.