微机原理课程设计-万年历(共14页).docx
精选优质文档-倾情为你奉上微机原理课程设计万年历的制作目录实验目的·························································(3)实验内容·························································(3)实验流程图·······················································(3)实验程序·························································(5)调试结果························································(11)心得体会·························································(14)实验目的:结合微型计算机原理课程的学习,进一步巩固已学习的知识,同时针对微型计算机原理知识的具体应用,学会对系统中的DOS和BIOS的使用。学会使用编写软件EDIT,弄懂汇编程序的上机过程以及如何运用DEBUG软件进行汇编程序的调试。通过单步调试,加深对汇编语言的内容了解。实验内容:接受年月日信息并显示,编写程序,先显示“What is the data?”,并响铃一次,然后再显示year,接收键盘输入的年,输入正确后,显示month,从键盘输入月,输入正确后,再显示day,从键盘输入日期的信息,并显示。对于时间的算法,闰年时,二月有29天,而平年,二月有28天,其它月份有30天或是31天。若输入年月日时产生错误,警告并重新输入。实验流程图:入口段寄存器初始化和堆栈初始化显示“What is the data?”输出响铃,延迟1s调用getnum,接收键入的年,月,日信息调用dispyear,显示年输出字符“-”调用dispmonth,显示月输出字符“-”调用dispday,显示日返回DOS子程序getnum流程图:入口输入年份四位XXXX错误信息年份输入是否合理?Y输入月份二位XXN月份输入是否合理?错误信息Y日期输入二位XXN输入合理?错误信息YN是二月份?YN是闰年吗?Y日期输入合理N日期输入合理吗NYY返回实验程序:assume cs:code,ds:datadata segmentcr equ 0dhlf equ 0ahstring1 db 'What is the data?','$'string2 db cr,lf,'Year :','$'string3 db cr,lf,'Month :','$'string4 db cr,lf,'Day :','$'string5 db cr,lf,'ERROR! Input again:','$' buff1 db 5 db ? db 5 dup(?) buff2 db 3 db ? db 3 dup(?) buff3 db 3 db ? db 3 dup(?) data endscode segment start:mov ax,data mov ds,ax mov dx,offset string1 mov ah,9 int 21h call delay call warning call delay call getnum mov dl,0dh mov ah,02h int 21h mov dl,0ah mov ah,02h int 21h call dispyear mov dl,'-' mov ah,02h int 21h call dispmonth mov dl,'-' mov ah,02h int 21h call dispday mov ax,4c00h int 21hgetnum proc near repea0:mov dx,offset string2 mov ah,9 int 21h mov dx,offset buff1 mov ah,0ah int 21h mov cx,4 mov si,offset buff1 inc si check:inc si mov al,si sub al,30h mov ah,0h cmp ax,9h ja repea cmp ax,0h jb repea loop checkmov si,offset buff1mov ah,'$'mov si+6,ahjmp repeat0 repea:call error call warningjmp repea0 repeat0:mov dx,offset string3 mov ah,9 int 21h mov dx,offset buff2 mov ah,0ah int 21h mov si,offset buff2 call address cmp al,0dh jz repeat01 cmp ax,12h ja repeat01 cmp ax,0 jbe repeat01mov si,offset buff2mov ah,'$'mov si+4,ahjmp repeat1repeat01:call errorcall warningjmp repeat0repeat1:mov dx,offset string4 mov ah,9 int 21h mov dx,offset buff3 mov ah,0ah int 21h mov si,offset buff3 call address cmp ax,31h ja repeat11 cmp ax,0 jbe repeat11 mov si,offset buff2 call address cmp ax,2h jz feb mov dl,2 div dl cmp ah,0h jz doumonth mov si,offset buff2 call address cmp ax,8h ja downmonth1 jmp overdoumonth:mov si,offset buff2 call address cmp ax,7h ja downmonth2 mov si,offset buff3 call address cmp ax,31h jz repeat11 jmp overdownmonth2:jmp overrepeat11:call errorcall warningjmp repeat1 downmonth1:mov si,offset buff3 call address cmp ax,31h jz repeat11 jmp over feb:mov si,offset buff1 inc si inc si mov dx,si sub dh,30h sub dl,30h mov cl,4 rol dl,cl add dl,dh mov dh,0 mov cl,8 rol dx,cl call address cmp ax,0 jz hundard add ax,dxmov bl,alnextdiv:mov al,ah mov ah,0 mov cl,4 div cl add ah,2 cmp ah,3 ja nextdiv mov al,bladd al,2 div cl cmp ah,0h jz leapyearcommonyear:mov si,offset buff3 call address cmp ax,28h ja repeat11 cmp ax,0 jbe repeat11 jmp overleapyear:mov si,offset buff3 call address cmp ax,29h ja repeat11 cmp ax,0 jbe repeat11 jmp over hundard:mov al,dh mov ah,0 add ax,2 mov dl,4 div dl cmp ah,0h jz leapyear jmp commonyear over:mov si,offset buff3mov ah,'$'mov si+4,ahret getnum endpdispyear proc near mov dx,offset buff1 inc dx inc dx mov ah,9 int 21h retdispyear endpdispmonth proc near mov dx,offset buff2 inc dx inc dx mov ah,9 int 21h retdispmonth endpdispday proc near mov dx,offset buff3 inc dx inc dx mov ah,9 int 21h retdispday endpaddress proc nearinc si inc si mov ax,si sub ah,30h sub al,30h mov cl,4 rol al,cl add al,ah mov ah,0 retaddress endpdelay proc near push ax push dx mov dx,5020h;近1秒 mov ax,0 s1:sub ax,1 sbb dx,0 cmp ax,0 jne s1 cmp dx,0 jne s1 pop dx pop ax retdelay endp error proc nearpush dxpush axmov dx,offset string5mov ah,9int 21hpop axpop dxreterror endp warning proc nearpush dxpush axmov dl,07h mov ah,2 int 21h pop ax pop dx retwarning endp code endsend start调试结果:响铃前:响铃后:输入实例:输入错误信息:心得体会:通过短短几天的课程设计,让我重新拿起已经学习的微机原理理论知识。相比一年前的程序的编写,现在的我,对于程序的流程理解和汇编语言的运用,更加灵活,更加通顺,渐渐的得心应手。相比较单片机的课程设计而言,我更加喜欢微机原理的编程设计,感觉它功能更加强大,特点鲜明,还可以单步调试,类似顺序执行的程序化语言的让我不由自主的爱上它,喜欢去编程,而单片机的运行,各个模块之间相互调用,总是给人一种摸不到头绪,杂乱无章的感觉。但是,另一方面,短暂的课程设计,不得不给人留下很多的遗憾。首先,十三个题目,做起来非常多,假如只选四个,又会放弃很多有用的功能,要想每一个均独立完成,并都做到尽善尽美,花的时间远远不止是四天的时间,需要平时,课下的钻研,体会,实践,只有这样,才能体会汇编语言的强大。然后,课程设计的内容丰富,有许多平时不能接触到的,但非常常用的功能,而这些功能,在短时间内不能尽快掌握。这又不的不说是一件遗憾的事情。总的来说,课程设计给予我们的收获远远不止是上课时学习到的。理论知识固然很重要,但是不要实践亲自检验,给人的感觉总是不深刻的,只有亲自动手去探索,去体会,将理论知识加以应用并及时巩固,才可以学习的更快,才可以激发人的学习兴趣,并不断去探索,只有真正脱离应试模式,不只依靠老师的帮助,才能让我们的学习更加持久,更加具有创造力与生命力。专心-专注-专业