; ; Name: Karamian, Vahe ; Project: #3 ; Due: 11/09/2000 ; ; Description: ; 1. Query user for a list of 32 numbers between 1 and 100 ; 2. Compute the sum, the maximum, the minimum, and the ; integer average INCLUDE PCMAC.INC .MODEL SMALL .STACK 100H .DATA BLANK_LINE DB 13, 10, '$' HEADER DB "Project #3", 10, 13, 10, 13 DB "Enter the numbers, 0 to end:", 10, 13, '$' PROMPT DB "?", '$' INVALID DB "Number not between 1-100.", 10, 13, '$' NOTANUM DB "No number is entered.", 10, 13, '$' COUNT DB "Count: ", '$' TOTAL DB "Total: ", '$' MAXIMUM DB "Maximum: ", '$' MINIMUM DB "Minimum: ", '$' AVERAGE DB "Average: ", '$' TOT Dw 0 CNT Dw 0 MAX Dw 0 MIN Dw 100 AVG Dw 0 .CODE EXTRN GetDec: NEAR, PutDec: NEAR PROJ3 PROC mov AX, @DATA mov DS, AX _PutStr BLANK_LINE _PutStr HEADER WHILEL32: cmp CNT, 32 jge FIN ; End program is CNT>32 _putstr PROMPT ; Get Number call GetDec jc ERROR2 ; Not A number! cmp AX, 100 jg ERROR1 ; NUM>100 cmp AX, 0 jl ERROR1 ; NUM<0 je FIN ; if NUM=0, End Program cmp AX, MAX jle LESS_MAX ; NUMMIN mov MIN, AX ; MIN = NUM MORE_MIN: add TOT, AX ; Compute Total inc CNT jmp WHILEL32 ERROR1: _PutStr INVALID jmp WHILEL32 ERROR2: _PutStr NOTANUM jmp WHILEL32 FIN: cmp CNT, 0 jg DOIT mov MIN, 0 DOIT: _PutStr BLANK_LINE _PutStr COUNT ; Display Count mov AX, CNT call PutDec _PutStr BLANK_LINE _PutStr TOTAL ; Display Total mov AX, TOT call PutDec _PutStr BLANK_LINE _PutStr MAXIMUM ; Display Maximum mov AX, MAX call PutDec _PutStr BLANK_LINE _PutStr MINIMUM ; Display Minimum mov AX, MIN call PutDec _PutStr BLANK_LINE cmp CNT, 0 je DISPLAY_AVG xor DX, DX ; calculate Average mov AX, TOT div CNT mov AVG, AX mov CX, DX xor DX, DX mov AX, CNT mov BX, 2 ;xor DX, DX div BX cmp AX, CX jg DISPLAY_AVG cmp CNT, 1 je DISPLAY_AVG inc AVG DISPLAY_AVG: _PutStr AVERAGE mov AX, AVG call PutDec _PutStr BLANK_LINE DONE: _EXIT PROJ3 ENDP END PROJ3