1、实验实验48259中断实验中断实验STACK SEGMENT STACKDW 64 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODE,SS:STACKSTART:PUSH DS ;保存数据段保存数据段MOV AX,0000HMOV DS,AX ;数据段清;数据段清0MOV AX,OFFSET IRQ7 ;取中断程序入口地址(相对地址);取中断程序入口地址(相对地址)ADD AX,2000H ;加装载时;加装载时IP2000H地址(绝对地址)地址(绝对地址)MOV SI,003CH ;填;填8259中断中断7中断向量中断向量MOV SI,AX ;填偏移地址;填
2、偏移地址MOV AX,0000H ;段地址;段地址CS0000HMOV SI,003EHMOV SI,AX ;填段地址向量;填段地址向量CLI ;关中段;关中段POP DSIN AL,21H ;读;读8259中断屏蔽字中断屏蔽字AND AL,7FH ;开;开8259中断中断7OUT 21H,ALMOV CX,000AHA1:CMP CX,0000H JNZ A2IN AL,21HOR AL,80HOUT 21H,ALSTIHLTA2:STIJMP A1 ;断点;断点IRQ7:MOV AX,0137H ;中断程序入口地址;中断程序入口地址INT 10H ;BIOS功能调用,功能调用,MOV AX
3、,0120H ;显示;显示“7”和空格和空格INT 10HDEC CXMOV AL,20HOUT 20H,ALCLIIRET CODE ENDS END START实验实验48259中断实验中断实验注意注意:程序中程序中8259中断向量地址为绝对地址中断向量地址为绝对地址,已定义为已定义为段地址段地址CS=0000H,偏移地址偏移地址IP=2000H,故装载时一故装载时一定按此填入定按此填入CS与与IP地址地址.后面实验不再重述后面实验不再重述).分析程序分析程序 问题问题?实验考试实验考试如果改变为如果改变为IRQ3,或其它,程序应如何改动?或其它,程序应如何改动?实验实验58255并行接口
4、应用实验并行接口应用实验(1)STACK SEGMENT STACK DW 64 DUP(?)STACK ENDSCODE SEGMENT ASSUME CS:CODE,SS:STACKSTART:MOV AL,83H ;10000011 OUT 63H,ALA1:IN AL,61H OUT 60H,AL JMP A1CODE ENDS END START实验实验58255并行接口应用实验并行接口应用实验(2)STACK SEGMENT STACKDW 64 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODESTART:CLI ;关中断关中断MOV AL,86
5、H ;控制字控制字10000110OUT 63H,ALMOV AL,05H ;控制字控制字00000101pc2置位,置位,kk1下降沿触发下降沿触发OUT 63H,ALMOV AX,0000HMOV DS,AXMOV AX,OFFSET IRQ7ADD AX,2000H MOV SI,003CHMOV SI,AX MOV AX,0000HMOV SI,003EHMOV SI,AXIN AL,21HAND AL,7FHOUT 21H,ALA1:STI ;开中断开中断HLTJMP A1IRQ7:IN AL,61HOUT 60H,ALMOV AL,20HOUT 20H,ALIRETCODE END
6、S END STARTSTACK SEGMENT STACK DW 256 DUP(?)STACK ENDSDATA SEGMENTTABLE DB 01H,03H,02H,06H,04H,0CH,08H,09H DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART:MOV AX,DATA MOV DS,AXMAIN:MOV AL,90H OUT 63H,ALA1:MOV BX,OFFSET TABLE MOV CX,0008H A2:MOVAL,BX OUT61H,AL CALLDALLY INCBX LOOPA2 JMPA1DALLY:PUSH
7、CX MOV CX,5000HA3:PUSHAXPOPAXLOOPA3POPCXRETCODE ENDS END START 实验实验68253计数器应用实验计数器应用实验设定8253的2#通道工作方式为方式0,用于事件计数,当计数值为5时,发出中断请求信号,显示“M”。实验部分程序如下:Stack segment stack dw 64 dup(?)Stack endsCode segment assume ss:code,ss:stackStart:in al,21h and al,7fh out 21h,al MOV AL,90HOUT 43H,ALA1:MOV AL,05HOUT 42
8、H,AL hlt sti jmp a1 mov ax,014dh int 10h mov ax,0120h int 10h Mov al,20h out 20h,al iretCode ends end start 实验实验68253计数器应用实验计数器应用实验(2)实验实验68253计数器应用实验计数器应用实验(2)实验实验68253计数器应用实验计数器应用实验(2)STACK SEGMENT STACKDW 64 DUP(?)STACK ENDSCODE SEGMENTASSUME CS:CODESTART:PUSH DSMOV AX,0000HMOV DS,AXMOV AX,OFFSET
9、 IRQ0ADD AX,2000HMOV SI,0020HMOV SI,AXMOV AX,0000HMOV SI,0022HMOV SI,AXPOP DSMOV AL,0FCHOUT 21H,ALMOV AL,15HOUT 43H,ALMOV AL,0FFHOUT 40H,ALMOV DL,30HA1:STIJMP A1IRQ0:MOV AH,01HMOV AL,DL CMP AL,3AHJNZ A2MOV AL,0DHINT 10H实验实验68253计数器应用实验计数器应用实验(2)MOV AL,30HA2:INT 10HINC AXMOV DL,ALMOV AX,0120HINT 10HCALL DALLYMOV AL,20HOUT 20H,ALIRETDALLY:PUSH AXMOV CX,0100HA3:MOV AX,0560HA4:DEC AXJNZ A4LOOP A3POP AXRETCODE ENDS END START