;用MASM5.0编译通过
data segment
T DB 45
A DB 0
B DB 0
C DB 0
D DB 0
E DB 0
F DB 0
N DB 45 DUP(5 DUP(0)) ;定义成绩存放单元
AVR DB 45 DUP(0) ;定义平均成绩存放单元
MESS DB 0dh,0ah
DB "Total $"
AA DB " : "
M1 DB " "
M2 DB " ",0DH,0AH,24H
data ends
code segment
main proc far
assume cs:code,ds:data
start:
PUSH DS
XOR AX,AX
PUSH AX
MOV AX,DATA
MOV DS,AX
PUSH DS
POP ES
;以下产生随机成绩
MOV CX,5*45
XOR AL,AL
OUT 43H,AL
IN AL,40H
MOV DI,OFFSET N
NEXT:
MOV BX,11
MOV AH,0
MUL BX
ADD AX,5463
MOV DX,0
MOV BX,50
DIV BX
ADD DL,50
MOV [DI],DL
INC DI
MOV AL,DL
LOOP NEXT
;以下求平均成绩
MOV DI,OFFSET AVR
MOV SI,OFFSET N
MOV CX,45
L0:
PUSH CX
MOV CX,5
MOV AX,0
L1:
MOV BH,0
MOV BL,[SI]
ADD AX,BX
INC SI
LOOP L1
MOV BL,5
DIV BL
MOV [DI],AL
POP CX
INC DI
LOOP L0
;以下统计成绩类型
MOV CX,45
MOV BX,OFFSET AVR
C_NEXT:
MOV AL,[BX]
CMP AL,90
JB C1
INC A
JMP C_END
C1:
CMP AL,80
JB C2
INC B
JMP C_END
C2:
CMP AL,70
JB C3
INC C
JMP C_END
C3:
CMP AL,66
JB C4
INC D
JMP C_END
C4:
CMP AL,60
JB C5
INC E
JMP C_END
C5:
INC F
C_END:
INC BX
LOOP C_NEXT
;以下显示结果
MOV DX,OFFSET MESS
MOV AH,09
INT 21H
MOV AL,T
CALL BIN_D
MOV AL,A
MOV AA,'A'
CALL BIN_D
MOV AL,B
INC AA
CALL BIN_D
MOV AL,C
INC AA
CALL BIN_D
MOV AL,D
INC AA
CALL BIN_D
MOV AL,E
INC AA
CALL BIN_D
MOV AL,F
INC AA
CALL BIN_D
RET
main endp
;=====================
;以下数字-ASCII码转换
BIN_D PROC NEAR
MOV AH,0
MOV BL,10D
DIV BL
CMP AL,0
JE NO10
ADD AX,3030H
MOV M1,AL
MOV M2,AH
JMP DISP11
NO10:
ADD AH,30H
MOV M1,AH
MOV AL,' '
MOV M2,AL
DISP11:
MOV DX,OFFSET AA
MOV AH,09
INT 21H
RET
BIN_D ENDP
;========================
code ends
end start
建议你去百度或GOOGLE搜索一下,看看有没有相关信息或资料可以帮你。
答案发给你了,请查收