本项目是基于8086的点阵显示,可以通过按键显示所要显示的内容
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- IOY0 EQU 0C400H ;片选第一片8255的地址
- IOY1 EQU 0C440H ;片选第二片8255的地址
- O8255_A EQU IOY0+00*2 ;第一片8255的地址的A口
- O8255_B EQU IOY0+01*2 ;第一片8255的地址的B口
- O8255_C EQU IOY0+10*2 ;第一片8255的地址的C口
- O8255_MODE EQU IOY0+11*2 ;第一片8255的地址的控制字寄存器
- T8255_A EQU IOY1+00*2 ;第二片8255的地址的A口
- T8255_B EQU IOY1+01*2 ;第二片8255的地址的B口
- T8255_C EQU IOY1+10*2 ;第二片8255的地址的C口
- T8255_MODE EQU IOY1+11*2 ;第二片8255的地址的控制字寄存器
- DATAS SEGMENT
- ;此处输入数据段代码
- COUNT1 DB 00H
- COUNT2 DB 01H
- TAB DB 08H,02H,18H,02H,0C8H,3FH,14H,02H,32H,02H,11H,02H,0E8H,7FH,08H,08H
- DB 0CH,08H,0EAH,7FH,08H,08H,88H,08H,88H,08H,08H,08H,08H,0AH,08H,04H ;待
- DB 08H,00H,08H,1FH,08H,11H,7FH,11H,08H,11H,08H,11H,1CH,11H,2CH,11H
- DB 2AH,11H,0AH,11H,89H,10H,88H,50H,48H,50H,48H,50H,28H,60H,08H,00H ;机
- DB 00H,01H,00H,01H,3FH,01H,0A0H,7FH,0A1H,20H,52H,12H,14H,02H,08H,02H
- DB 18H,02H,18H,06H,24H,05H,24H,09H,82H,18H,61H,70H,1CH,20H,00H,00H ;欢
- DB 02H,00H,84H,01H,6CH,3EH,24H,22H,20H,22H,20H,22H,27H,22H,24H,22H
- DB 0A4H,22H,64H,2AH,24H,12H,04H,02H,04H,02H,0AH,00H,0F1H,7FH,00H,00H ;迎
- DB 80H,08H,82H,08H,84H,08H,0ECH,3FH,84H,08H,80H,08H,80H,08H,0EFH,7FH
- DB 88H,08H,88H,08H,48H,08H,48H,08H,28H,08H,14H,00H,0E2H,7FH,00H,00H ;进
- DB 30H,00H,60H,00H,40H,00H,80H,00H,0C0H,00H,40H,01H,40H,01H,20H,02H
- DB 20H,04H,10H,04H,10H,08H,08H,10H,04H,70H,02H,20H,01H,00H,00H,00H ;入
- DB 00H,3EH,0FCH,01H,40H,04H,20H,04H,10H,02H,0F8H,01H,0C0H,04H,30H,08H
- DB 0FCH,1FH,08H,31H,20H,05H,10H,09H,08H,11H,04H,21H,42H,21H,80H,00H ;系
- DB 08H,02H,08H,04H,0C4H,7FH,04H,02H,22H,02H,1FH,11H,90H,20H,0C8H,7FH
- DB 04H,29H,3EH,09H,00H,09H,00H,09H,0B8H,48H,87H,48H,40H,70H,20H,00H ;统
- DB 00H,00H,00H,00H,00H,00H,00H,00H,08H,00H,08H,00H,08H,00H,08H,00H
- DB 08H,00H,08H,00H,08H,00H,08H,00H,08H,00H,00H,00H,08H,00H,00H,00H ;!
- DB 0FEH,3FH,80H,00H,80H,00H,0F8H,0FH,88H,08H,88H,08H,0F8H,0FH,88H,08H
- DB 88H,08H,88H,08H,0FFH,7FH,08H,08H,08H,08H,08H,08H,08H,0AH,08H,04H ;再
- DB 0F8H,0FH,08H,08H,08H,08H,88H,08H,88H,08H,88H,08H,88H,08H,88H,08H
- DB 48H,09H,40H,01H,20H,01H,20H,21H,10H,21H,0CH,61H,03H,3EH,00H,00H ;见
- DATAS ENDS
- STACKS SEGMENT
- ;此处输入堆栈段代码
- N1 DB 100 DUP(?)
- STACKS ENDS
- CODES SEGMENT
- ASSUME CS:CODES,DS:DATAS,SS:STACKS
- START:
- MOV AX,DATAS
- MOV DS,AX
- MOV DX,O8255_MODE
- MOV AL,81H
- OUT DX,AL ;第一片8255方式选择
- MOV DX,T8255_MODE
- MOV AL,80H
- OUT DX,AL ;第二片8255方式选择
- MOV CX,0
- CALL C1
- X: CALL C2
- MOV SI,0000H ;指针赋值0
- MOV AH,2 ;显示“待机”
- JMP X0
- Y: CALL C2
- MOV AH,7 ;显示“欢迎进入系统”
- MOV SI,0040H
- MOV DI,SI
- JMP X0
- Z: CALL C2
- MOV AH,2 ;显示“再见”
- MOV SI,0120H
- MOV DI,SI
- X0: PUSH CX
- MOV BX,1024 ;整体循环1024次
- X1: PUSH BX
- MOV BH,COUNT1 ;初始化
- MOV BL,COUNT2
- CLC ;CF位清零
- RER: MOV CX,16 ;循环次数
- MOV SI,DI ;指向原来的位置
- LOOP1:
- MOV DX,T8255_A ;清除列
- MOV AL,00H
- OUT DX,AL
- MOV DX,T8255_B
- MOV AL,00H
- OUT DX,AL
- CALL FI
- INC SI ;指针再次加1
- RCL BL,1 ;每次循环向左移动1位
- RCL BH,1 ;连带CF位一同左移1位
- DEC CX ;循环次数减1
- CMP CX,0 ;循环次数大于0,就继续循环
- JNZ LOOP1
- POP BX ;第二重循环计数
- DEC BX
- CMP BX,0
- JNZ X1
- LOOP3:
- POP CX ;第三重循环,控制显示哪些字
- INC CX
- MOV DI,SI
- CMP CL,AH
- JNZ X0 ;显示程序结束
- MOV DI,0000H
- MOV AH,0
- MOV CX,0
- CALL C1
- MOV AH,4CH
- INT 21H
- C1: MOV DX,O8255_C ;读取C口状态
- IN AL,DX
- CMP AL,0EH ;判断按下的是第几个按键,依次跳转
- JZ X
- CMP AL,0DH
- JZ Y
- CMP AL,0BH
- JZ Z
- O: MOV DX,O8255_C ;初始化键盘扫描输入
- PUSH AX
- MOV AL,0FH
- OUT DX,AL
- POP AX
- JMP C1
- RET
- C2: MOV DX,O8255_C ;对数码管的输出
- PUSH AX
- CALL C3
- OUT DX,AL
- POP AX
- RET
- C3: CMP AL,0EH ;数码管输出变量
- JZ M1
- CMP AL,0DH
- JZ M2
- CMP AL,0BH
- JZ M3
- M1: MOV AL,17H
- RET
- M2: MOV AL,27H
- RET
- M3: MOV AL,37H
- RET
- FI: MOV DX,O8255_A ;循环行扫描
- MOV AL,BL
- OUT DX,AL
- MOV DX,O8255_B
- MOV AL,BH
- OUT DX,AL
- LOOP2:
- MOV DX,T8255_A ;循环列扫描
- MOV AL,TAB[SI]
- OUT DX,AL
- INC SI ;指针加1,指向下一个数据
- MOV DX,T8255_B
- MOV AL,TAB[SI]
- OUT DX,AL
- RET
- CODES ENDS
- END START
复制代码 以上是代码
附件只包含1个文件 Proteus仿真文件下载:
基于8086点阵.zip
(109.44 KB, 下载次数: 42)
|