微机原理与接口技术霓虹灯程序设计.docx
微机原理实验报告课 题 名: 霓虹灯设计 班 级: 学 号: _ 姓 名: 指导教师: 目录Ø实验目的3Ø实验要求3Ø实验原理3Ø实验内容3Ø程序代码4Ø程序及硬件系统调试情况9Ø设计总结与体会9Ø 实验目的在熟悉8086/8088指令系统的根底上,掌握8086/8088汇编语言程序设计方法;掌握8259可编程中断控制器,8255可编程并行接口的应用。Ø 实验要求模拟霓虹灯实验箱中的发光二极管交替变换的过程。用8255设计霓虹灯,三种以上变化:设计程序控制8个并排LED灯霓虹灯至少4种不同的状态的变换,选择8255的任一数据端口连接发光二极管模拟。运行过程中可随时中断退出。Ø 实验原理可通过DVCC8086单板机上的8255芯片来实现,利用8255A中的PC口,将其8位输出PC7PC0分别与8个LED灯L1L8相连,当PC口其中某位输出为“0时,那么对应LED灯亮。通过编程先对8255进展初始化,选择控制字,设置PC口为输出方式,然后给8088CPU中的AH赋值0EFH,采用循环移位指令对AH中的数值0EFH进展移位,最后将移位后的数据输到PC口,从而使8个LED灯按要求依次逐一点亮。 其他变化原理类似。Ø 实验内容² 八个灯半亮,半灭;² 依次从左向右亮,从右向左亮,循环三次;² 两边往中间,中间往两边亮,循环三次;² 单数灯依次从左向右亮,双数灯依次从右往左亮,循环三次。Ø 流程图初始化8255定义中断irq2,开场irq7矢量开场是否开场?8个LED灯L1L8全亮全灭闪烁2次从左向右从右向左依次循环,循环2次两边往中间,中间往两边循环,循环2次单数依次从左向右再双数亮,循环2次是否中断?完毕YNYØ 程序代码STACK SEGMENT STACKDW 64 DUP()stack endsCODE SEGMENTASSUME CS:CODE,SS:STACKSTART: CLI MOV BX,0010H MOV AL,80H OUT 63H,AL PUSH DS MOV AX,0000H MOV DS,AX MOV AX,OFFSET IRQ1 ADD AX,2000H MOV SI,0024H MOV SI,AX MOV AX,0000H MOV SI,0026H MOV SI,AX MOV AX,OFFSET IRQ5 ADD AX,2000H MOV SI,0034H MOV SI,AX MOV AX,0000H MOV SI,0036H MOV SI,AX POP DS IN AL,21H AND AL,0DDH OUT 21H,AL MOV AL,0FFH OUT 61H,ALa10: STI CMP BX,0000H JZ A11 JMP A10a11: STI MOV CX,3A1: MOV AL,80H ;半亮,半灭 OUT 63H,AL MOV AL,00H OUT 61H,AL CALL DALLY1 MOV AL,0FFH OUT 61H,AL CALL DALLY1 MOV AL,80H OUT 63H,AL MOV AL,0F0H OUT 61H,AL CALL DALLY1 MOV AL,80H OUT 63H,AL MOV AL,0FFH OUT 61H,AL CALL DALLY1 MOV AL,0FH OUT 61H,AL CALL DALLY2 LOOP A1 MOV CX,3A2: MOV AL,07EH ;两边往中间,中间往两边 OUT 61H,AL CALL DALLY1 MOV AL,0BDH OUT 61H,AL CALL DALLY1 MOV AL,0DBH OUT 61H,AL CALL DALLY1 MOV AL,0E7H OUT 61H,AL CALL DALLY1 MOV AL,0E7H OUT 61H,AL CALL DALLY1 MOV AL,0DBH OUT 61H,AL CALL DALLY1 MOV AL,0BDH OUT 61H,AL CALL DALLY1 MOV AL,07EH OUT 61H,AL CALL DALLY2 LOOP A2 MOV CX,2A3: MOV AL,07FH ;依次亮,左右 OUT 61H,AL CALL DALLY1 MOV AL,0BFH OUT 61H,AL CALL DALLY1 MOV AL,0DFH OUT 61H,AL CALL DALLY1 MOV AL,0EFH OUT 61H,AL CALL DALLY1 MOV AL,0F7H OUT 61H,AL CALL DALLY1 MOV AL,0FBH OUT 61H,AL CALL DALLY1 MOV AL,0FDH OUT 61H,AL CALL DALLY1 MOV AL,0FEH OUT 61H,AL CALL DALLY1 MOV AL,0FEH OUT 61H,AL CALL DALLY1 MOV AL,0FDH OUT 61H,AL CALL DALLY1 MOV AL,0FBH OUT 61H,AL CALL DALLY1 MOV AL,0F7H OUT 61H,AL CALL DALLY1 MOV AL,0EFH OUT 61H,AL CALL DALLY1 MOV AL,0DFH OUT 61H,AL CALL DALLY1 MOV AL,0BFH OUT 61H,AL CALL DALLY1 MOV AL,07FH OUT 61H,AL CALL DALLY2 LOOP A3 MOV cx,3A4: MOV AL,07FH ;单数依次从左向右亮,双数依次从右向左亮 OUT 61H,AL CALL DALLY1 MOV AL,0DFH OUT 61H,AL CALL DALLY1 MOV AL,0F7H OUT 61H,AL CALL DALLY1 MOV AL,0FDH OUT 61H,AL CALL DALLY1 MOV AL,0FEH OUT 61H,AL CALL DALLY1 MOV AL,0FBH OUT 61H,AL CALL DALLY1 MOV AL,0EFH OUT 61H,AL CALL DALLY1 MOV AL,0BFH OUT 61H,AL CALL DALLY2 LOOP A4 MOV AL,0FAH OUT 61H,AL CALL DALLY2 LOOP A4 MOV CX,3 JCXZ A12 JMP A11 a12: INT 21Hirq1: MOV AL,0FFH OUT 61H,AL MOV AL,20H OUT 20H,AL HLT IRETirq5: MOV BX,0000H MOV AL,20H IRETDALLY1 PROC PUSH AX PUSH CX MOV CX,0040HB1: MOV AX,0200HB2: DEC AX JNZ B2 LOOP B POP AX RETDALLY1 ENDPDALLY2 PROC PUSH AX PUSH CX MOV CX,0200HB3: MOV AX,0200HB4: DEC AX JNZ B4 LOOP B3 POP CX POP AX RETDALLY2 ENDPCODE ENDS END STARTØ 程序及硬件系统调试情况在Wmd86调试软件里面翻开程序,首先编译改程序,此时会弹出一个编译出错对话框,按提示的出错行数对应进展修改,修改完后再编译汇编链接。实验步骤 一² 关闭DVCC8086电源,按要求连接线路:8255芯片PB口输出端PB0PB7依次接D0D7IRQ5开场连接kk2IRQ1中断连接kk1² 翻开DVCC8086电源,输入u2000来查询程序是否装入,装入后键入G=2000,然后按下kk2观察指示灯的显示状态,然后按下kk1观察指示灯的亮灭情况。Ø 设计总结与体会经过这一周的专周, 做关于霓虹灯实验设计,我认真查阅资料,学习关于这方面的知识, 才真正体会到了其中的不易,每一个设计环节,稍有疏忽实验将难以成功。有了这次实验设计的经历,我想以后再遇到类似的问题我将会考虑的更加全面一些。第 14 页