【实验】动态显示二位七段数码管
【实验内容】
将8255的A口PA0~PA6分别与七段数码管的段码驱动输入端a~g相连(方式0),位码驱动输入端S2、S1接8255C口的PB1、PB0。PC0~0C7分别接开关K1~K8,开关合上为0,断开为1,在七段数码管上显示开关K8-K1八位二进制数的十六进制形式。
【实验电路图】
【流程图】
【程序】
1 .8086 2 .model small 3 .data 4 led db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,77h,7ch,39h,5eh,79h,71h;初始化段码表 5 portA equ 200h 6 portB equ 202h 7 portC equ 204h;初始化8255三个端口的地址 8 .stack 9 .code 10 start: 11 mov ax,@data 12 mov ds,ax 13 14 mov dx,portA 15 mov al,10001001b 16 out dx,al;初始化8255 a、b口输出 c口输入 17 play: 18 mov al,1h 19 mov dx,portB 20 out dx,al;输出b口 选择个位 21 mov dx,portC 22 in al,dx;输入c口数据 23 and al,0fh;获取后四位 24 mov bx,offset led 25 xlat;查表获取段码 26 mov dx,portA 27 out dx,al;从a口输出 28 call delay;调用延时子程序 29 30 mov al,2h 31 mov dx,portB 32 out dx,al;输出b口 选择十位 33 mov dx,portC 34 in al,dx;输入c口数据 35 and al,0f0h 36 mov cl,4 37 shr al,cl 38 mov bx,offset led 39 xlat;查询获取前四位的段码 40 mov dx,portA 41 out dx,al;输出 42 call delay;调用延时子程序 43 jmp play 44 45 ;延时子程序 46 delay proc 47 push cx 48 push ax 49 mov ax,6 50 ;双层循环实现延时 51 x1: mov cx,0080h;调整可以更改延迟时间 52 x2: dec cx 53 jne x2 54 dec ax 55 jne x1 56 pop ax 57 pop cx 58 ret 59 delay endp 60 mov ah,4ch 61 int 21h;程序结束 62 end start
stay hungry...