Assume that you have the following set of hexadecimal values
Assume that you have the following set of hexadecimal values: $20, $25, $40, $50, $12. Write a segment of a program to find the minimum and maximum values of the set.
Solution
DATA SEGMENT
ARR DW $20,$25,$40,$50,$12
LEN DW $05
MIN DB ?
MAX DB ?
DATA ENDS
CODE SEGMENT, ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AXLEA 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 ENDS
END START
