微機(jī)接口研究性教學(xué)專(zhuān)題三_題目一_第1頁(yè)
微機(jī)接口研究性教學(xué)專(zhuān)題三_題目一_第2頁(yè)
微機(jī)接口研究性教學(xué)專(zhuān)題三_題目一_第3頁(yè)
微機(jī)接口研究性教學(xué)專(zhuān)題三_題目一_第4頁(yè)
微機(jī)接口研究性教學(xué)專(zhuān)題三_題目一_第5頁(yè)
已閱讀5頁(yè),還剩17頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡(jiǎn)介

1、 微機(jī)接口研究性教學(xué)專(zhuān)題三 本次研討,我們組對(duì)題目一展開(kāi)研究。題目一:編寫(xiě)程序,將自己的名字以動(dòng)畫(huà)的形式顯示在屏幕上??凑l(shuí)的動(dòng)畫(huà)漂亮。(題目難度較大,考察的是顯示器接口。) 漢字并不屬于ASCII碼,不能直接顯示,但是我們可以利用字符來(lái)組成漢字,進(jìn)而完成漢字的顯示。通過(guò)查閱資料,我們了解到可以通過(guò)三種方法解決這個(gè)問(wèn)題,直接控制顯存,使用BIOS,使用DOS功能,最終我們選擇使用BIOS解決這個(gè)問(wèn)題。BIOS是英文"Basic Input Output System"的縮略語(yǔ),直譯過(guò)來(lái)后中文名稱(chēng)就是"基本輸入輸出系統(tǒng)"。其實(shí),它是一組固化到計(jì)算機(jī)內(nèi)主板上一

2、個(gè)ROM芯片上的程序,它保存著計(jì)算機(jī)最重要的基本輸入輸出的程序、系統(tǒng)設(shè)置信息、開(kāi)機(jī)后自檢程序和系統(tǒng)自啟動(dòng)程序。 其主要功能是為計(jì)算機(jī)提供最底層的、最直接的硬件設(shè)置和控制。 首先說(shuō)明工作原理: 我們使用BIOS中的中斷INT 10H解決問(wèn)題。匯編中的10H中斷是由BIOS對(duì)顯示器和屏幕所提供的服務(wù)程序。 使用int 10h服務(wù)程序時(shí),必須先指定ah寄存器為以下顯示服務(wù)編號(hào)之一,以指定需要調(diào)用的功用。顯示服務(wù) (Video Service:int 10h)00H:設(shè)置顯示器模式01H:設(shè)置光標(biāo)形狀02H:設(shè)置光標(biāo)位置03H:讀取光標(biāo)信息04H:讀取光筆位置05H:設(shè)置顯示頁(yè)06H、07H:初始化或

3、滾屏08H:讀光標(biāo)處的字符及其 屬性09H:在光標(biāo)處按指定屬性顯示字符0AH:在當(dāng)前光標(biāo)處顯示字符0BH:設(shè)置調(diào)色板、背景色或邊框0CH: 寫(xiě)圖形象素0DH:讀圖形象素0EH:在Teletype模式下顯示字符0FH:讀取顯示器模式10H:顏色11H: 字體12H:顯示器的配置13H:在Teletype模式下顯示字符串1AH:讀取/設(shè)置顯示組合編碼1BH: 讀取功能/狀態(tài)信息1CH:保存/恢復(fù)顯示器狀態(tài) 我們使用了功能06H,13H。功能06H功能描述:初始化屏幕或滾屏入口參數(shù):AH06H向上滾屏AL滾動(dòng)行數(shù)(0清窗口)BH空白區(qū)域的缺省屬性(CH、CL) 窗口的左上角位置(Y坐標(biāo),X坐標(biāo))(D

4、H、DL)窗口的右下角位置(Y坐標(biāo),X坐標(biāo))具體結(jié)合我們的清屏函數(shù)看一下:;-CLEAR PROC USES AX BX CX DXMOV CL,0MOV CH,0 ;(CH、CL) 窗口的左上角位置(Y坐標(biāo),X坐標(biāo))MOV DL,79MOV DH,24 ;(DH、DL)窗口的右下角位置(Y坐標(biāo),X坐標(biāo))MOV BH,7 MOV AL,0 ;整屏為空白MOV AH,6 ;初始化屏幕或滾屏INT 10HRETCLEAR ENDP ;-通過(guò)功能06H我們可以在每次顯示之前清屏并對(duì)屏幕做相關(guān)設(shè)定。功能 13H功能描述:在Teletype模式下顯示字符串入口參數(shù):AH13HBH頁(yè)碼BL屬性(若AL=0

5、0H或 01H)CX顯示字符串長(zhǎng)度(DH、DL)坐標(biāo)(行、列)ES:BP顯示字符串的地址 AL顯示輸出方式0 字符串中只含顯示字符,其顯示屬性在BL中。顯示后,光標(biāo)位置不變1字符串中只含顯示字符,其顯示屬性在BL中。顯示后,光標(biāo)位置改變2 字符串中含顯示字符和顯示屬性。顯示后,光標(biāo)位置不變3字符串中含顯示字符和顯示屬性。顯示后,光標(biāo)位置改變出口參數(shù):無(wú)還是結(jié)合具體程序來(lái)看一下:首先說(shuō)明在定義數(shù)據(jù)段時(shí),我們將要輸出的字符串按照如下方式定義,BUFF DB "H",15,"E",15,"L",15,"L",15,&qu

6、ot;O",15則在使用功能13H輸出字符串時(shí),每個(gè)字符后的數(shù)字可以作為該字符的顏色,比如0為黑色,1為藍(lán)紫色,2為翠綠色,15為白色。;-MOV BUFFSI,15 ;將第SI-1個(gè)字符設(shè)置為白色MOV BH,0MOV CX,5 ;顯示字符串長(zhǎng)度MOV DH,20MOV DL,20LEA BP,BUFF ;顯示字符串的地址MOV AL,2MOV AH,13H ;在Teletype模式下顯示字符串INT 10H;-BUFF DB " ",15," ",15," ",15," ",15,"*&qu

7、ot;,15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15 DB " ",15," ",15," ",15,"*",15,"*",15,"*",15,"*",15,&

8、quot;*",15,"*",15,"*",15,"*",15," ",15," ",15," ",15," ",15 DB " ",15," ",15,"*",15," ",15,"*",15," ",15," ",15," ",15," ",15,"*&q

9、uot;,15," ",15," ",15," ",15," ",15," ",15 DB " ",15,"*",15," ",15," ",15," ",15,"*",15," ",15," ",15,"*",15," ",15," ",15," ",15,

10、" ",15," ",15," ",15 DB " ",15," ",15," ",15," ",15," ",15," ",15,"*",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15," &

11、quot;,15 DB " ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15 DB " ",15," "

12、,15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15 DB " ",15," ",15,"*",15," ",15,&quo

13、t; ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15 DB "*",15," ",15," ",15," ",15," ",15,"*",15," "

14、;,15," ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15 DB " ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15,&qu

15、ot; ",15," ",15," ",15," ",15," ",15," ",15 DB " ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15,"*",15," ",15," &quo

16、t;,15," ",15," ",15," ",15 DB " ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15,&q

17、uot; ",15 DB " ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15以上字符串為我們顯示“冬”這個(gè)漢字時(shí)所構(gòu)造的字符串,空格

18、和“*”經(jīng)過(guò)合適的位置搭配即可顯示出“冬”字。通過(guò)功能13H我們可以實(shí)現(xiàn)變換顏色以及變換位置的字符串輸出。在顯示時(shí),我們希望一個(gè)圖形能夠停頓一下,不要刷新過(guò)快,所以我們每次顯示需要一個(gè)延時(shí)??梢岳每盏难h(huán)來(lái)實(shí)現(xiàn)延時(shí),這里我們利用了一個(gè)4層循環(huán)。為了便于書(shū)寫(xiě)程序,我們將延時(shí)程序?qū)懗闪艘粋€(gè)子程序。;-Delay1S PROCmov AH,200DEL0:DEC AH CMP AH,0 JZ BR mov AL,150DEL1:DEC AL CMP AL,0 JZ DEL0 mov BL,150DEL2:DEC BL CMP BL,0 JZ DEL1 MOV BH,150DEL3: DEC BH

19、CMP BH,0 JZ DEL2 JMP DEL3BR:RETDELAY1S ENDP;-此外,我們希望最后的程序有按下某一個(gè)鍵就能夠退出的功能,此功能我們利用INT 16H(鍵盤(pán)中斷)來(lái)實(shí)現(xiàn)。;-MOV AH,1 ;讀鍵盤(pán)之前先檢查是否有按鍵INT 16HJZ AGAIN ;沒(méi)有則回到顯示字符的循環(huán)MOV AH,0 ;讀鍵盤(pán)功能INT 16H ;AL返回輸入字符ASCII碼CMP AL,KBESC ;和定義的退出鍵的ASCII碼比較JNZ AGAIN ;不是則回到顯示字符的循環(huán);-這樣,關(guān)于原理就介紹完畢。下面是程序?qū)崿F(xiàn)流程。具體變換顯示顏色及位置的方法為將要變顏色的字符的位置和要顯示的顏色

20、分別用兩個(gè)變量表示,每次顯示之前循環(huán)變換,這樣就能實(shí)現(xiàn)每次位置與顏色的變換。;- ADD SI,2.IF SI>29MOV SI,1.ENDIFADD DI,1.IF DI>13MOV DI,0.ENDIF;-在調(diào)試程序時(shí)遇到的問(wèn)題為字符串顯示的位置不對(duì),后來(lái)經(jīng)過(guò)用TD調(diào)試發(fā)現(xiàn)是因?yàn)槊看物@示完后,DH,DL(即表示顯示的位置)會(huì)自動(dòng)清零,而我的程序并沒(méi)有在每次顯示前都賦值。改為每次顯示之前都做一次賦值后問(wèn)題得到解決。程序效果截圖:程序清單:.MODEL SMALL;-.DATAKBESC EQU 1BHBUFF1 DB " ",15," ",

21、15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15BUFF2 DB " ",15," ",15," ",15,"*",15,

22、"*",15,"*",15,"*",15,"*",15,"*",15,"*",15,"*",15," ",15," ",15," ",15," ",15BUFF3 DB " ",15," ",15,"*",15," ",15,"*",15," ",15,&qu

23、ot; ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15BUFF4 DB " ",15,"*",15," ",15," ",15," ",15,"*",15," ",15," ",15,"

24、*",15," ",15," ",15," ",15," ",15," ",15," ",15BUFF5 DB " ",15," ",15," ",15," ",15," ",15," ",15,"*",15,"*",15," ",15," ",15," &q

25、uot;,15," ",15," ",15," ",15," ",15BUFF6 DB " ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," "

26、;,15," ",15," ",15BUFF7 DB " ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",1

27、5BUFF8 DB " ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15," ",15," ",15BUFF9 DB "*",15," &qu

28、ot;,15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15BUFF10 DB " ",15," ",15," ",15," "

29、;,15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15BUFF11 DB " ",15," ",15," ",15," ",15," ",15,"*",

30、15," ",15," ",15," ",15,"*",15," ",15," ",15," ",15," ",15," ",15BUFF12 DB " ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15

31、," ",15," ",15," ",15," ",15," ",15," ",15," ",15BUFF13 DB " ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15," ",15,"*",15,&

32、quot; ",15," ",15," ",15," ",15," ",15COLOR DB 1,2,3,4,5,6,7,8,9,10,11,12,13,14;-.CODECLEAR PROC USES AX BX CX DXMOV CL,0MOV CH,0MOV DL,79MOV DH,24MOV BH,7MOV AL,0MOV AH,6INT 10HRETCLEAR ENDPDelay1S PROCmov AH,200DEL0:DEC AH CMP AH,0 JZ BR mov AL,150DEL1:

33、DEC AL CMP AL,0 JZ DEL0 mov BL,150DEL2:DEC BL CMP BL,0 JZ DEL1 MOV BH,150DEL3: DEC BH CMP BH,0 JZ DEL2 JMP DEL3BR:RETDELAY1S ENDP;-.STARTUPCALL CLEARMOV AX,DSMOV ES,AXMOV SI,29MOV DI,13AGAIN:CALL CLEARMOV BUFF1SI,15MOV BUFF2SI,15MOV BUFF3SI,15MOV BUFF4SI,15MOV BUFF5SI,15MOV BUFF6SI,15MOV BUFF7SI,15M

34、OV BUFF8SI,15MOV BUFF9SI,15MOV BUFF10SI,15MOV BUFF11SI,15MOV BUFF12SI,15MOV BUFF13SI,15ADD SI,2.IF SI>29MOV SI,1.ENDIFADD DI,1.IF DI>13MOV DI,0.ENDIF;-MOV BH,COLORDIMOV BUFF1SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,2JMP GO1.ENDIF.IF SI>15MOV DH,4JMP GO1.ENDIF.IF SI>8MOV DH,6JMP GO1.ENDIF

35、MOV DH,8GO1:.IF DI>9MOV DL,40JMP GO011.ENDIF.IF DI>6MOV DL,10JMP GO011.ENDIF.IF DI>3MOV DL,30JMP GO011.ENDIFMOV DL,20GO011:LEA BP,BUFF1MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF2SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,3JMP GO2.ENDIF.IF SI>15MOV DH,5JMP GO2.ENDIF.IF SI>8MOV DH,

36、7JMP GO2.ENDIFMOV DH,9GO2:.IF DI>9MOV DL,40JMP GO22.ENDIF.IF DI>6MOV DL,10JMP GO22.ENDIF.IF DI>3MOV DL,30JMP GO22.ENDIFMOV DL,20GO22:LEA BP,BUFF2MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF3SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,4JMP GO3.ENDIF.IF SI>15MOV DH,6JMP GO3.ENDIF.IF SI&g

37、t;8MOV DH,8JMP GO3.ENDIFMOV DH,10GO3:.IF DI>9MOV DL,40JMP GO33.ENDIF.IF DI>6MOV DL,10JMP GO33.ENDIF.IF DI>3MOV DL,30JMP GO33.ENDIFMOV DL,20GO33:LEA BP,BUFF3MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF4SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,5JMP GO4.ENDIF.IF SI>15MOV DH,7JMP GO4.EN

38、DIF.IF SI>8MOV DH,9JMP GO4.ENDIFMOV DH,11GO4:.IF DI>9MOV DL,40JMP GO44.ENDIF.IF DI>6MOV DL,10JMP GO44.ENDIF.IF DI>3MOV DL,30JMP GO44.ENDIFMOV DL,20GO44:LEA BP,BUFF4MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF5SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,6JMP GO5.ENDIF.IF SI>15MOV DH,

39、8JMP GO5.ENDIF.IF SI>8MOV DH,10JMP GO5.ENDIFMOV DH,12GO5:.IF DI>9MOV DL,40JMP GO55.ENDIF.IF DI>6MOV DL,10JMP GO55.ENDIF.IF DI>3MOV DL,30JMP GO55.ENDIFMOV DL,20GO55:LEA BP,BUFF5MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF6SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,7JMP GO6.ENDIF.IF SI&

40、gt;15MOV DH,9JMP GO6.ENDIF.IF SI>8MOV DH,11JMP GO6.ENDIFMOV DH,13GO6:.IF DI>9MOV DL,40JMP GO66.ENDIF.IF DI>6MOV DL,10JMP GO66.ENDIF.IF DI>3MOV DL,30JMP GO66.ENDIFMOV DL,20GO66:LEA BP,BUFF6MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF7SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,8JMP GO7.

41、ENDIF.IF SI>15MOV DH,10JMP GO7.ENDIF.IF SI>8MOV DH,12JMP GO7.ENDIFMOV DH,14GO7:.IF DI>9MOV DL,40JMP GO77.ENDIF.IF DI>6MOV DL,10JMP GO77.ENDIF.IF DI>3MOV DL,30JMP GO77.ENDIFMOV DL,20GO77:LEA BP,BUFF7MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF8SI,BHMOV BH,0MOV CX,15.IF SI>23MOV

42、 DH,9JMP GO8.ENDIF.IF SI>15MOV DH,11JMP GO8.ENDIF.IF SI>8MOV DH,13JMP GO8.ENDIFMOV DH,15GO8:.IF DI>9MOV DL,40JMP GO88.ENDIF.IF DI>6MOV DL,10JMP GO88.ENDIF.IF DI>3MOV DL,30JMP GO88.ENDIFMOV DL,20GO88:LEA BP,BUFF8MOV AL,2MOV AH,13HINT 10H;-MOV BH,COLORDIMOV BUFF9SI,BHMOV BH,0MOV CX,15.IF SI>23MOV DH,10JMP GO9.ENDIF.IF SI>15MOV DH,12JMP GO9.ENDIF.IF SI>8MOV DH,14JMP GO9.ENDIFMOV DH,16GO9:.IF DI>9MOV DL,40JMP GO99.ENDIF.IF DI>6MOV DL,10JMP GO99.ENDIF.IF DI>3MOV DL,30JMP GO99.ENDIFMOV DL

溫馨提示

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

評(píng)論

0/150

提交評(píng)論