1、接口课程设计出租车计价器信息科学与技术学院微机原理与接口技术课程设计报告 1.方案选择 11.1 题目: 11.2 要求: 12.程序设计与分析 12.1 功能设计 12.1.1 输出字符串宏 (str) 12.1.2 定义光标定位宏 12.1.3 清屏宏 (clearscreen) 12.1.4 延时模块 12.1.5 数字显示模块 22.1.6 数字自增模块 22.1.7 设置单价模块 22.2主程序设计 22.2.1 主函数 22.3字符串宏模块 32.3.1本设计的方法,计算公式 32.3.2本模块的流程图: 32.3.3本设计的重点、难点和解决方法 32.4字显示成数的形式的disp
2、子程序 42.5自加功能: 53.程序运行界面 65总结 66参考文献: 77附原程序: 81.方案选择1.1 题目:出租车计价器1.2 要求:1.计价功能2.手动设计单价3.显示里程、单价与总价4.据时间设定单价2.程序设计与分析2.1 功能设计2.1.1 输出字符串宏 (str) 功能:将字符串定义在宏里面,然后输出。2.1.2 定义光标定位宏 功能:指定光标的位置。2.1.3 清屏宏 (clearscreen)功能:设置开始和结尾的行列数以及属性。2.1.4 延时模块 功能:延缓每次显示的时间,使之能够准确的输出。2.1.5 数字显示模块 功能:显示所有的数字内容,其中包括行驶过程中的价
3、格,和里程的显示。在数据段中定义数字的格式,通过中断显示出数字能容。光标定位,使数字显示在指定的位置。2.1.6 数字自增模块 功能:设计程车每走100m,总价格增加0.2元,起步价为5元。此时在行驶的里程中,不断的加100m,当达到3km的时候,通过cx的判断,使价格从5元开始,每走100m加0.2元。需要用到延时程序,和跳转功能。2.1.7 设置单价模块 功能:手动设置单价,设定每公里要走的单价。在数据段定义后,每输入一次,通过取数据段的数据,完成定价的功能。2.2主程序设计2.2.1 主函数2.3字符串宏模块2.3.1本设计的方法,计算公式 显示字符串是本模块的功能,方法是将字符串传送到
4、dx中,然后用09中断输出。 2.3.2本模块的流程图:2.3.3本设计的重点、难点和解决方法 我认为本设计的重点和难点在于字符串的传送,解决方法在于用09输出和字符串的定义一起搭配使用。2.4字显示成数的形式的disp子程序2.5自加功能:3.程序运行界面5总结在这次的课程设计中,学到的知识有很多,收获也不小。可以从理论结合实际,可以把身边的一些所涉及到的编程工具自己也能够体会和学习一下。比如这次所做的计程车计价器。由于能力有限不能拿单片机或仿真的工具来做,只是用汇编基础的模拟了一下,其中也了解到了最基本的原理,锻炼了自己的基础知识水平。可以用到将来的实际应用当中。能够体会到其中的乐趣。但是
5、这次也有许多的问题,首先是自己的编程水平不好,所以做起来速度很慢,需要以后多多练习,实验。有些功能还没有能够实现,所以还需要进一步的学习,要学的知识还有很多,还应该花更多的精力在这些方面,这样才能够提高自己的专业水平。汇编语言和微机接口原理也是最基层的计算机语言和最接近硬件的,只有了解了这里的本质,才能更有效准确的运用其他工具。6参考文献: 1 IBM-PC汇编语言程序设计 沈美明 清华大学出版社 2001年8月第2版 2 IBM-PC汇编语言程序设计例题习题集沈美明 清华大学出版社 1991年6月第1版 3 微机系统和接口应用技术朱世鸿 著 清华大学出版社 2006年9月第1版 7附原程序:
6、data segment valuenum db 00,00,00,.,00,$;distance valuenum3 db 00,00,05,.,00,$;price num1 db total value,$ num2 db distance,$ num3 db km,$ num4 db yuan,$ stop db *press s to stop!,$ go_on db*press g to go on,$shuzi db _ ,0dh,0ah,$ db | |,0dh,0ah,$ db |_|,0dh,0ah,$ db ,0dh,0ah,$ db |,0dh,0ah,$ db |,0
7、dh,0ah,$ db _ ,0dh,0ah,$ db _|,0dh,0ah,$ db |_ ,0dh,0ah,$ db _ ,0dh,0ah,$ db _|,0dh,0ah,$ db _|,0dh,0ah,$ db ,0dh,0ah,$ db |_|,0dh,0ah,$ db |,0dh,0ah,$ db _ ,0dh,0ah,$ db |_ ,0dh,0ah,$ db _|,0dh,0ah,$ db _ ,0dh,0ah,$ db |_ ,0dh,0ah,$ db |_|,0dh,0ah,$ db _ ,0dh,0ah,$ db |,0dh,0ah,$ db |,0dh,0ah,$ db
8、_ ,0dh,0ah,$ db |_|,0dh,0ah,$ db |_|,0dh,0ah,$ db _ ,0dh,0ah,$ db |_|,0dh,0ah,$ db _|,0dh,0ah,$data endsposcurse macro dh1,dl1 ;定义光标定位宏 push ax push bx push dx mov ah,2h mov bh,0h mov dh,dh1 ;光标行坐标位置 mov dl,dl1 ;光标列坐标位置 int 10h ;mov ah,2h int 10h是10号中断的2号功能,设置光标位置 pop dx pop bx pop axendmcode segmen
9、tassume cS:code,ds:datamain proc far mov ax,data mov ds,ax clear macro aL1,bh1,ch1,cl1,dh1,dl1 MOV AH,06H ;初始化屏幕,10号中断的6号功能 mov aL,aL1 mov bh,bh1 mov ch,ch1 mov cl,cl1 mov dh,dh1 mov dl,dl1 INT 10H endm clear 0,01000000b,2,3,20,75 clear 0,00011110b,5,5,18,73 mov cx,0B: inc cx cmp cx,32 jz c ;不相等则跳转到
10、c call disp3 call delay call disp2 call delay call delay call inc_2 call delay mov ah,0bh int 21h inc al jnz b mov ah,01h int 21h cmp al,s jnz b jmp ac: clear 0,01000000b,2,3,20,75 clear 0,00011110b,5,5,18,73 call disp1;显示价格 call delay call inc_1;价格加2 call delay call disp2;显示里程 call delay call inc_2
11、;里程加2 call delay mov ah,0bh int 21h inc al jnz c mov ah,01h int 21h cmp al,s jnz c jmp am:jmp ba: mov ah,0bh int 21h inc al jnz a mov ah,01h int 21h cmp al,g jnz a mov al,valuenum cmp al,0 ja c mov al,valuenum+1 cmp al,0 ja c mov al,valuenum+2 cmp al,3 ja c cmp al,3 jnz m jmp cRETmain endp;-output子程
12、序-output proc near push ax mov ah,09h int 21h pop axretoutput endp;inc_1 子程序inc_1 proc near push ax mov al,valuenum3+4 inc al inc al mov valuenum3+4,al cmp al,0ah jnz return3 mov valuenum3+4,00h mov al,valuenum3+2 inc al mov valuenum3+2,al cmp al,0ah jnz return3 mov valuenum3+2,00h mov al,valuenum3+
13、1 inc al mov valuenum3+1,al cmp al,0ah jnz return3 mov valuenum3+1,00h mov al,valuenum inc al mov valuenum3,al cmp al,0ah jnz return3 mov valuenum3,00h return3:pop axretinc_1 endp;inc_2 子程序inc_2 proc near push ax mov al,valuenum+4 inc al mov valuenum+4,al cmp al,0ah jnz return mov valuenum+4,00h mov
14、 al,valuenum+2 inc al mov valuenum+2,al cmp al,0ah jnz return mov valuenum+2,00h mov al,valuenum+1 inc al mov valuenum+1,al cmp al,0ah jnz return mov valuenum+1,00h mov al,valuenum inc al mov valuenum,al cmp al,0ah jnz return mov valuenum,00h return:pop axretinc_2 endp ;-delay子程序-delay proc near pus
15、h bx push ax push cx mov bl,75dwaitf2: mov cx,1000d waitf1: in al,61h and al,10h cmp al,ah je waitf1 mov ah,al loop waitf1 dec bl cmp bl,0 jnz waitf2 pop cx pop ax pop bx ret delay endp;-disp1子程序, 从5开始显示-disp1 proc near lea dx,num1 poscurse 09h,6h ;坐标位置 call output ;输出num1里面的字符串 lea dx,num2 poscurse
16、 0ch,08h call output lea dx,num3 poscurse 0ch,23h call output lea dx,num4 poscurse 09h,23h call output lea dx,stop poscurse 12h,06h call output lea dx,go_on poscurse 12h,30h mov ah,09h ;显示dx寄存器地址中的字符串 int 21h mov al,valuenum3 mov bl,12h mul bl mov dx,offset shuzi poscurse 07h,13h add dx,ax call outp
17、ut poscurse 08h,13h add dx,06h call output poscurse 09h,13h add dx,06h call output poscurse 07h,16h mov al,valuenum3+1 mov bl,12h mul bl mov dx,offset shuzi poscurse 07h,16h add dx,ax call output poscurse 08h,16h add dx,06h call output poscurse 09h,16h add dx,06h call output poscurse 07h,19h mov al,
18、valuenum3+2 mov bl,12h mul bl mov dx,offset shuzi poscurse 07h,19h add dx,ax call output poscurse 08h,19h add dx,06h call output poscurse 09h,19h add dx,06h call output poscurse 09h,1ch mov dl,2eh mov ah,02h ;调用系统时间 int 21h poscurse 07h,1eh mov al,valuenum3+4 mov bl,12h mul bl mov dx,offset shuzi po
19、scurse 07h,1eh add dx,ax call output poscurse 08h,1eh add dx,06h call output poscurse 09h,1eh add dx,06h call output ret disp1 endp;-disp2子程序-disp2 proc near push ax mov al,valuenum mov bl,12h mul bl mov dx,offset shuzi poscurse 0ah,13h add dx,ax call output poscurse 0bh,13h add dx,06h call output p
20、oscurse 0ch,13h add dx,06h call output poscurse 0ah,16h mov al,valuenum+1 mov bl,12h mul bl mov dx,offset shuzi poscurse 0ah,16h add dx,ax call output poscurse 0bh,16h add dx,06h call output poscurse 0ch,16h add dx,06h call output poscurse 0ah,19h mov al,valuenum+2 mov bl,12h mul bl mov dx,offset sh
21、uzi poscurse 0ah,19h add dx,ax call output poscurse 0bh,19h add dx,06h call output poscurse 0ch,19h add dx,06h call output poscurse 0ch,1ch mov dl,2eh mov ah,02h int 21h poscurse 0ah,1eh mov al,valuenum+4 mov bl,12h mul bl mov dx,offset shuzi poscurse 0ah,1eh add dx,ax call output poscurse 0bh,1eh a
22、dd dx,06h call output poscurse 0ch,1eh add dx,06h call output pop axret disp2 endp;-disp3子程序-disp3 proc near lea dx,num1 ;取num的地址送dx poscurse 09h,6h mov ah,09h int 21h lea dx,num2 poscurse 0ch,8h mov ah,09h int 21h lea dx,num3 poscurse 0ch,23h call output lea dx,num4 poscurse 09h,23h call output lea
23、 dx,stop poscurse 12h,06h mov ah,09h int 21h lea dx,go_on poscurse 12h,30h call output mov al,valuenum3 mov bl,12h mul bl mov dx,offset shuzi poscurse 07h,13h add dx,ax call output poscurse 08h,13h add dx,06h call output poscurse 09h,13h add dx,06h call output poscurse 07h,16h mov al,valuenum3+1 mov
24、 bl,12h mul bl mov dx,offset shuzi poscurse 07h,16h add dx,ax call output poscurse 08h,16h add dx,06h call output poscurse 09h,16h add dx,06h call output poscurse 07h,19h mov al,valuenum3+2 mov bl,12h mul bl mov dx,offset shuzi poscurse 07h,19h add dx,ax call output poscurse 08h,19h add dx,06h call
25、output poscurse 09h,19h add dx,06h call output poscurse 09h,1ch mov dl,2eh mov ah,02h int 21h poscurse 07h,1eh mov al,valuenum3+4 mov bl,12h mul bl mov dx,offset shuzi poscurse 07h,1eh add dx,ax call output poscurse 08h,1eh add dx,06h call output poscurse 09h,1eh add dx,06h call output ret disp3 endp code ends end main
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1