版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、開關實驗:io8255aequ 288hio8255cequ 28ahio8255zequ 28bhcode segmentassume cs:codestart:mov dx,io8255zmov al,8bhout dx,alinout:mov dx,io8255cin al,dxmov dx,io8255aout dx,almov dl,0ffhmov ah,06hint 21hjz inoutmov ah,4chint 21hcode endsend start 交通燈控制實驗:data segmentio8255c equ 28ahio8255z equ 28bhportc1 db
2、21h db 81h,01h,81h,01h,81h,01h,81h,01h,81h,01h,81h,01h db 44h db 42h,40h,42h,40h,42h,40h,42h,40h,42h,40h,42h,40h db 0ffhdata endscode segment assume cs:code,ds:datastart: mov ax,data mov ds,ax mov dx,io8255z mov al,90h out dx,al mov dx,io8255cre_on: mov bx,0;on: mov al,portc1bx cmp al,0ffh jz re_on
3、out dx,al inc bxmov cx,200test al,24hjz de1mov cx,10000de1: mov di,9000de0: dec di jnz de0 loop de1 push dx mov ah,06hmov dl,0ffhint 21hpop dxjz onexit:mov ah,4ch int 21hcode endsend start七段數(shù)碼管靜態(tài)顯示實驗:io8255aequ 288hio8255zequ 28bhdata segmentled db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fhmesg1db 0dh,
4、0ah,input a num(0-9),other key is exit,0dh,0ah,$data endscode segment assume cs:code,ds:datastart:mov ax,datamov ds,axmov dx,io8255zmov ax,80hout dx,alsss:mov dx,offset mesg1mov ah,09hint 21hmov ah,01int 21hcmp al,0jl exitcmp al,9jg exitsub al,30hmov bx,offset ledxlatmov dx,io8255aout dx,aljmp sssex
5、it:mov ah,4chint 21hcode endsend start數(shù)碼管循環(huán)顯示0099data segment io8255a equ 288h io8255b equ 289hio8255c equ 28ahio8255z equ 28bh led db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh buffer1 db 0,0 bz dw 01,00data endscode segmentassume cs:code,ds:datastart:mov ax,datamov ds,axmov dx,io8255b ;將8255設為a口輸出mov
6、 al,80hout dx,almov di,offset buffer1 ;設di為顯示緩沖區(qū)loop1: mov cx,0300h;循環(huán)次數(shù)loop2: mov bh,02 lll: mov byte ptr bz,bhpush didec diadd di,bzmov bl,di ;bl為要顯示的數(shù)pop dimov bh,0mov si,offset led;置led數(shù)碼管偏移地址為siadd si,bx;求出對應的led碼mov al,byte ptrsimov dx,io8255c;自8255a的口輸出out dx,almov al,byte ptr bz ;使相應的數(shù)碼管亮mov
7、 dx,io8255cout dx,alpush cxmov cx,3000 ;若顯示過快,可更改cx值最大為0ffffhdelay: loop delay ;延時pop cxmov bh,byte ptr bzshr bh,1jnz lllloop loop2 ;循環(huán)延時mov ax,word ptrdi mov ah,01int 16hjne exit ;有鍵按下轉exitmov ax,word ptrdiinc alaaamov di,al;al中為十位mov di+1,ah;ah中為個位jmp loop1exit: mov dx,io8255amov al,0;關掉數(shù)碼管顯示out d
8、x,almov ah,4ch;返回dosint 21hcode endsend start鍵盤接口實驗(行掃描法)data segmentio8255a equ 288hio8255c equ 28ahio8255z equ 28bhkey db 37h,38h,39h,41h,54h,52h db 34h,35h,36h,42h,53h,4dh db 31h,32h,33h,43h,48h,4ch db 30h,46h,45h,44h,58h,4ehdata endscode segment assume cs:code,ds:datastart: mov ax,data mov ds,ax
9、lp0: mov dx,io8255z mov al,90h out dx,al; mov di,0 mov si,0 lp1:mov al,00h mov dx,io8255c out dx,al mov dx,io8255a in al,dx and al,3fh cmp al,3fh jz lp1 call delay mov ah,0feh mov cx,4 lp2:mov al,ah mov dx,io8255c out dx,al mov dx,io8255a in al,dx and al,3fh cmp al,3fh jnz aa; rol ah,1 loop lp2 jmp
10、lp1 aa: push ax mov dx,io8255a in al,dx nop nop nop nop nop and al,3fh cmp al,3fh jnz aa pop axl4: mov cx,6lp4:shr al,1 jnc l3 inc si loop lp4l3: mov cx,4 mov al,ah lp3:shr al,1 jnc lp5 inc di loop lp3lp5:mov bx,di mov al,6 mul bl add ax,sidisp: mov bx,offset key xlat mov dh,0 mov dl,al mov ah,2 int
11、 21h jmp lp0exit: mov ah,4ch int 21h delay proc near push cx mov cx,20h l1:loop l1 pop cx ret delay endp code ends end startbca: mov al,ahmov dx,io8255cout dx,al;輸出行值mov dx,io8255ain al,dx;讀入列值and al,00111111b;保留低4位有效值cmp al,00111111b;判斷a0行是否有鍵按下mov bl,al;有鍵按下,確定該鍵的值rol ah;本行無鍵按下則繼續(xù)查找下一行,循環(huán)左移(使下一行輸出
12、0)loop bcajmp abcrealy:mov dx,io8255cin al,dxnopnopnopand al,0fhcmp al,0fhjnz realymov cx,4mov al,bllp1: shr al,1jnc lp2inc diloop lp1lp2:mov cx,6mov al,ahlp20:shr al,1jnc lp3inc siloop lp20lp3:mov bx,dimov al,6mul bladd ax,sidisp:mov bx,offset keyxlatmov dh,0mov dl,almov ah,2int 21hjmp lp0exit:mov
13、ah,4chint 21hdelay proc nearpush cxmov cx,20hl1:loop l1 pop cx retdelay endpcode endsend startdata segment io8255a equ 288h io8255b equ 289h io8255c equ 28ah io8255z equ 28bh key db 37h,38h,39h,41h,54h,52h db 34h,35h,36h,42h,53h,4dh db 31h,32h,33h,43h,48h,4ch db 30h,46h,45h,44h,58h,4eh led1 db 3fh,0
14、6h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh led2 db 77h,7ch,39h,5eh,79h,71hdata endscode segment assume cs:code,ds:datastart: mov ax,data mov ds,axlp0: mov dx,io8255z mov al,90h out dx,al;c shu chu ,a shu ru lp1: mov di,0 mov si,0 mov al,00h mov dx,io8255c out dx,al mov dx,io8255a in al,dx and al,3fh cmp al,
15、3fh jz lp1 call delay mov ah,0feh mov cx,4lp2:mov al,ah mov dx,io8255c out dx,al mov dx,io8255a in al,dx and al,3fh cmp al,3fh jnz realy;you jian an xia rol ah,1 loop lp2 jmp lp1realy:push axmov dx,io8255ain al,dxnopnopnopnopnopand al,3fhcmp al,3fhjnz realypop axl4: mov cx,6lp4:shr al,1 jnc l3 inc s
16、i loop lp4l3: mov cx,4 mov al,ah lp3:shr al,1 jnc lp5 inc di loop lp3lp5:mov bx,di mov al,6 mul bl add ax,sidisp: mov bx,offset key xlat cmp ax,39hjl llcmp ax,40hjg lll ll: sub ax,30h mov bx,offset led1 xlat mov dx,io8255b out dx,ax jmp lp1lll: sub ax,41h mov bx,offset led2 xlat mov dx,io8255b out d
17、x,ax jmp lp1exit: mov ah,4ch int 21hdelay proc near push cx mov cx,20hl1: loop l1 pop cx retdelay endpcode endsend start 實驗三3.1timer_ctl equ 283htimer0 equ 280hio8255z equ 28bhio8255c equ 28ahcode segment assume cs:codestart: mov dx,io8255z mov al,80h out dx,al mov al,00010000b mov dx,timer_ctl out
18、dx,al mov dx,timer0 mov al,9 out dx,aldisplay: mov al,00000000b mov dx,timer_ctl out dx,al mov dx,timer0 in al,dx mov bl,al mov al,9 sub al,bl mov dx,io8255c out dx,al mov ah,06h mov dl,0ffh int 21h jz display mov ah,4ch int 21hcode endsend start3.2timer_ctl equ 283htimer0 equ 280htimer1 equ 281hmod
19、e03 equ 36hmode12 equ 76hcode segment assume cs:codestart: mov dx,timer_ctl mov al,mode03 out dx,al mov dx,timer0 mov ax,500 out dx,al mov al,ah out dx,al mov dx,timer_ctl mov al,mode12 out dx,al mov dx,timer1 mov ax,500 out dx,al mov al,ah out dx,al mov ah,4ch int 21h code endsend start3.3timer0 eq
20、u 280htimer1 equ 281htimerctl equ 283hio8255a equ 288hio8255z equ 28bhcode segment assume cs:codestart: mov dx,io8255z mov al,90h out dx,alll1: mov al,0 out dx,al call delay mov al,1 out dx,al call delay jmp ll1delay proc near push dx mov dx,timerctl mov al,36h out dx,al mov dx,timer0 mov ax,1000 ou
21、t dx,al mov al,ah out dx,al mov dx,timerctl mov al,70h out dx,al mov dx,timer1 mov ax,500 out dx,al mov al,ah out dx,alll2: mov ah,06 mov dl,0ffh int 21h jne exit mov dx,io8255a in al,dx and al,01 jz ll2 pop dx retexit: mov ah,4ch int 21hdelay endpcode endsend start3.4data segmentio8255a equ 288hio8
22、255z equ 28bhtimer0 equ 280htimerctl equ 283htable dw 524,588,660,784,880,988,1048 ;高音的;table dw 262,294,330,347,392,440,524 ;低音的msg db 'press 1,2,3,4,5,6,7,8,esc:',0dh,0ah,'$'data endscode segmentassume cs:code, ds:datastart: mov ax,data mov ds,ax mov dx,offset msg mov ah,9 int 21hs
23、ing: mov ah,7 int 21h cmp al,1bh je finish cmp al,'1' jl sing cmp al,'8' jg sing sub al,32h shl al,1 mov bl,al mov bh,0 mov ax,4240h mov dx,0fh div word ptrtable+bx mov bx,ax mov dx,timerctl mov al,00110110b out dx,al mov dx,timer0 mov ax,bx out dx,al mov al,ah out dx,al mov dx,io825
24、5z mov al,10000000b out dx,al mov dx,io8255a mov al,03h out dx,al call delay mov al,0h out dx,al jmp singfinish: mov ax,4c00h int 21hdelay proc near push cx push ax mov ax,15 x1: mov cx,0ffffh x2: dec cx jnz x2 dec ax jnz x1 pop ax pop cx retdelay endpcode endsend start3.5data segmentio8255a equ 288
25、hio8255z equ 28bhtimer0 equ 280htimerctl equ 283h;table dw 524,588,660,698,784,880,998,1048table dw 262,294,330,347,392,440,494,524;music_dataxxx db 1,1,5,5,6,6,5,4,4,3,3,2,2,1,5,5,4,4,3,3,2,5,5,4,4,3,3,2,1,1,5,5,6,6,5,4,4,3,3,2,2,1music_datalzlh db 1,2,3,1,1,2,3,1,3,4,5,3,4,5,5,6,5,4,3,1,5,6,5,4,3,
26、1,2,5,1,2,5,1mus_t1 db 50,50,50,100,50,50,50,100,50,50,25,50,50,25,15,15,15,15,50,25,15,15,15,15,50,25,50,75,50,50,70,50;mus_t db 50,50,50,50,50,50,50,100,50,50,50,50,50,50,50,100,50,50,50,50,50,50,50,100,50,50,50,50,50,50,50,100,50,50,50,50,50,50,50,100,50,50,50,50,50,50,50,100msg db 'xiao xing
27、 xing:',0dh,0ah,'$'data endscode segment assume cs:code,ds:datastart: mov ax,data mov ds,ax mov dx,offset msg mov ah,9 int 21h ;tishi mov bx,0 push bx sing: pop bx ; mov si,offset music_dataxxx mov si,offset music_datalzlh add si,bx push bx mov al,byte ptrsi ; que pu zhi ;cmp al,'1
28、39; ;jl sing ;cmp al,'8' ;jg sing ;sub al,31h shl al,1 mov bl,al mov bh,0 mov ax,4240h mov dx,0fh div word ptrtable+bx mov bx,ax mov dx,timerctl mov al,00110110b out dx,al mov dx,timer0 mov ax,bx out dx,al mov al,ahout dx,al mov dx,io8255z mov al,10000000b out dx,al mov dx,io8255a mov al,03h
29、 out dx,al lea si,mus_t1 ;lea si,mus_t mov bx,si call mus_d ;out dx,al call delay mov al,0h out dx,al ;guan yang sheng qi pop bx cmp bx,42 je hehe add bx,1 push bx jmp singhehe: mov bx,0 push bx jmp sing finish: mov ax,4c00h int 21h mus_d procleng: mov cx,2081 delay1: loop delay1 dec bx jnz lengretm
30、us_d endp delay proc near push cx push ax mov ax,15x1:mov cx,0ffffhx2:dec cx jnz x2 dec ax jnz x1 pop ax pop cx retdelay endpcode endsend start 實驗四int00 equ 288hint01 equ 289hio8255c equ 282hio8255z equ 283hn equ 7code segmentassume cs:codestart: call i8255 cli mov bx,0 call write0b call i8259 mov c
31、l,0 stil1: cmp cl,n jnz l1 mov ah,4ch int 21hint_service proc push dx ; mov dx,io8255c ;mov al,0ffh ;out dx,al inc bx mov al,bl mov ah,bh mov dx,io8255c out dx,ax nop nop nop mov al,20h out 20h,al nop pop dx iretnt_service endpwrite0b proc mov ax,code mov ds,ax mov dx,offset int_service mov ax,250bh
32、 int 21h retwrite0b endpi8255 proc mov al,80h mov dx,io8255z out dx,al reti8255 endpi8259 proc mov al,00010011b mov dx,int00 out dx,al mov al,8 mov dx,int01 out dx,al mov al,00000001b out dx,al mov al,0 out dx,al in al,21h and al,0f7h out 21h,al reti8259 endpcode endsend start實驗5鋸齒波:io0832a equ 290h
33、code segmentassume cs:codestart: mov cl,0 mov dx,io0832all1: mov al,cl out dx,al add cl,1 push dx mov ah,06h ;判斷是否有鍵按下 mov dl,0ffh int 21h pop dx jz ll1mov ah,4chint 21hcode endsend start正弦波:data segmentio0832a equ 290hsin db 80h,96h,0aeh,0c5h,0d8h,0e9h,0f5h,0fdh db 0ffh,0fdh,0f5h,0e9h,0d8h,0c5h,0ae
34、h,96h db 80h,66h,4eh,38h,25h,15h,09h,04h db 00h,04h,09h,15h,25h,38h,4eh,66hdata endscode segmentassume cs:code,ds:datastart: mov ax,data mov ds,axl1: mov si,offset sin mov bh,32ll1: mov al,si mov dx,io0832a out dx,al mov ah,06h ;判斷是否有鍵按下 mov dl,0ffh int 21h jne exit mov cl,1delay: loop delay inc si
35、dec bh jnz ll1 jmp l1exit: mov ah,4ch int 21hcode endsend start直流電機轉速控制:data segmentio0832a equ 290hio8255c equ 28ahio8255z equ 28bhdata endscode segmentassume cs:code,ds:datastart: mov ax,data mov ds,ax mov al,85h ;8255初始化 mov dx,io8255z out dx,al lp1: mov dx,io8255c ;開關值賦給cx作為循環(huán)次數(shù) in al,dx mov ah,
36、0 mov cx,ax lp2: mov al,0ffh mov dx,io8032a out dx,al mov ah,06h ;判斷是否有鍵按下 mov dl,0ffh int 21h jne exit loop lp2lp3: mov cx,32lp4: mov al,80h mov dx,io8032a out dx,al mov ah,06h ;判斷是否有鍵按下 mov dl,0ffh int 21h jne exit loop lp4 jmp lp1exit: mov ah,4chint 21hcode endsend start 實驗六模數(shù)轉換io0809a equ 298hco
37、de segment assume cs:codestart:mov dx,io0809a out dx,al mov cx,0ffhdelay:loop delay in al,dx mov bl,al mov cl,4 shr al,cl call disp mov al,bl and al,0fh call disp mov ah,02 mov dl,20h int 21h mov dl,20h int 21h push dx mov ah,06h mov dl,0ffh int 21h pop dx je start mov ah,4ch int 21hdisp proc near mov dl,al cmp dl,9 jle ddd add d
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年08月江蘇蘇州銀行博士后研究人員招考筆試歷年參考題庫附帶答案詳解
- 2025至2031年中國蝦養(yǎng)殖行業(yè)投資前景及策略咨詢研究報告
- 2024年棉麻機械項目可行性研究報告
- 2025至2031年中國熱電偶瓷套管行業(yè)投資前景及策略咨詢研究報告
- 2024年PVC鞋頭帖項目可行性研究報告
- 2024至2030年黑白小電視機項目投資價值分析報告
- 2025至2031年中國多向閥行業(yè)投資前景及策略咨詢研究報告
- 2025年中咨江西工程有限公司招聘筆試參考題庫含答案解析
- 排隊系統(tǒng)與存貯系統(tǒng)的綜合模型探討
- 2025年湖南火電建設有限公司招聘筆試參考題庫含答案解析
- 偉星管-云上裝飾
- 消防安全檢查記錄表(完整詳細版)1
- 腫瘤放射治療技術-總論課件
- 5S評分基準模板
- 沈陽師范大學科研平臺和專業(yè)能力實踐基地建設規(guī)劃
- 大連市12處縣級以上飲用水水源保護區(qū)區(qū)劃方案
- 蘇教版二年級科學下冊第3課《神奇的新材料》教學設計
- 二次供水工程施工方案
- 第二章離心風機.ppt
- 中國傳統(tǒng)圖案紋樣
- DLT5210.1-2021電力建設施工質量驗收及評價規(guī)程
評論
0/150
提交評論