程序有问题,请高手看看,帮忙改改!
汇编编程题目:计算10个0~9之间数字的总和、平均值并统计大于6的数字的个数。
要求:
(1)屏幕显示程序功能-欢迎界面;
(2)键盘输入具体数值,限制输入范围在0~9之间;
(3)屏幕显示计算结果;
(4)控制程序的循环与退出方式;
(5)给出源程序和流程图。
DATA SEGMENT
WELTOUSE DB 0DH,0AH,‘Welcome to use this program!$’
INTRO DB 0DH,0AH,‘If you want to quit the program,type q or Q!$’
INTRO2 DB 0DH,0AH,‘Please input 10 integers between 0 to 9!$’
ERR DB 0DH,0AH,‘Error!!! Valid range is from 0 to 9!$’
NUM DB 0DH,0AH,‘NO.$’
SUM DB 0DH,0AH,‘The sum is :$’
AVE DB 0DH,0AH,‘The average is :$’
PASSED DB 0DH,0AH,‘The numbers passed are :$’
ALLPASS DB 0DH,0AH,‘All numbers passed .$’
TRYAGAIN DB 0DH,0AH,‘Welcome to try again .$’
SURE DB 0DH,0AH,‘Are you sure to exit ?(Y/N)$’
EXIT DB 0DH,0AH,‘Thanks for suing,press any key to exit .$’
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
GETCHAR MACRO
MOV AH,01H
INT 21H
ENDM
DISPLAY1 MACRO STRING
LEA DX,STRING
MOV AH,09H
INT 21H
ENDM
DISPLAY2 MACRO
DISPLAY1 NUM
MOV DX,SI
MOV AH,02H
INT 21H
MOV DL,‘>’
MOV AH,02H
INT 21H
ENDM
DISPLAYCHAR MACRO
MOV AH,02H
INT 21H
ENDM
EXIT1: DISPLAY1 EXIT
GETCHAR
MOV AX,4CH
INT 21H
QUIT: DISPLAY1 SURE
GETCHAR
CMP AL,‘N’
JZ INPUT
CMP AL,‘Y’
JZ EXIT1
JMP QUIT
ERROR: DISPLAY1 ERR
JMP INPUT
START: MOV AX,DATA
MOV DS,AX
DISPLAY1 WELTOUSE
DISPLAY1 INTRO
INITIAL: DISPLAY1 INTRO2
MOV CX,10
MOV BX,0
MOV BP,‘0’
MOV SI,‘0’
INPUT: DISPLAY2
GETCHAR
CMP AL,‘q’
JZ QUIT
CMP AL,‘Q’
JZ QUIT
CMP AL,‘9’
JA ERROR
CMP AL,‘0’
JB ERROR
CMP AL,‘6’
JBE SIXS
INC BP
SIXS: INC SI
SUM AL,30H
ADD BL,AL
LOOP INPUT
MOV BH,10
MOV AX,BX
MOV BL,10
DIV BL
MOV BX,AX
ADD BL,30H
ADD BH,30H
DISPLAY1 SUM
MOV DL,BL
DISPLAYCHAR
MOV DL,BH
DISPLAYCHAR
DISPLAY1 AVE
MOV DL,BL
DISPLAYCHAR
MOV DL,BH
DISPLAYCHAR
MOV CX,BP
CMP BP,‘:’
JE ALLPASSED
DISPLAY1 PASSED
MOV DX,CX
DISPLAYCHAR
JMP OVER
ALLPASSED: DISPLAY1 ALLPASS
JMP OVER
OVER: DISPLAY1 TRYAGAIN
DIAPLAY1 INTRO
JMP INITIAL
CODE ENDS
END START