已閱讀5頁,還剩18頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
課 程 設(shè) 計 課程名稱 微機(jī)課程設(shè)計 題目名稱_ 計算器 學(xué)生學(xué)院_ _ 自動化_專業(yè)班級_ 13自動化()班_ 學(xué) 號 學(xué)生姓名_ _ _指導(dǎo)教師_ _ _2015 年 12月30日實驗任務(wù).一.目的1 鞏固和加深對微機(jī)原理及應(yīng)用課程內(nèi)容的認(rèn)識和理解,提高應(yīng)用水平;2 掌握匯編語言程序的編程方法;3 熟悉鍵盤控制和七段數(shù)碼管的使用。二.設(shè)計要求課程設(shè)計內(nèi)容上機(jī)編程:1 在顯示器上顯示任意六位十六進(jìn)制數(shù);2 將8個鍵按實驗室要求定義鍵值,按任意鍵在顯示器上顯示對應(yīng)鍵值,要求顯示值能左移;3 實現(xiàn):a) 定義鍵盤按鍵,12個為數(shù)字鍵1E,4個功能鍵:加號,除號,等號,CLEAR 清零鍵;b) 可進(jìn)行四位10進(jìn)制加法運算;c) 可進(jìn)行四位16進(jìn)制除法運算。4 電路框圖5.課程設(shè)計報告目錄1.程序一41.1問題:41.2代碼:42.程序二42.1問題:52.2代碼:53.程序一93.1問題:93.2代碼:9二、系統(tǒng)設(shè)計說明21三、程序流程設(shè)計圖21四、個人總結(jié)22附錄:231.程序一1.1問題:在顯示器上顯示以下六位十六進(jìn)制數(shù):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 ;設(shè)置0F數(shù)碼管段碼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 ;信號線設(shè)為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為地址的待查表格的一個字節(jié)內(nèi)容送到AL累加器中。 ;在執(zhí)行該指令前,將數(shù)據(jù)表偏移址送BX中,將待查字節(jié)在數(shù)據(jù)表的偏移指針?biāo)虯L 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個鍵按實驗室要求定義鍵值,按任意鍵在顯示器上顯示對應(yīng)鍵值,要求顯示值能左移;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問題:實現(xiàn):a) 定義鍵盤按鍵,12個為數(shù)字鍵1E,4個功能鍵:加號,除號,等號,CLEAR 清零鍵;b) 可進(jìn)行四位10進(jìn)制加法運算;c) 可進(jìn)行四位16進(jìn)制除法運算。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;確認(rèn)有按鍵按下 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;標(biāo)志BX0102H代表加法 RETKEYDIV:CMP BH,00H;/號按鍵 JNZ KEYDIV_1 CALL LP3KEYDIV_1:MOV BX,0103H;標(biāo)志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;加法功能子函數(shù) 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:;除法功能子函數(shù) PUSH AX;除法子程序 PUSH BX PUSH DX MOV SI,OFFSET VA3 MOV DI,OFFSET VA4 MOV AH,00H MOV CL,4;被除數(shù) 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;除數(shù) 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鍵功能子函數(shù) CALL CLEAR RETCLEAR: LEA SI,VA2 LEA DI,VA3 MOV CX,0006HCLEAR1:MOV AL,3FH;修改整個數(shù)組為0 MOV SI,AL MOV AL,00H MOV DI,AL INC SI INC DI LOOP CLEAR1 MOV BH,00H RET ;-LP1: ;SIDI前一位賦值給后一位從而插入新數(shù)據(jù)不會覆蓋前面的數(shù)據(jù) 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:;把表里十六進(jìn)制的值轉(zhuǎn)化為數(shù)碼管顯示的對應(yīng)的16進(jìn)制 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子函數(shù) 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;延時子函數(shù) PUSH
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024-2030年中國學(xué)校家具行業(yè)發(fā)展現(xiàn)狀及前景規(guī)劃研究報告
- 2024-2030年中國嬰兒洗護(hù)用品市場運行動態(tài)及前景趨勢預(yù)測報告
- 2024-2030年中國女性洗液行業(yè)市場營銷模式及發(fā)展前景預(yù)測報告
- 2024-2030年中國多型腔熱流道管坯模具境外融資報告
- 2024年標(biāo)準(zhǔn)簡易個人魚塘承包合同模板版B版
- 梅河口康美職業(yè)技術(shù)學(xué)院《高級語言程序?qū)嵺`》2023-2024學(xué)年第一學(xué)期期末試卷
- 茂名職業(yè)技術(shù)學(xué)院《語文教學(xué)設(shè)計與實施》2023-2024學(xué)年第一學(xué)期期末試卷
- 微專題定量測定型實驗突破策略-2024高考化學(xué)一輪考點擊破
- 呂梁職業(yè)技術(shù)學(xué)院《生物學(xué)科專業(yè)導(dǎo)論》2023-2024學(xué)年第一學(xué)期期末試卷
- 2024年某科技公司與某航空公司關(guān)于機(jī)載娛樂系統(tǒng)的合同
- 壟斷行為的定義與判斷準(zhǔn)則
- 模具開發(fā)FMEA失效模式分析
- 聶榮臻將軍:中國人民解放軍的奠基人之一
- 材料化學(xué)專業(yè)大學(xué)生職業(yè)生涯規(guī)劃書
- 乳品加工工(中級)理論考試復(fù)習(xí)題庫(含答案)
- 《教材循環(huán)利用》課件
- 學(xué)生思想政治工作工作證明材料
- 2023水性環(huán)氧樹脂涂層鋼筋
- 湘少版六年級英語上冊《Unit 12 第二課時(Part CPart D)》課堂教學(xué)課件公開課
- 國開《Windows網(wǎng)絡(luò)操作系統(tǒng)管理》形考任務(wù)2-配置本地帳戶與活動目錄域服務(wù)實訓(xùn)
- 環(huán)保設(shè)施安全風(fēng)險評估報告
評論
0/150
提交評論