概述
一.实验目的:
1.进一步掌握子程序设计方法;
2.进一步掌握基本的 DOS 功能调用.
二.实验内容:
1.从键盘上输入某班学生的某科目成绩.输入按学生的学号由小到大的顺序输入.
2.统计检查每个学生的名次.
3.将统计结果在屏幕上显示.
4.为便于观察,输入学生数目不宜太多,以不超过一屏为宜.输出应便于阅读.尽可
能考虑美观.
5.输入要有检错手段.
源程序:
DATA SEGMENT
BUFFER DB 100
DB 0
DB 100 DUP (0)
COUNT DB 0
COUNT1 DB 1
COUNT2 DB 0
COUNT3 DB 1
STRING1 DB 'NUM RANK SCORE',0DH,0AH,'$'
STRING2 DB ' ','$'
RANK DB 100 DUP (?)
MUN DB 100 DUP (?)
SCORE DB 100 DUP (?)
DATA ENDS
STACK SEGMENT STACK 'STACK'
DB 100 DUP (?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK,ES:DATA
MAIN: MOV AX,DATA
MOV DS,AX
CALL INPUT
CALL HH
CALL CHANGE
CALL PAIXU
CALL HH
CALL OUTPUT
MOV AX,4C00H
INT 21H
HH PROC
MOV AH,02H
MOV DL,0DH
INT 21H
MOV AH,02H
MOV DL,0AH
INT 21H
RET
HH ENDP
INPUT PROC
MOV DX,SEG BUFFER
MOV DS,DX
MOV DX,OFFSET BUFFER
MOV AH,0AH
INT 21H
RET
INPUT ENDP
CHANGE PROC
LEA BX,BUFFER
LEA DI,SCORE
LEA SI,MUN
MOV CH,1
CH1: MOV AL,[BX+2]
CMP AL,'!'
JZ A
CMP AL,','
JZ B
SUB AL,30H
ADD AL,AL
MOV DH,AL
MOV CL,2
SHL AL,CL
ADD AL,DH
MOV AH,[BX+3]
SUB AH,30H
ADD AL,AH
MOV [DI],AL
MOV [SI],CH
INC SI
INC CH
INC DI
INC BX
INC BX
JMP CH1
B: INC BX
JMP CH1
A: NOP
RET
CHANGE ENDP
PAIXU PROC ;假排序,只是获得每个成绩的地址
SUB CH,1
MOV AL,CH
ADD AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
MOV COUNT,CH
MOV COUNT2,CH
LEA SI,SCORE
LEA BX,RANK
D: LEA DI,SCORE
MOV AL,[SI]
E: MOV AH,[DI]
CMP AH,AL
JBE C
INC COUNT1
INC DI
DEC COUNT
JNZ E
F: INC SI
MOV COUNT,CH
MOV DL,COUNT1
MOV [BX],DL
INC BX
MOV DL,1
MOV COUNT1,DL
DEC COUNT2
JNZ D
JMP G
C: INC DI
DEC COUNT
JNZ E
JMP F
G: NOP
RET
PAIXU ENDP
OUTPUT PROC ;输出顺序为,number,score,rank
LEA SI,RANK
LEA DI,SCORE
MOV AH,09H
MOV DX,SEG STRING1
MOV DS,DX
MOV DX,OFFSET STRING1
INT 21H
H: CALL KONGGE
MOV AH,02H
MOV AL,COUNT3
ADD AL,30H
MOV DL,AL
INT 21H
INC COUNT3
CALL KONGGE
MOV AL,[SI]
ADD AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
CALL KONGGE
MOV AL,[DI]
CBW
MOV BL,10
DIV BL
MOV BH,AH
ADD AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
MOV AL,BH
ADD AL,30H
MOV AH,02H
MOV DL,AL
INT 21H
CALL HH
INC SI
INC DI
DEC CH
JNE H
JMP J
KONGGE: MOV AH,09H
MOV DX,SEG STRING2
MOV DS,DX
MOV DX,OFFSET STRING2
INT 21H
RET
J: NOP
RET
OUTPUT ENDP
CODE ENDS
END MAIN
最后
以上就是感动小虾米为你收集整理的北京邮电大学危机原理实验四 子程序设计的全部内容,希望文章能够帮你解决北京邮电大学危机原理实验四 子程序设计所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复