微机原理 汇编题一道,急求解答,高分求解答,要多少金币我可以追加
按同余法产生一组随机数N(1<N《50),并按N+50赋给45名同学的5门课程的成绩,要求编程实现计算每个同学的平均成绩,并根据平均成绩统计全班的成绩各等级的人数(A:9...
按同余法产生一组随机数N(1<N《50),并按N+50赋给45名同学的5门课程的成绩,要求编程实现计算每个同学的平均成绩,并根据平均成绩统计全班的成绩各等级的人数(A:90~100,B:80~89,C:70~79,D:66~69,E:60~65,F:60分以下),按以下格式显示:
Total<总人数>
A:<人数1>
B:<人数2>
C:<人数3>
D:<人数4>
E:<人数5>
F:<人数6>
要多少金币我可以追加,拜托了各位 展开
Total<总人数>
A:<人数1>
B:<人数2>
C:<人数3>
D:<人数4>
E:<人数5>
F:<人数6>
要多少金币我可以追加,拜托了各位 展开
展开全部
;用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
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询