第八章、輸入輸出程序設(shè)計(jì)_第1頁(yè)
第八章、輸入輸出程序設(shè)計(jì)_第2頁(yè)
第八章、輸入輸出程序設(shè)計(jì)_第3頁(yè)
第八章、輸入輸出程序設(shè)計(jì)_第4頁(yè)
第八章、輸入輸出程序設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩35頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Assembly LanguageAssembly Language CPUMEMI/O設(shè)備設(shè)備三總線三總線I/O接口接口第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language”第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly Language

2、Assembly Language第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language 第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language3.IN/OUT3.IN/OUT指令的應(yīng)用實(shí)例指令的應(yīng)

3、用實(shí)例例例1 1:循環(huán)測(cè)試可編程中斷控制器:循環(huán)測(cè)試可編程中斷控制器8259A8259A的狀態(tài)寄存器的第二位是否為的狀態(tài)寄存器的第二位是否為1 1,若為,若為1 1則推出測(cè)則推出測(cè)試;試; AGAIN: AGAIN: IN AL,IN AL, STATUS_PORTSTATUS_PORT TEST AL, 00000100B TEST AL, 00000100B JZ AGAIN JZ AGAIN例例2 2:讀取某接口的命令寄存器(端口號(hào)位:讀取某接口的命令寄存器(端口號(hào)位126H126H)然后使其第七位置)然后使其第七位置1 1而進(jìn)行成而進(jìn)行成組數(shù)據(jù)傳送。組數(shù)據(jù)傳送。 MOV DX,126H

4、 MOV DX,126H IN AL,DX IN AL,DX OR AL,80H OR AL,80H OUT DX,AL OUT DX,AL 第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language 第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembl

5、y LanguageAssembly Language proc push ax pop ax ret endp push ax pop ax ret第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language push ax push ax push dx push dx mov dx, mov dx, 378h378h ; ; 數(shù)據(jù)寄存器數(shù)據(jù)寄存器 out dx, al out dx, al mov dx, mov dx, 379h 379h ; ; 狀態(tài)寄存器狀態(tài)寄存器again

6、: in al, dxagain: in al, dx test al, 80h ; test al, 80h ; (dx)7 7 = busy je again je again ; =0,; =0,打印機(jī)忙打印機(jī)忙 mov dx, mov dx, 37ah 37ah ; ; 控制寄存器控制寄存器 mov al, 0dhmov al, 0dh out dx, al out dx, al ; 送選通信號(hào)送選通信號(hào) jmp $+2jmp $+2 ; ; 展寬選通信號(hào)展寬選通信號(hào) mov al, 0chmov al, 0ch out dx, al out dx, al pop dx pop dx

7、pop ax pop ax ret ret0 0 0 0 1 1 0 1選通位自動(dòng)換行初始化選擇位中斷位第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language第第1717講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式一和二設(shè)備的數(shù)據(jù)傳送方式一和二(2(2課時(shí)課時(shí)) )Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language非屏蔽中斷請(qǐng)求非

8、屏蔽中斷請(qǐng)求 中斷邏輯中斷邏輯INT nINTO除法錯(cuò)除法錯(cuò)單步單步 n 4 0 1 2 NMI8259A(PIC)IR0 系統(tǒng)定時(shí)器系統(tǒng)定時(shí)器IR1 鍵盤鍵盤IR2 彩色彩色/圖形接口圖形接口IR3 保留保留IR4 串行通訊口串行通訊口IR5 保留保留IR6 軟盤軟盤IR7 打印機(jī)打印機(jī)08090A0B0C0D0E0F第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Languag

9、e第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language 第第1818講:講:I/OI/O設(shè)備

10、的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language 第第1818講:講:I/OI/O設(shè)備的數(shù)據(jù)傳送方式三設(shè)備的數(shù)據(jù)傳送方式三Assembly LanguageAssembly Language第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝

11、ssembly LanguageAssembly Language第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language定時(shí)器中斷定時(shí)器中斷18.218.2次次/SEC/SEC ; INT_TIMER; INT_TIMERINT 1CHINT 1CH IRETIRET INT_1CH PROCINT_1CH PROC IRETIRET INT_ICH ENDPINT_IC

12、H ENDPRING PROCRING PROC1.1.計(jì)數(shù)計(jì)數(shù)182(10182(10秒秒) )2.2.顯示字符串顯示字符串 IRETIRETRING ENDPRING ENDP例例1: 編寫一個(gè)中斷處理程序,要求在主程序運(yùn)行期間,每隔編寫一個(gè)中斷處理程序,要求在主程序運(yùn)行期間,每隔 10秒響鈴一次,同時(shí)顯示秒響鈴一次,同時(shí)顯示 bell 第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssem

13、bly Language例例2 2:鍵盤模擬程序:鍵盤模擬程序第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language 7 6 5 4 3 2 1 0鍵盤第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language例例3 3:從鍵盤接收字符,同時(shí)對(duì):從鍵盤接收字符,同時(shí)對(duì)3232字節(jié)的輸入緩沖區(qū)進(jìn)行測(cè)試;如緩沖區(qū)已滿,將鍵盤掛字節(jié)的輸入緩沖區(qū)進(jìn)行測(cè)試;如緩沖區(qū)已滿,將鍵盤掛起,由打印機(jī)輸出一個(gè)提示信息起,由打印機(jī)輸出一個(gè)提示信息;

14、;MAINBUFFER滿 CALL CALL NKBD中斷32次TYP中斷17次KBINTPRINTDISPINTIP第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language 第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Languagedseg segment addr dw ? ;緩沖區(qū)指針 count dw ? buffer db 20h dup ( ) prompt db please input:,0dh,0ah,$ mes

15、sage db buffer overflow,0dh,0ah save_ip9 dw ? save_cs9 dw ? save_ipf dw ? save_csf dw ?dseg ends mov addr, offset buffer mov count, 0第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Languagemov al, 09 ;鍵盤mov ah, 35hint 21hmov save_ip9, bxmov save_cs9, es mov dx, offset push dsmov ax, se

16、g mov ds, axmov al, 09mov ah, 25hint 21h pop ds in al, 21hand al, 0fdhout 21h, al mov al, 0fh ;打印機(jī)mov ah, 35hint 21h mov save_ipf, bxmov save_csf, es mov dx, offset prtintpush dsmov ax, seg prtintmov ds, axmov al, 0fhmov ah, 25hint 21h pop ds mov ah, 9lea dx, promptint 21h第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套

17、與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language sti mov ah, 2 mov dl, $ int 21h cli push ds mov dx, save_ip9 mov ax, save_cs9 mov ds, ax mov al, 09 mov ah, 25h int 21h pop dspush dsmov dx, save_ipfmov ax, save_csfmov ds, axmov al, 0fhmov ah, 25hint 21h pop dsin al, 21hand al, 0fdhout 21h, al sti第第1919講:

18、中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language通碼:通碼:(60h)7=0斷碼:斷碼:(60h)7=1 push ax push bx in al, 60h push ax in al, 61h mov ah, al or al, 80h out 61h, al ;鍵盤應(yīng)答信號(hào) xchg ah, al out 61h,al ;復(fù)位鍵盤 pop ax test al,80h jnz ret1 ;通碼時(shí)處理 mov bx,addr mov bx, al inc bx inc count mov addr, bxcheck

19、: cmp count,32 jb ret1 ;判斷是否溢出 ;屏蔽鍵盤中斷 and al, 7fh out 21h,al ;允許打印機(jī)中斷 call intipret1: cli mov al, 20h out 20h,al ;結(jié)束鍵盤中斷 pop bx pop ax iret第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language push ax push bx push dx cli mov bx, offset message mov addr, bx mov dx, mov al, 0dh out dx, al mov dx, mov al, 1dh out dx, al jmp $+2 mov al, 1ch out dx, al pop dx pop bx pop ax ret第第1919講:中斷嵌套與中斷程序?qū)嵗治鲋v:中斷嵌套與中斷程序?qū)嵗治鯝ssembly LanguageAssembly Language push ax push bx push dx mov

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論