In: Computer Science
Write a program to find out the maximum value out of a list of ten values using loop. The maximum finding codes can be in a Sub Routine named MAX (optional).
easy68k assembly language
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE
CODE-
DATA SEGMENT
ARR DB 5,3,7,1,9,2,6,8,4 ;Define byte to stote array
LEN DW $-ARR ;Define word(DW)
MIN DB ? ; We are initializing Min DB ? to ? (? stands for blank value).
MAX DB ?
DATA ENDS ;End point
CODE SEGMENT
ASSUME DS:DATA CS:CODE ;assume data name given to data segment
START:
MOV AX,DATA ;Move DATA to AX
MOV DS,AX ;Move AX to DATA
LEA SI,ARR Load effective address which load address of second element into the first element
MOV AL,ARR[SI] ; move the value of Array ARR in index of SI register to AL register.
MOV MIN,AL ;Mov AL register to Minimum
MOV MAX,AL ;Mov AL register to Maximum
MOV CX,LEN ;Assign value of 8 to CX (8 is length of array)
REPEAT: ; label and all word end with (:)
MOV AL,ARR[SI]
CMP MIN,AL ;compare for minimum
JL CHECKMAX ;check for max
MOV MIN,AL ;store min in AL
CHECKMAX:
CMP MAX,AL ;comapre for max
JG DONE
MOV MAX,AL ;move max value in MAX
DONE:
INC SI ;Increment the address value in SI
LOOP REPEAT ;end of loop
MOV AH,4CH ;if value is 4ch then return
INT 21H
CODE ENDS ;end of code segment
END START ; end of program