Question: DATA SEGMENT MenuMsg DB 'Menu Options:$ ' Opt 1 Msg DB ' 1 . Select number of integers ( Max 1 0 ) $ '

DATA SEGMENT
MenuMsg DB 'Menu Options:$'
Opt1Msg DB '1. Select number of integers (Max 10)$'
Opt2Msg DB '2. Enter numbers$'
Opt3Msg DB '3. Compute the average$'
Opt4Msg DB '4. Find the maximum number$'
Opt5Msg DB '5. Find the minimum number$'
Opt6Msg DB '6. Exit program$'
PromptMsg DB 'Enter your choice (1-6): $'
CountPrompt DB 'Enter count (1-10): $'
NumPrompt DB 'Enter number: $'
AvgMsg DB 'The average is: $'
MaxMsg DB 'The maximum number is: $'
MinMsg DB 'The minimum number is: $'
InvalidMsg DB 'Invalid choice. Try again.$'
Numbers DW 10 DUP(?)
Count DW 0
Total DW 0
Avg DW 0
Max DW 0
Min DW 0
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX ; Initialize Data Segment
MainMenu:
; Display the menu
CALL DisplayMenu
; Get user input
CALL GetChoice
CMP AL,1 ; Check option
JE SelectCount
CMP AL,2
JE EnterNumbers
CMP AL,3
JE ComputeAverage
CMP AL,4
JE FindMaximum
CMP AL,5
JE FindMinimum
CMP AL,6
JE ExitProgram
; Invalid choice
CALL DisplayInvalid
JMP MainMenu
SelectCount:
; Prompt for count
CALL DisplayCountPrompt
CALL GetNumber
CMP AX,1
JL InvalidInput
CMP AX,10
JG InvalidInput
MOV Count, AX ; Store count
JMP MainMenu
EnterNumbers:
; Prompt for numbers
MOV CX, Count ; Loop count
XOR SI, SI ; Index
EnterLoop:
CALL DisplayNumPrompt
CALL GetNumber
MOV [Numbers + SI], AX
ADD SI,2
LOOP EnterLoop
JMP MainMenu
ComputeAverage:
; Compute the average
MOV CX, Count ; Loop count
XOR AX, AX ; Clear AX (sum)
XOR SI, SI ; Index
SumLoop:
ADD AX,[Numbers + SI]
ADD SI,2
LOOP SumLoop
MOV BX, Count
DIV BX ; AX / BX
MOV Avg, AX ; Store average
CALL DisplayAvg
JMP MainMenu
FindMaximum:
; Find the maximum number
XOR SI, SI
MOV AX,[Numbers]
MOV CX, Count
DEC CX
MaxLoop:
MOV BX,[Numbers + SI]
CMP BX, AX
JLE SkipMax
MOV AX, BX
SkipMax:
ADD SI,2
LOOP MaxLoop
MOV Max, AX
CALL DisplayMax
JMP MainMenu
FindMinimum:
; Find the minimum number
XOR SI, SI
MOV AX,[Numbers]
MOV CX, Count
DEC CX
MinLoop:
MOV BX,[Numbers + SI]
CMP BX, AX
JGE SkipMin
MOV AX, BX
SkipMin:
ADD SI,2
LOOP MinLoop
MOV Min, AX
CALL DisplayMin
JMP MainMenu
ExitProgram:
MOV AH,4CH
INT 21H
DisplayMenu:
; Print menu
MOV AH,09H
LEA DX, MenuMsg
INT 21H
LEA DX, Opt1Msg
INT 21H
LEA DX, Opt2Msg
INT 21H
LEA DX, Opt3Msg
INT 21H
LEA DX, Opt4Msg
INT 21H
LEA DX, Opt5Msg
INT 21H
LEA DX, Opt6Msg
INT 21H
RET
DisplayCountPrompt:
MOV AH,09H
LEA DX, CountPrompt
INT 21H
RET
DisplayNumPrompt:
MOV AH,09H
LEA DX, NumPrompt
INT 21H
RET
DisplayInvalid:
MOV AH,09H
LEA DX, InvalidMsg
INT 21H
RET
DisplayAvg:
MOV AH,09H
LEA DX, AvgMsg
INT 21H
CALL PrintNumber
RET
DisplayMax:
MOV AH,09H
LEA DX, MaxMsg
INT 21H
CALL PrintNumber
RET
DisplayMin:
MOV AH,09H
LEA DX, MinMsg
INT 21H
CALL PrintNumber
RET
GetChoice:
MOV AH,01H
INT 21H
SUB AL,'0'
RET
GetNumber:
; Read a number from the user
MOV AH,01H
INT 21H
SUB AL,'0'
MOV AH,0
RET
PrintNumber:
; Convert and print number in AX
; Simplified implementation, add routines for formatting numbers
RET
CODE ENDS
END START

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!