《微型计算机原理及其应用》课程设计.doc_第1页
《微型计算机原理及其应用》课程设计.doc_第2页
《微型计算机原理及其应用》课程设计.doc_第3页
《微型计算机原理及其应用》课程设计.doc_第4页
《微型计算机原理及其应用》课程设计.doc_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

课 程 设 计 课程名称 微机课程设计 题目名称_ 计算器 学生学院_ _ 自动化_专业班级_ 13自动化()班_ 学 号 学生姓名_ _ _指导教师_ _ _2015 年 12月30日实验任务.一.目的1 巩固和加深对微机原理及应用课程内容的认识和理解,提高应用水平;2 掌握汇编语言程序的编程方法;3 熟悉键盘控制和七段数码管的使用。二.设计要求课程设计内容上机编程:1 在显示器上显示任意六位十六进制数;2 将8个键按实验室要求定义键值,按任意键在显示器上显示对应键值,要求显示值能左移;3 实现:a) 定义键盘按键,12个为数字键1E,4个功能键:加号,除号,等号,CLEAR 清零键;b) 可进行四位10进制加法运算;c) 可进行四位16进制除法运算。4 电路框图5.课程设计报告目录1.程序一41.1问题:41.2代码:42.程序二42.1问题:52.2代码:53.程序一93.1问题:93.2代码:9二、系统设计说明21三、程序流程设计图21四、个人总结22附录:231.程序一1.1问题:在显示器上显示以下六位十六进制数:1 D 3 B 5 C1.2代码:STACK SEGMENT STACK DW 64 DUP(?)STACK ENDSDATA SEGMENTTABLEDB3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H ;TABLE DB 0FCH,60H,0DAH,0F2H,66H,0B6H,0BEH,0E0H; DB 0FEH,0E6H,0EEH,2EH,9CH,7AH,9EH,8EH ;设置0F数码管段码VA1 DB 01H,0DH,03H,0BH,05H,0CH DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATA ;8255初始化 MOV DS,AX MOV DX,0606H ;信号线设为IOY0 MOV AL,90H ;端口A、B为输出 OUT DX,AL ;DX为控制端口地址A1: LEA SI,VA1 MOV CX,0006H MOV AL,0FBH ;11111011A2: MOV DX,0604H OUT DX,AL ;B口上拉? PUSH AX ;利用AX移位 MOV BX,OFFSET TABLE MOV AL,SI XLAT ; 把以DS:BX+AL为地址的待查表格的一个字节内容送到AL累加器中。 ;在执行该指令前,将数据表偏移址送BX中,将待查字节在数据表的偏移指针送AL MOV DX,0602H OUT DX,AL ;查表代码送C口显示 INC SI ;SI+1 CALL DALLY POP AX ROL AL,1 LOOP A2 JMP A1DALLY: PUSH CX ;延时MOV CX,0002HA3: MOV AX,00FFHA4: DEC AX JNZ A4 LOOP A3 POP CX RETCODE ENDSEND START2.程序二2.1问题:将8个键按实验室要求定义键值,按任意键在显示器上显示对应键值,要求显示值能左移;D62E5F102.2代码:STACK SEGMENT STACKDW 32 DUP(?)STACK ENDSDATA SEGMENTVA1DB7FH,0BFH,0DFH,0EFH,0F7H,0FBH;VA1DB0FBH,0F7H,0EFH,0DFH,0BFH,7FH;VA1 DB 0DFH,0EFH,0F7H,0FBH,0FDH,0FEHVA2 DB 00H,00H,00H,00H,00H,00HTABLE DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71HDATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV AL,90H MOV DX,0606H OUT DX,AL MOV BX,0000H STT: MOV AL,00H MOV DX,0604H OUT DX,AL MOV DX,0600H IN AL,DX AND AL,0CH CMP AL,0CH; AND AL,0C6H; CMP AL,0C6H JNZ KEYXD CALL DISP JMP STT KEYXD:CALL TIME MOV DX,0600H IN AL,DX AND AL,0CH CMP AL,0CH; AND AL,0C6H; CMP AL,0C6H JNZ KEY_JIAN JMP STT KEY_JIAN:MOV DX,0604H MOV AL,0FBH OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,04H JNZ KEY_D CALL KEY5 JMP STTK KEY_D: TEST AL,08H JNZ KEY_F CALL KEYD JMP STTK KEY_F: MOV DX,0604H MOV AL,0F7H OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,04H JNZ KEY_6 CALL KEYF JMP STTK KEY_6: TEST AL,08H JNZ KEY_1 CALL KEY6 JMP STTK KEY_1: MOV DX,0604H MOV AL,0EFH OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,04H JNZ KEY_2 CALL KEY1 JMP STTKKEY_2: TEST AL,08H JNZ KEY_0 CALL KEY2 JMP STTKKEY_0: MOV DX,0604H MOV AL,0DFH OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,04H JNZ KEY_E CALL KEY0 JMP STTKKEY_E: TEST AL,08H JNZ ABC CALL KEYE ABC: JMP STTK;-KEY0: CALL LP1 MOV AL,3FH;- MOV DI+5,AL CALL DISP RET KEY1: CALL LP1 MOV AL,06H;- MOV DI+5,AL CALL DISP RET KEY2: CALL LP1 MOV AL,5BH;- MOV DI+5,AL CALL DISP RET KEY5: CALL LP1 MOV AL,6DH;- MOV DI+5,AL CALL DISP RETKEY6: CALL LP1 MOV AL,7DH;- MOV DI+5,AL CALL DISP RET KEYD: CALL LP1MOVAL,5EH; ;MOV AL,0DH;- MOV DI+5,AL CALL DISP RET KEYE: CALL LP1 MOV AL,79H;- MOV DI+5,AL CALL DISP RET KEYF: CALL LP1 MOV AL,71H;- MOV DI+5,AL CALL DISP RET ;- ;-LP1: MOV DI,OFFSET VA2 MOV CX,0005H LP2: MOV AL,DI+4 MOV DI+5,AL DEC SI DEC DI LOOP LP2 RETDISP: MOV SI,OFFSET VA1 MOV DI,OFFSET VA2 MOV BX,OFFSET TABLE MOV DL,DI+5 CMP DL,3FH JNZ DIR5 MOV DL,DI+4 CMP DL,3FH JNZ DIR4 MOV DL,DI+3 CMP DL,3FH JNZ DIR3 MOV DL,DI+2 CMP DL,3FH JNZ DIR2 MOV DL,DI+1 CMP DL,3FH JNZ DIR1 JMP DIR0DIR5: MOV CX,0006H JMP DIRDIR4: MOV CX,0005H JMP DIR DIR3: MOV CX,0004H JMP DIR DIR2: MOV CX,0003H JMP DIRDIR1: MOV CX,0002H JMP DIR DIR0: MOV CX,0001HDIR : MOV DX,0604H MOV AL,SI OUT DX,AL MOV DX,0602H MOV AL,DI OUT DX,AL CALL TIME INC SI INC DI LOOP DIR RETTIME : PUSH AX PUSH CX MOV CX,0005HTIME1: MOV AX,00F0HTIME2: DEC AX JNZ TIME2 LOOP TIME1 POP CX POP AX RET;-STTK: CALL DISP MOV AL,00H MOV DX,0604H OUT DX,AL MOV DX,0600H IN AL,DX AND AL,0CH CMP AL,0CH JNZ STTK JMP STT CODE ENDS END START 3.程序一3.1问题:实现:a) 定义键盘按键,12个为数字键1E,4个功能键:加号,除号,等号,CLEAR 清零键;b) 可进行四位10进制加法运算;c) 可进行四位16进制除法运算。3.2代码:STACK SEGMENT STACKDW 32 DUP(?)STACK ENDSDATA SEGMENTVA2 DB 0FCH,0FCH,0FCH,0FCH,0FCH,0FCH;检测非0VA1 DB 7FH,0BFH,0DFH,0EFH,0F7H,0FBH;位选VA3 DB 00H,00H,00H,00H,00H,00HVA4 DB 00H,00H,00H,00H,00H,00HTABLE DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H;0-F的显示段选DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV AL,90H MOV DX,0606H OUT DX,AL MOV BX,0000H;初始化8255 CALL CLEAR STT: MOV AL,00H MOV DX,0604H OUT DX,AL MOV DX,0600H IN AL,DX AND AL,0FH;检测是否按键按下 CMP AL,0FH JNZ KEYXD CALL DISP JMP STT KEYXD:CALL TIME;消除抖动 MOV DX,0600H IN AL,DX AND AL,0FH CMP AL,0FH JNZ KEY_JIAN JMP STT KEY_JIAN:MOV DX,0604H;确认有按键按下 MOV AL,0FBH;输入X1为0 OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,01H;检测Y4高低 JNZ KEY_2;高的话跳 CALL KEY3;低直接确定是KEY3 JMP STTK KEY_2: TEST AL,02H;检测Y3 JNZ KEY_1 CALL KEY2 JMP STTKKEY_1: TEST AL,04H;检测Y2 JNZ KEY_CLEAR CALL KEY1 JMP STTKKEY_CLEAR: TEST AL,08H;检测Y1 JNZ KEY_7 CALL KEYCLEAR JMP STTK KEY_7: MOV DX,0604H MOV AL,0F7H;输入X2为0 OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,01H JNZ KEY_6 CALL KEY7 JMP STTK KEY_6: TEST AL,02H JNZ KEY_5 CALL KEY6 JMP STTK KEY_5: TEST AL,04H JNZ KEY_4 CALL KEY5 JMP STTK KEY_4: TEST AL,08H JNZ KEY_D CALL KEY4 JMP STTK KEY_D: MOV DX,0604H MOV AL,0EFH;输入X3为0 OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,01H JNZ KEY_B CALL KEYD JMP STTKKEY_B: TEST AL,02H JNZ KEY_9 CALL KEYB JMP STTK KEY_9: TEST AL,04H JNZ KEY_8 CALL KEY9 JMP STTKKEY_8: TEST AL,08H JNZ KEY_E CALL KEY8 JMP STTKKEY_E: MOV DX,0604H MOV AL,0DFH;输入X4为0 OUT DX,AL MOV DX,0600H IN AL,DX TEST AL,01H JNZ KEY_DIV CALL KEYE JMP STTK KEY_DIV: TEST AL,02H JNZ KEY_DENG CALL KEYDIV JMP STTKKEY_DENG: TEST AL,04H JNZ KEY_ADD CALL KEYDENG JMP STTKKEY_ADD: TEST AL,08H JNZ ABC CALL KEYADD ABC: JMP STTK;- KEY1: CMP BH,00H JZ KEY1_1 CALL CLEAR KEY1_1:CALL LP1 MOV AL,06H;段选 MOV SI+5,AL MOV AL,01H;位选- MOV DI+5,AL CALL DISP RET KEY2: CMP BH,00H JZ KEY2_1 CALL CLEAR KEY2_1:CALL LP1 MOV AL,5BH;- MOV SI+5,AL MOV AL,02H;- MOV DI+5,AL CALL DISP RET KEY3: CMP BH,00H JZ KEY3_1 CALL CLEAR KEY3_1:CALL LP1 MOV AL,4FH;- MOV SI+5,AL MOV AL,03H;- MOV DI+5,AL CALL DISP RET KEY4: CMP BH,00H JZ KEY4_1 CALL CLEAR KEY4_1:CALL LP1 MOV AL,66H;- MOV SI+5,AL MOV AL,04H;- MOV DI+5,AL CALL DISP RET KEY5: CMP BH,00H JZ KEY5_1 CALL CLEAR KEY5_1:CALL LP1 MOV AL,6DH;- MOV SI+5,AL MOV AL,05H MOV DI+5,AL CALL DISP RET KEY6: CMP BH,00H JZ KEY6_1 CALL CLEAR KEY6_1:CALL LP1 MOV AL,7DH;- MOV SI+5,AL MOV AL,06H MOV DI+5,AL CALL DISP RET KEY7: CMP BH,00H JZ KEY7_1 CALL CLEAR KEY7_1:CALL LP1 MOV AL,07H;- MOV SI+5,AL MOV AL,07H MOV DI+5,AL CALL DISP RET KEY8: CMP BH,00H JZ KEY8_1 CALL CLEAR KEY8_1:CALL LP1 MOV AL,7FH;- MOV SI+5,AL MOV AL,08H MOV DI+5,AL CALL DISP RET KEY9: CMP BH,00H JZ KEY9_1 CALL CLEAR KEY9_1:CALL LP1 MOV AL,6FH;- MOV SI+5,AL MOV AL,09H MOV DI+5,AL CALL DISP RET KEYB: CMP BH,00H JZ KEYB_1 CALL CLEAR KEYB_1:CALL LP1 MOV AL,7CH;- MOV SI+5,AL MOV AL,0BH MOV DI+5,AL CALL DISP RET KEYD: CMP BH,00H JZ KEYD_1 CALL CLEAR KEYD_1:CALL LP1 MOV AL,5EH;- MOV SI+5,AL MOV AL,0DH MOV DI+5,AL CALL DISP RET KEYE: CMP BH,00H ;按键等号 JZ KEYE_1 CALL CLEAR KEYE_1:CALL LP1 MOV AL,79H;- MOV SI+5,AL MOV AL,0EH MOV DI+5,AL CALL DISP RET KEYADD:CMP BH,00H;+号按键 JNZ KEYADD_1 CALL LP3KEYADD_1:MOV BX,0102H;标志BX0102H代表加法 RETKEYDIV:CMP BH,00H;/号按键 JNZ KEYDIV_1 CALL LP3KEYDIV_1:MOV BX,0103H;标志BX为0103H代表除法 RET KEYDENG:MOV BH,01H;等号功能 CMP BL,02H JZ K1 CMP BL,03H JZ K2 STTE: RETK1: CALL ADD1 JMP STTEK2: CALL DIV1 JMP STTE;- ADD1: MOV AX,0000H;加法功能子函数 LEA SI,VA3 LEA DI,VA4 MOV CX,0006H CLC ADD1_1: MOV AL,DI ADC AL,SI AAA MOV DI,AL INC SI INC DI LOOP ADD1_1 CALL CHANGE CALL DISP RET ;-DIV1:;除法功能子函数 PUSH AX;除法子程序 PUSH BX PUSH DX MOV SI,OFFSET VA3 MOV DI,OFFSET VA4 MOV AH,00H MOV CL,4;被除数 MOV AL,DI+3 ROL AX,CL ADD AL,DI+2 ROL AX,CL ADD AL,DI+1 ROL AX,CL ADD AL,DI MOV BH,00H;除数 MOV BL,SI+3 ROL BX,CL ADD BL,SI+2 ROL BX,CL ADD BL,SI+1 ROL BX,CL ADD BL,SI MOV DX,0000H DIV BX MOV BX,AX;处理商 AND BX,000FH MOV DI,BL MOV BX,AX MOV CL,4H SHR BX,CL AND BX,000FH MOV DI+1,BL MOV BX,AX MOV CL,8H SHR BX,CL AND BX,000FH MOV DI+2,BL MOV BX,AX MOV CL,0CH SHR BX,CL AND BX,0007H MOV DI+3,BL CALL CHANGE CALL DISP POP DX POP BX POP AX RET;- KEYCLEAR:;clear键功能子函数 CALL CLEAR RETCLEAR: LEA SI,VA2 LEA DI,VA3 MOV CX,0006HCLEAR1:MOV AL,3FH;修改整个数组为0 MOV SI,AL MOV AL,00H MOV DI,AL INC SI INC DI LOOP CLEAR1 MOV BH,00H RET ;-LP1: ;SIDI前一位赋值给后一位从而插入新数据不会覆盖前面的数据 MOV SI,OFFSET VA2 MOV DI,OFFSET VA3 MOV CX,0005H LP2: MOV AL,SI+4 MOV SI+5,AL MOV AL,DI+4 MOV DI+5,AL DEC SI DEC DI LOOP LP2 RET LP3: MOV CX,0006H MOV SI,OFFSET VA3 MOV DI,OFFSET VA4 LP4: MOV AL,SI MOV DI,AL INC SI INC DI LOOP LP4 RET CHANGE:;把表里十六进制的值转化为数码管显示的对应的16进制 MOV SI,OFFSET VA2 MOV DI,OFFSET VA4 MOV BX,OFFSET TABLE MOV CX,0006HCOMP0: MOV AL,DI XLAT MOV SI,AL INC SI INC DI LOOP COMP0 RETDISP: MOV SI,OFFSET VA1;显示DISPLAY子函数 MOV DI,OFFSET VA2 MOV DL,DI+5 CMP DL,3FH JNZ DIR5 MOV DL,DI+4 CMP DL,3FH JNZ DIR4 MOV DL,DI+3 CMP DL,3FH JNZ DIR3 MOV DL,DI+2 CMP DL,3FH JNZ DIR2 MOV DL,DI+1 CMP DL,3FH JNZ DIR1 JMP DIR0DIR5: MOV CX,0006H JMP DIRDIR4: MOV CX,0005H JMP DIR DIR3: MOV CX,0004H JMP DIR DIR2: MOV CX,0003H JMP DIRDIR1: MOV CX,0002H JMP DIR DIR0: MOV CX,0001HDIR : MOV DX,0604H MOV AL,SI OUT DX,AL MOV DX,0602H MOV AL,DI OUT DX,AL CALL TIME INC SI INC DI LOOP DIR RETTIME : PUSH AX;延时子函数 PUSH

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论