汇编语言编写学生成绩管理系统

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

hh MACRO ;回车换行宏定义
PUSH DX
PUSH AX
MOV DL,0AH
MOV AH,2
INT 21H
MOV DL,0DH
MOV AH,2
INT 21H
POP AX
POP DX
ENDM

clear MACRO ;清屏宏定义
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AH,2
MOV DH,0
MOV DL,0
INT 10H
MOV AH,6
MOV AL,0
MOV BH,7
MOV CH,0
MOV CL,0
MOV DH,24
MOV DL,79
INT 10H
ENDM

DATAS SEGMENT
cj DB 100 DUP(-1)
pm DB 100 DUP(0)
mz DB 100 DUP(14 DUP(' '),'$')
strm1 DB '1.insert student score$'
strm2 DB '2.delete student score$'
strm3 DB '3.show student score and rank$'
strm4 DB 'ESC.exit$'
stri1 DB 'input the student number:$'
stri2 DB 'input this student score:$'
stri3 DB 'insert success,press any key!$'
stri4 DB 'input this student name:$'
strd1 DB 'delete the student number:$'
strd2 DB 'delete success,press any key!$'
strr1 DB '===================score and rank===================$'
strr2 DB 'number name score rank $'
strr3 DB 'show success,press any key!$'
stre DB 'error,please try again$'
strq DB 'thanks for using$'
DATAS ENDS

STACKS SEGMENT

STACKS ENDS

CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX

main:
LEA DX,strm1
MOV AH,9
INT 21H
hh
LEA DX,strm2 ;获取STRM2的偏移地址
MOV AH,9
INT 21H
hh
LEA DX,strm3 ;获取STRM3的偏移地址
MOV AH,9
INT 21H
hh
LEA DX,strm4
MOV AH,9
INT 21H
hh
main1:
MOV AH,1
INT 21H

CMP AL,31H ;插入学生成绩
JE insert ;等于则转移INSERT
CMP AL,32H ;删除
JE delete
CMP AL,33H ;显示
JE rank
CMP AL,1BH ;退出
JE quit
JMP main1 ;跳转到MAIN1

insert:
clear ;调用清屏宏
LEA DX,stri1
MOV AH,9
INT 21H
hh
CALL shuru
MOV BX,AX
hh

LEA DX,stri4
MOV AH,9
INT 21H
hh
PUSH BX
PUSH DX
MOV AX,BX
MOV CL,15
MUL CL
MOV BX,AX
LEA DX,mz[BX] ;把名字存到mz中
MOV AH,10
INT 21H
POP DX
POP BX
hh

LEA DX,stri2
MOV AH,9
INT 21H
hh

CALL shuru
MOV cj[BX],AL ;把成绩存到cj
hh

LEA DX,stri3
MOV AH,9
INT 21H
MOV AH,1
INT 21H
hh
clear
JMP main

delete:
clear
LEA DX,strd1
MOV AH,9
INT 21H
hh

CALL shuru
MOV BX,AX
MOV cj[BX],-1 ;把输入学号的成绩删除
hh

LEA DX,strd2
MOV AH,9
INT 21H
hh
MOV AH,1
INT 21H
hh
clear
JMP main

rank:
MOV CX,100
MOV DH,1

rank0:
MOV DL,DH
DEC CX
CMP CX,-1H
JE rank5
MOV BX,1

rank1:
CMP cj[BX],CL
JE rank3
rank2:
INC BX
CMP BX,100
JE rank0
JMP rank1

rank3:
MOV pm[BX],DL
;把名次存到pm
INC DH
JM

P rank2

rank5:

clear
LEA DX,strr1
MOV AH,9
INT 21H
hh
LEA DX,strr2
MOV AH,9
INT 21H
hh
MOV BX,0
MOV DH,1
rank10:
INC BX
CMP BX,100
JE rank11

CMP cj[BX],-1
JE rank10


INC DH
MOV DL,10
MOV AH,2
INT 10H
PUSH BX
PUSH DX
MOV AX,BX
MOV CL,15
MUL CL
MOV BX,AX
ADD BX,2
LEA DX,mz[BX]
MOV AH,9
INT 21H
POP DX
POP BX


MOV DL,1
MOV AH,2
INT 10H
MOV AX,BX
CALL shuchu

MOV DL,30
MOV AH,2
INT 10H
MOV AL,cj[BX]
CALL shuchu

MOV DL,45
MOV AH,2
INT 10H
MOV AH,0
MOV AL,pm[BX]
CALL shuchu
hh

JMP rank10
rank11:
LEA DX,strr3
MOV AH,9
INT 21H
MOV AH,1
INT 21H
clear
JMP main

quit:
clear
MOV BH,0
MOV AH,2
MOV DH,5
MOV DL,20
INT 10H

LEA DX,strq
MOV AH,9
INT 21H
MOV AH,4CH
INT 21H

shuru PROC NEAR
PUSH BX
return:
MOV AH,1
INT 21H
CMP AL,30H
JL cuowu
CMP AL,39H
JG cuowu
SUB AL,30H
MOV AH,0
MOV BL,10
MUL BL
MOV BX,AX
MOV AH,1
INT 21H
CMP AL,30H
JL cuowu
CMP AL,39H
JG cuowu
MOV AH,0
SUB AL,30H
ADD AX,BX
POP BX
RET

cuowu:
hh
LEA DX,stre
MOV AH,9
INT 21H
hh
JMP return

shuru ENDP

shuchu PROC NEAR
PUSH CX
PUSH DX
MOV CL,10
CBW ;字节扩展为字
IDIV CL
MOV DH,AH
MOV DL,AL
ADD DL,30H
MOV AH,2
INT 21H
MOV DL,DH
ADD DL,30H
MOV AH,2
INT 21H
POP DX
POP CX
RET
shuchu ENDP

CODES ENDS
END START



相关文档
最新文档