STACK SEGMENT STACK
DB 100 DUP(?)
STACK ENDS
DATA SEGMENT
X DW 10 DUP(?)
N DW 10
M DW 0
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
MAIN PROC FAR
PUSH DS
MOV AX,0
PUSH AX
MOV AX,DATA
MOV DS,AX
MOV CX,N
MOV SI,0
L1: CALL GETINT
MOV X[SI],AX
ADD SI,2
LOOP L1
CALL MAX
CALL PUTINT
RET
MAIN ENDP
GETINT PROC NEAR
MOV DI,10
MOV BX,M
L2: MOV AH,1
INT 21H
CMP AL,30H
JL L2
CMP AL,39H
JG L2
SUB AL,30H
MOV AH,0
MOV BX,AX
MOV AX,BX
MUL DI
ADD BX,AX
MOV AX,BX
RET
GETINT ENDP
MAX PROC NEAR
MOV SI,M
MOV AX,X
MOV CX,N
L4: CMP AX,X[SI]
JGE L5
MOV AX,X[SI]
L5: ADD SI,2
LOOP L4
RET
MAX ENDP
PUTINT PROC NEAR
MOV CX,M
MOV DL,10
L6: MOV DX,0
DIV DI
ADD DX,30h
PUSH DX
INC CX
CMP AX,0
JNE L6
L7: MOV AH,2
POP DX
INT 21H
LOOP L7
RET
PUTINT ENDP
CODE ENDS
END MAIN