微機接口研究性教學專題三_題目一_第1頁
微機接口研究性教學專題三_題目一_第2頁
微機接口研究性教學專題三_題目一_第3頁
微機接口研究性教學專題三_題目一_第4頁
微機接口研究性教學專題三_題目一_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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

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

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

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

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

6、ot;O",15則在使用功能13H輸出字符串時,每個字符后的數(shù)字可以作為該字符的顏色,比如0為黑色,1為藍紫色,2為翠綠色,15為白色。;-MOV BUFFSI,15 ;將第SI-1個字符設置為白色MOV BH,0MOV CX,5 ;顯示字符串長度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以上字符串為我們顯示“冬”這個漢字時所構造的字符串,空格

18、和“*”經(jīng)過合適的位置搭配即可顯示出“冬”字。通過功能13H我們可以實現(xiàn)變換顏色以及變換位置的字符串輸出。在顯示時,我們希望一個圖形能夠停頓一下,不要刷新過快,所以我們每次顯示需要一個延時??梢岳每盏难h(huán)來實現(xiàn)延時,這里我們利用了一個4層循環(huán)。為了便于書寫程序,我們將延時程序寫成了一個子程序。;-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;-此外,我們希望最后的程序有按下某一個鍵就能夠退出的功能,此功能我們利用INT 16H(鍵盤中斷)來實現(xiàn)。;-MOV AH,1 ;讀鍵盤之前先檢查是否有按鍵INT 16HJZ AGAIN ;沒有則回到顯示字符的循環(huán)MOV AH,0 ;讀鍵盤功能INT 16H ;AL返回輸入字符ASCII碼CMP AL,KBESC ;和定義的退出鍵的ASCII碼比較JNZ AGAIN ;不是則回到顯示字符的循環(huán);-這樣,關于原理就介紹完畢。下面是程序實現(xiàn)流程。具體變換顯示顏色及位置的方法為將要變顏色的字符的位置和要顯示的顏色

20、分別用兩個變量表示,每次顯示之前循環(huán)變換,這樣就能實現(xiàn)每次位置與顏色的變換。;- ADD SI,2.IF SI>29MOV SI,1.ENDIFADD DI,1.IF DI>13MOV DI,0.ENDIF;-在調試程序時遇到的問題為字符串顯示的位置不對,后來經(jīng)過用TD調試發(fā)現(xiàn)是因為每次顯示完后,DH,DL(即表示顯示的位置)會自動清零,而我的程序并沒有在每次顯示前都賦值。改為每次顯示之前都做一次賦值后問題得到解決。程序效果截圖:程序清單:.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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論