




已阅读5页,还剩27页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
学生成绩管理系统设计实验(汇编语言) 学生成绩管理系统设计实验一、实验目的 1、熟悉汇编语言程序结构; 2、熟悉int 21h的文件操作功能调用; 3、熟悉int 21h的1、9号功能和int 10h常用功能的使用方法; 4、掌握多子程序复杂问题程序设计方法; 5、掌握利用汇编语言实现字符串的输入输出程序设计方法; 6、了解多模块程序设计方法。二、实验原理 我们把可以多次调用、具有通用性、能完成特定功能的程序段编写成的独立程序模块称为子程序。子程序是把一个程序划分成若干模块所用的主要手段,它便于独立设计、测试程序和编制程序文件。实验内容1、实验要求 设计一个学生成绩管理系统,要求完成文件建立、学生成绩录入、显示指定学号的学生记录、删除一个学生的记录、修改学生记录、返回等工作。学生成绩包括学号xh、姓名xm、数学sx、语文yw、外语wy字段。至少包括30名学生信息,每名学生学号字段为4个字符,姓名字段为15个字符最大,每门成绩字段为3个字符最大。 程序设计步骤如下: 1、编写主程序main.asm; 2、编写文件创建子程序create,实现在指定盘指定文件夹“d:chengji2009”下建立一个指定名称的文件2009doc.dat; 3、编写成绩录入子程序append,实现在指定文件尾部插入一个学生的成绩记录; 4、编写显示子程序display,实现按指定学号显示一个学生的记录; 5、编写修改子程序modify,实现按指定学号修改一个学生的记录字段不需修改直接回车; 6、编写删除子程序,实现按指定学号、姓名删除一个学生的记录; 7、编译、链接、调试,产生可执行文件main.exe。程序流程图3、程序代码程序代码如下:datas segment msg1 db 1. append a record$ msg2 db 2. display a record$ msg3 db 3. modify a record$ msg4 db 4. delete a record$ msg5 db 5. create file$ msg6 db 6. return dos$ msgc db please input 1-6:$ msge db error!$ msgc1 db please input filename:$ len db 25 actlen db string db 25 duplen1 db 25 actlen1 db string1 db 25 duppathnm db d:chengji2009,23 duppath db d:chengji20092009doc.dat,00 msga1db please input xh:$ msga2db please input xm:$ msga3db please input sx:$ msga4db please input yw:$ msga5db please input wy:$ handle dw msgxh db xuehao: $ msgxm db xingming: $ msgsx db shuxue:$ msgyw db yuwen: $ msgwy db waiyu: $ buffer db 2048 dup msgrt db press any key to return!$ delstr db 33 dup datas endsstacks segment stack db 256 dup?stacks endscodes segment assume cs:codes,ds:datas,ss:stacksstart: mov ax,datas mov ds,ax;*;主程序 main proc fars:;清屏call cls ;逐行输出提示信息mov ah,02hmov dh,9mov dl,30int 10hmov ah,9lea dx,msg1int 21hmov ah,02hmov dh,10mov dl,30int 10hmov ah,9lea dx,msg2int 21hmov ah,02hmov dh,11mov dl,30int 10hmov ah,9lea dx,msg3int 21hmov ah,02hmov dh,12mov dl,30int 10hmov ah,9lea dx,msg4int 21hmov ah,02hmov dh,13mov dl,30int 10hmov ah,9lea dx,msg5int 21hmov ah,02hmov dh,14mov dl,30int 10hmov ah,9lea dx,msg6int 21h;提示输入mov ah,02hmov dh,15mov dl,30int 10hmov ah,9lea dx,msgcint 21h;从键盘读入一个数字mov ah,02hmov dh,15mov dl,48int 10hmov ah,1int 21h;按数字对应子程序cmp al,31hjz cappendcmp al,32hjz cdisplaycmp al,33hjz cmodifycmp al,34hjz cdeletecmp al,35hjz ccreatecmp al,36hjz e;若输入不是1-6数字,则提示错误mov ah,02hmov dh,16mov dl,30int 10hmov ah,9lea dx,msgeint 21hccreate:call createjmp scdelete:call deletejmp scmodify:call modifyjmp scdisplay:call displayjmp scappend:call appendjmp se: mov ah,4ch int 21hmain endp;*;create程序create proc nearpush axpush cxpush dxpush sipush di;清屏call cls;提示输入文件名mov ah,2mov dh,12mov dl,20int 10hmov ah,9lea dx,msgc1int 21h;从键盘读入文件名字符串mov ah,0ahlea dx,lenint 21h;将文件名字符串加到asciz字符串末尾mov cx,0mov cl,actlenlea si,stringlea di,pathnmadd di,16lcreate:mov al,byte ptr simov di,alinc diinc siloop lcreate;在asciz字符串末尾加00mov byte ptr di,0;按asciz字符串创建文件mov ah,3chlea dx,pathnmmov cx,0int 21hpop dipop sipop dxpop cxpop axretcreate endp;*;append程序append proc nearpush axpush bxpush cxpush dxpush sipush di;清屏call cls;打开文件只写mov ah,3dhmov al,01hlea dx,pathint 21hmov handle,ax;提示输入学号mov ah,02hmov dh,10mov dl,30int 10hmov ah,9lea dx,msga1int 21h;从键盘读入字符串mov ah,0ahlea dx,lenint 21h;在字符串末尾补足空格mov dx,4call fill;将文件指针定位至文件末尾mov ah,42hmov al,2mov bx,handlemov cx,0mov dx,0int 21h;写入文件mov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;提示输入姓名mov ah,02hmov dh,11mov dl,30int 10hmov ah,9lea dx,msga2int 21h;从键盘读入字符串mov ah,0ahlea dx,lenint 21h;在字符串末尾补足空格mov dx,15call fill;将文件指针定位至文件末尾mov ah,42hmov al,2mov bx,handlemov cx,0mov dx,0int 21h;写入文件mov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;提示输入语文成绩mov ah,02hmov dh,12mov dl,30int 10hmov ah,9lea dx,msga3int 21h;从键盘读入字符串mov ah,0ahlea dx,lenint 21h;在字符串末尾补足空格mov dx,3call fill;将文件指针定位至文件末尾mov ah,42hmov al,2mov bx,handlemov cx,0mov dx,0int 21h;写入文件mov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;提示输入数学成绩mov ah,02hmov dh,13mov dl,30int 10hmov ah,9lea dx,msga4int 21h;从键盘读入字符串mov ah,0ahlea dx,lenint 21h;在字符串末尾补足空格mov dx,3call fill;将文件指针定位至文件末尾mov ah,42hmov al,2mov bx,handlemov cx,0mov dx,0int 21h;写入文件mov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;提示输入外语成绩mov ah,02hmov dh,14mov dl,30int 10hmov ah,9lea dx,msga5int 21h;从键盘读入字符串mov ah,0ahlea dx,lenint 21h;在字符串末尾补足空格mov dx,3call fill;在字符串末尾加回车、换行inc simov byte ptr bx+si,0dhinc simov byte ptr bx+si,0ahadd actlen,2;将文件指针定位至文件末尾mov ah,42hmov al,2mov bx,handlemov cx,0mov dx,0int 21h;写入文件mov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;关闭文件mov ah,3ehmov bx,handleint 21hpop dipop sipop dxpop cxpop bxpop axretappend endp;*display proc nearpush axpush dx;清屏call cls;提示输入学号mov ah,02hmov dh,10mov dl,28int 10hmov ah,9lea dx,msgxhint 21h;从键盘读入学号字符串mov ah,0ahlea dx,lenint 21h;打开文件只读mov ah,3dhmov al,00hlea dx,pathint 21hmov handle,ax;将文件指针定位至文件开头mov ah,42hmov al,0mov bx,handlemov cx,0mov dx,0int 21h;将文件载入缓存mov ah,3fhmov bx,handlemov cx,2048lea dx,bufferint 21h;在缓存中找到对应记录lea si,bufferlea di,stringmov cx,axcall searchcmp dx,0jz output;若未找到,则提示错误mov ah,9lea dx,msgeint 21hjmp dend;显示对应信息output:mov ah,02hmov dh,11mov dl,28int 10hmov ah,9lea dx,msgxmint 21hadd si,5mov ah,9mov dx,siint 21hmov ah,02hmov dh,12mov dl,28int 10hmov ah,9lea dx,msgywint 21hadd si,16mov ah,9mov dx,siint 21hmov ah,02hmov dh,13mov dl,28int 10hmov ah,9lea dx,msgsxint 21hadd si,4mov ah,9mov dx,siint 21hmov ah,02hmov dh,14mov dl,28int 10hmov ah,9lea dx,msgwyint 21hadd si,4mov ah,9mov dx,siint 21hmov ah,2mov dh,15mov dl,28int 10hmov ah,9lea dx,msgrtint 21hmov ah,1int 21hdend:;关闭文件mov ah,3ehmov bx,handleint 21hpop dxpop axretdisplay endp;*modify proc nearpush axpush dx;清屏call cls;提示输入学号mov ah,02hmov dh,10mov dl,28int 10hmov ah,9lea dx,msgxhint 21h;从键盘读入学号字符串mov ah,0ahlea dx,lenint 21h;打开文件读写mov ah,3dhmov al,10lea dx,pathint 21hmov handle,ax;将文件指针定位至文件开头mov ah,42hmov al,0mov bx,handlemov cx,0mov dx,0int 21h;将文件载入缓存mov ah,3fhmov bx,handlemov cx,2048lea dx,bufferint 21h;在缓存中找到对应记录lea si,bufferlea di,stringmov cx,axcall searchcmp dx,0jz revisexm;若未找到,则提示错误mov ah,9lea dx,msgeint 21hjmp mend;修改姓名revisexm:mov ah,02hmov dh,11mov dl,28int 10hmov ah,9lea dx,msgxmint 21hmov ah,0ahlea dx,lenint 21hcmp byte ptr string,0dh ;若为回车,则将指针指向下一字段jnz xmcontadd si,5jmp reviseywxmcont:push simov dx,15call fillpop siadd si,5lea bx,buffermov dx,sisub dx,bxmov ah,42hmov al,00mov bx,handlemov cx,00int 21hmov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;修改语文成绩reviseyw:mov ah,02hmov dh,12mov dl,28int 10hmov ah,9lea dx,msgywint 21hmov ah,0ahlea dx,lenint 21hcmp byte ptr string,0dhjnz ywcontadd si,16jmp revisesxywcont:push simov dx,3call fillpop siadd si,16lea bx,buffermov dx,sisub dx,bxmov ah,42hmov al,00mov bx,handlemov cx,00int 21hmov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;修改数学成绩revisesx:mov ah,02hmov dh,13mov dl,28int 10hmov ah,9lea dx,msgsxint 21hmov ah,0ahlea dx,lenint 21hcmp byte ptr string,0dhjnz sxcontadd si,4jmp revisewysxcont:push simov dx,3call fillpop siadd si,4lea bx,buffermov dx,sisub dx,bxmov ah,42hmov al,00mov bx,handlemov cx,00int 21hmov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21h;修改外语成绩revisewy:mov ah,02hmov dh,14mov dl,28int 10hmov ah,9lea dx,msgwyint 21hmov ah,0ahlea dx,lenint 21hcmp byte ptr string,0dhjz mendpush simov dx,3call fillpop siadd si,4lea bx,buffermov dx,sisub dx,bxmov ah,42hmov al,00mov bx,handlemov cx,00int 21hmov ah,40hmov bx,handlemov cx,0mov cl,actlenlea dx,stringint 21hmend: ;关闭文件mov ah,3ehmov bx,handleint 21hpop dxpop axretmodify endp;*delete proc nearpush axpush dx;清屏call cls;提示输入姓名mov ah,02hmov dh,11mov dl,28int 10hmov ah,9lea dx,msga2int 21h;读入姓名字符串mov ah,0ahlea dx,len1int 21h;提示输入学号mov ah,02hmov dh,12mov dl,28int 10hmov ah,9lea dx,msga1int 21h;读入学号字符串mov ah,0ahlea dx,lenint 21h;打开文件读写mov ah,3dhmov al,10lea dx,pathint 21hmov handle,ax;将文件指针指向开头mov ah,42hmov al,0mov bx,handlemov cx,0mov dx,0int 21h;载入文件mov ah,3fhmov bx,handlemov cx,2048lea dx,bufferint 21h;在缓存中搜索学号对应记录lea si,bufferlea di,stringmov cx,axcall searchcmp dx,0jnz delend;比较该记录对应姓名是否与输入的相同push siadd si,5lea di,string1mov cx,0mov cl,actlen1mov dx,0lcheck:mov al,simov ah,dicmp al,ahjz lcontimov dx,1jmp delerrlconti:inc siinc diloop lcheckpop sicmp dx,0jz del;姓名不对应则提示错误delerr:mov ah,9lea dx,msgeint 21hjmp delenddel:;将文件指针定位至该记录开始处lea bx,buffermov dx,sisub dx,bxmov ah,42hmov al,00mov bx,handlemov cx,00int 21h;将该记录覆盖为空格mov ah,40hmov bx,handlemov cx,33lea dx,delstrint 21hdelend: ;关闭文件mov ah,3ehmov bx,handleint 21hpop dxpop axretdelete endp;*;清屏程序cls proc nearpush axpush bxpush cxpush dx;屏幕初始化mov ah,6mov al,0mov bh,7mov cx,0mov dx,2479hint 10h;重定位光标mov dx,0mov ah,2int 10hpop dxpop cxpop bxpop axretcls endp;*;搜索程序;若找到对应记录,则将dx赋为0,并将si指向该记录首地址;否则dx赋为1。search proc nearpush a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高中介绍孔子的课件
- 高三复课防疫知识培训课件
- 高一物理时间轴课件
- 离婚合同财产分割补充:子女抚养费及监护权调整
- 离婚协议书范本:财产分配及子女抚养权明确协议
- 离婚后房产共有权益及管理责任补充协议
- 离婚财产分割协议书:房产、车辆、存款等明细划分
- 广告物料设计代理执行合同
- 骨髓细胞检查课件
- 构建职业教育与产业对接机制的方案
- 2025年辅警面试考试试题库目(答案+解析)
- 解读《医务人员职业道德准则(2025年版)》(含准则全文)
- 23G409先张法预应力混凝土管桩
- 人教PEP版(一起)(2024)一年级上册英语全册教案(单元整体教学设计)
- 全国计算机等级考试(二级)考试题库附完整答案(典优)
- 下肢深静脉血栓及肺栓塞
- GB∕T 37303.6-2019 船舶和海上技术 船舶操纵性 第6部分:模型试验特殊要求
- 河南省地图含市县地图矢量分层地图行政区划市县概况ppt模板
- 绩效管理全套ppt课件(完整版)
- 幼儿园安全保卫“三防”工作实施方案
- 《创新方法TRIZ理论入门》课件04因果分析
评论
0/150
提交评论