用汇编写的一个学生成绩管理系统
来源:互联网 发布:linux新建 删除文件夹 编辑:程序博客网 时间:2024/06/01 23:21
用汇编写的学生成绩管理,就个人而言算是比较满意之作,现在供大家分享参考,如果有什么问题希望留言提出
功能:1.建立成绩文档
2.计算总分和平均分
3.显示成绩报表
原理分析
思想很简单,就是由键盘输入学生的相关数据(学号,个科目成绩),然后算出每个学生的平均分以及总分,然后将他们记录在链表中,然后生成相应的文本,然后就可以从文本中读取相应数据并显示。
源程序
程序开始运行:
输入数据:
创建文件成功
写入文件后文件内容
读出内容
huanhang macro;换行回车 mov ah,2 mov dl,10 int 21h mov ah,2 mov dl,13 int 21h endm ;-----------------------------------------------------------------------DATAS SEGMENTbuff2 db 512 dup('$');缓冲区2,用于储存从file中读出的文件。englishgrade dw 300 dup(0) ;用于记录英语成。arrage dw 300 dup('$') ;用于记录平均分。sum dw 300 dup('$') ;用于记录总分studycode dw 300 dup('$') ;用于记录学号 mathgrade dw 300 dup(0) ;用于记录数学成绩。 buff db 1200 dup('$') ;缓冲区1,用于写入file。 buffcode db 300 dup(0) ;以下为对应的相应链表,主要是为了file的排版用到。 buffenglish db 300 dup(0) buffmath db 300 dup(0) buffarrage db 300 dup(0) buffsum db 300 dup(0) input1 dw 0 ;各种输入时用到的中间量 y dw 10 ;用于div 10 ;以下是菜单 z1 db "*--------------------------------------------------------*$" z2 db "* 1.Input the data about students. *$" z3 db "* 2.create a new file to store the data. *$" z4 db "* 3.write the data into the file. *$" z5 db "* 4.read the data from the file. *$" z6 db "* 5.output the data you read from the file. *$" z7 db "*--------------------------------------------------------*$" z8 db "* 6.exit *$" ;以下是各种成功,报错语句。 h12 db "THE data is successful read!$" h11 db "THE data is successful writed!$" h10 db "THE file is successful created!$" h9 db "Please input your choose:$" h8 db "code english math sum arrage$" h7 db "Error!!your file can't open!$" h6 db "Error!!can't make the new file!!$" h5 db "Please input the students' math grade:$" h4 db "please input the how many students:$" h3 db "Please input the students' english grade:$" h2 db "your input is error!$" h1 db "please input the students' codes:$" ;标志位,因为成绩有可能是3位也有可能是2位,所以写入file时需要判断写入多少位 aflag dw 0 bflag dw 0 ;中间变量,用于记录“数组下标”。 a dw 0 b dw 0 d dw 0 e dw 0 f dw 0 g dw 0 h dw 0 i dw 0 j dw 0 k dw 0 shuliang dw 0 k1 db 'abc.txt',00h handle dw 0 handle2 dw 0DATAS ENDS STACKS SEGMENT stack s dw 100 dup(0)STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKSmain proc far ;主程序。 push ds xor ax,ax push ax MOV AX,DATAS MOV DS,AX N0: huanhang huanhang huanhang huanhang huanhang call menu huanhang mov ah,09h lea dx,h9 int 21h mov ah,01h int 21h cmp al,36h jg kerror cmp al,30h jb kerror cmp al,31h je N1 cmp al,32h je N2 cmp al,33h je N3 cmp al,34h je N4 cmp al,35h je N5 cmp al,36h je exitN1: huanhang call input jmp N0N2: huanhang mov ah,09h lea dx,h10 int 21h call newfile jmp N0 huanhangN3: huanhang mov ah,09h lea dx,h11 int 21h call writefile huanhang jmp N0N4: huanhang mov ah,09h lea dx,h12 int 21h call readfile huanhang jmp N0N5: huanhang call output jmp N0kerror: call error1 exit: retmain endp;-----------------------------------------------------------------------input proc near uses ax bx cx dx si di ;输入子程序。 call inputshuliang mov cx,shuliangbL1: call inputstudycode call inputEnglishGrade call inputMathGrade call inputbuff huanhang call getsum call getarrage mov di,h mov buff[di],0dh inc h mov di,h mov buff[di],0ah inc h mov di,h loop bL1 bexit: retinput endp ;-----------------------------------------------------------------------inputstudycode proc near uses ax bx cx dx si di ;输入学号in__1: mov ah,09h lea dx,h1 int 21h mov cx,4 mov si,a mov di,b in_1: mov ah,01h int 21h cmp al,0dh je P1 cmp al,0ah je P1 xor ah,ah ;这一小块,是将学号压入对应的链表。方便接下来的操作 mov buffcode[di],al inc b mov di,bP1: cmp ax,30h ;乘以10的输入方法。 jb aerror cmp ax,39h jG aerror sub ax,30h mov bx,ax mov ax,input1 mul y mov input1,ax add input1,bx loop in_1 huanhang mov dx,input1 mov studycode[si],dx xor bx,bx mov input1,bx jmp aexit aerror: call error1 jmp in__1aexit: mov di,b ;位了排版好看,这里压入一个空格 mov al,' ' mov buffcode[di],al inc b retinputstudycode endp ;----------------------------------------------------------------------- inputEnglishGrade proc near uses ax bx cx dx si di ;输入英语成绩in__2: mov ah,09h lea dx,h3 int 21h mov si,a mov cx,3 mov di,din_2: mov ah,01h int 21h cmp al,0dh je aL1 xor ah,ah ;将成绩(这里提一下,因为这里直接就是A码,下面写入的时候就不用再加30h了),压入对应的链表 mov buffenglish[di],al inc d mov di,d inc aflag ;记录成绩的位数,2位还是3位 P2: cmp ax,0dh je aL1 cmp ax,30h jb berror cmp ax,39h jG berror sub ax,30h mov bx,ax mov ax,input1 mul y mov input1,ax add input1,bx loop in_2aL1: huanhang mov dx,input1 mov englishgrade[si],dx xor bx,bx mov input1,bx jmp bexit berror: call error2 jmp in__2bexit: retinputEnglishGrade endp ;----------------------------------------------------------------------- inputMathGrade proc near uses ax bx cx dx si di ;输入数学成绩,几乎与输入英语成绩一样in__4: mov ah,09h lea dx,h5 int 21h mov si,a mov cx,3 mov di,ein_4: mov ah,01h int 21h cmp al,0dh je cL1 xor ah,ah mov buffmath[di],al inc e mov di,e inc bflag cmp ax,30h jb cerror cmp ax,39h jG cerror sub ax,30h mov bx,ax mov ax,input1 mul y mov input1,ax add input1,bx loop in_4cL1: huanhang mov dx,input1 mov mathgrade[si],dx xor bx,bx mov input1,bx jmp cexit cerror: call error2 jmp in__4cexit: retinputMathGrade endp ;-----------------------------------------------------------------------inputshuliang proc near uses ax di cx ;输入学生数量 mov ah,09h lea dx,h4 int 21h mov cx,6 in_3: mov ah,01h ;简单的乘10输入。 int 21h xor ah,ah cmp ax,0dh je in_out cmp ax,30h jb in_out cmp ax,39h jG in_out sub ax,30h mov bx,ax mov ax,shuliang mul y mov shuliang,ax add shuliang,bx loop in_3in_out: huanhang ret inputshuliang endp ;-----------------------------------------------------------------------error1 proc near uses ax bx cx dx si di ;输入错误处理。 huanhang mov ah,09h lea dx,h2 int 21h xor cx,cx mov input1,cx huanhang reterror1 endp ;-----------------------------------------------------------------------;输入错误处理。这里本来是有点不同的,后来改着改着就一样了,但为了避免代码大规模变化,就留着它了。error2 proc near uses ax bx cx dx si di huanhang mov ah,09h lea dx,h2 int 21h xor cx,cx mov input1,cx huanhang reterror2 endp ;-----------------------------------------------------------------------getsum proc near uses ax bx cx dx si di ;求总分的子程序 mov si,a xor cx,cx mov di,h mov ax,englishgrade[si] mov bx,mathgrade[si] add ax,bx mov sum[si],ax L8: ;这里用除10法,将总分压入缓冲区 xor dx,dx div y push dx inc cx cmp ax, 0 je L9 jmp L8 L9: pop dx add dl,30h mov buff[di],dl inc h mov di,h loop L9 mov di,h mov al,' ' mov buff[di],al inc h retgetsum endp;-----------------------------------------------------------------------getarrage proc near uses ax bx cx dx si di ;求平均分,与求总分的基本一致 mov si,a xor cx,cx mov di,h xor dx,dx mov ax,sum[si] mov bx,2 div bx mov arrage[si],ax add a,2 L10: xor dx,dx div y push dx inc cx cmp ax, 0 je L11 jmp L10 L11: pop dx add dl,30h mov buff[di],dl inc h mov di,h loop L11 mov di,h mov al,' ' mov buff[di],al inc h retgetarrage endp ;-----------------------------------------------------------------------;创建新文档,这里本来应该是创建在C盘的,但是WIN7下(还是虚拟机下),导致创建不出来,最后只能在masm的根目录下创建了。newfile proc near uses ax bx cx dx si di mov ah,3ch mov cx,00 lea dx,k1 int 21h jc eerror mov handle,ax jmp e5eerror: mov ah,09h lea dx,h6 int 21h e5: retnewfile endp;-----------------------------------------------------------------------;写入文档,这里犯了一个很严重的错误,就是最后忘记把文件给关了,导致下面文档的内容读不出来,苦了整整一个下午才发现。writefile proc near uses ax bx cx dx si di mov ah,40h mov bx,handle mov cx,h lea dx,buff int 21h jc derror jmp e6 derror: mov ah,09h lea dx,h6 int 21he6: mov ah,3eh int 21h retwritefile endp;-----------------------------------------------------------------------;整合资料,将各个种类的资料按“学号 英语成绩 数学成绩 总分 平均分”的顺序排版,一行一位学生。inputbuff proc near uses ax bx cx dx si di mov si,h mov cx,5 S1: mov di,i mov al,buffcode[di] mov buff[si],al inc i inc h mov si,h mov di,i loop S1 inc aflag ;这里就用到了前文的标志位,因为还要再加空格,所以它要+1. mov cx,aflag mov di,d mov al,' ' mov buffenglish[di],al inc d S2: mov di,j mov si,h mov al,buffenglish[di] mov buff[si],al inc h inc j mov si,h mov di,j loop S2 inc bflag mov cx,bflag mov di,e mov al,' ' mov buffmath[di],al inc e S3: mov di,k mov si,h mov al,buffmath[di] mov buff[si],al inc h inc k mov si,h mov di,k loop S3 xor ax,ax mov aflag,ax mov bflag,ax retinputbuff endp;-----------------------------------------------------------------------;文件的读取。readfile proc near uses ax bx cx dx si di mov ah,3dh mov al,00 lea dx,k1 int 21h jc gerror mov handle2,ax J1: mov ah,3fh mov bx,handle2 mov cx,512 lea dx,buff2 int 21h jc gerror cmp ax,0 je e13 jmp e13gerror: call error5e13: retreadfile endp;-------------------------------------------------------------------------error5 proc near uses ax bx cx dx si di ;读取错误的子程序 mov ah,09h lea dx,h7 int 21h reterror5 endp ;-------------------------------------------------------------------------output proc near uses ax bx cx dx si di ;输出读取到的内容 mov ah,09h lea dx,h8 int 21h huanhang xor si,siO1: mov ah,02h mov dl,buff2[si] cmp dl,'$' je e14 int 21h inc si jmp O1e14: retoutput endp ;-------------------------------------------------------------------------menu proc near uses ax bx cx dx si di ;菜单栏。 mov ah,09h lea dx,z1 int 21h huanhang mov ah,09h lea dx,z2 int 21h huanhang mov ah,09h lea dx,z3 int 21h huanhang mov ah,09h lea dx,z4 int 21h huanhang mov ah,09h lea dx,z5 int 21h huanhang mov ah,09h lea dx,z6 int 21h huanhang mov ah,09h lea dx,z8 int 21h huanhang mov ah,09h lea dx,z7 int 21h retmenu endp CODES ENDS END main
0 0
- 用汇编写的一个学生成绩管理系统
- Linux--用shell写一个学生成绩管理系统
- 用C写的简单学生成绩管理系统
- 用js写的学生成绩管理系统
- 用C语言写的学生成绩管理系统
- 用 c编写的一个学生成绩管理系统
- JAVA写的学生成绩管理系统
- 用C++写学生成绩管理系统
- 一个学生成绩管理系统的代码
- 一个简单的学生成绩管理系统
- 我要写一个学生成绩管理系统
- 汇编:学生成绩管理系统
- 我写的Java学生成绩管理系统源代码
- 用Objective-C写学生成绩管理系统MIS
- 一个很烂的学生成绩管理系统
- 汇编——学生成绩管理系统
- 用c++模拟实现一个学生成绩管理系统
- 我至今写的最长的代码!!(学生成绩管理系统)
- C++结构体之统计最高最低分
- 线程池的概念及Linux 怎么设计一个简单的线程池
- 最大数的输出
- PowerDesigner学习之零散笔记
- LeetCode Merge Sorted Array
- 用汇编写的一个学生成绩管理系统
- suse下安装apache
- 第1次实验——NPC问题(回溯算法、聚类分析)
- C语言实验-打印金字塔
- ARM体系结构与编程
- python之蟒开启理论计算化学的新时代
- 纵向滑动条的方法
- SSH深度历险(四) Maven初步学习
- 在struts1框架下用jQuery进行异步提交出现缺少method属性的异常