Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Language only please Array Maximum and Minimum Declare an array of inte

ID: 3706264 • Letter: A

Question

Assembly Language only please

Array Maximum and Minimum Declare an array of integers: .data size: .word 8 array: .word 23, -12, 45, -32, 52,-72, 8, 13 Write a program that determines the minimum and the maximum element in the array. Assume that the array has at least one element (in which case, that element will be both the minimum and maximum.) Leave the results in registers. Qtspim simulator: The starting address of Data Section is 0x10000000 Mars simulator: The starting address of Data Section is 0x10010000

Explanation / Answer

DATA SEGMENT

/* Declare an array */

ARR DB 25,-12,45,-32,52,-72,8,

/* Find length of array*/

LEN DW $-ARR

/* Declare variable for minimum and maximum*/

MIN DB ?

MAX DB ?

DATA ENDS

CODE SEGMENT

ASSUME DS:DATA CS:CODE

START:

MOV AX,DATA

MOV DS,AX

LEA SI,ARR

MOV AL,ARR[SI]

MOV MIN,AL

MOV MAX,AL

MOV CX,LEN

REPEAT:

MOV AL,ARR[SI]

CMP MIN,AL

JL CHECKMAX

MOV MIN,AL

CHECKMAX:

CMP MAX,AL

JG DONE

MOV MAX,AL

DONE:

INC SI

LOOP REPEAT

MOV AH,4CH

INT 21H

CODE END

END START

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote