您的位置:首页 > 其它

【实验】动态显示二位七段数码管

2012-04-14 21:12 369 查看
【实验内容】

将8255的A口PA0~PA6分别与七段数码管的段码驱动输入端a~g相连(方式0),位码驱动输入端S2、S1接8255C口的PB1、PB0。PC0~0C7分别接开关K1~K8,开关合上为0,断开为1,在七段数码管上显示开关K8-K1八位二进制数的十六进制形式。
【实验电路图】



【流程图】



【程序】

.8086
.model small
.data
led db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh,77h,7ch,39h,5eh,79h,71h
ioporta equ 60h
ioportb equ 61h
ioportc equ 62h
.stack
.code
start:
mov ax,@data
mov ds,ax

mov dx,ioporta
mov al,10001001b
out dx,al;初始化8255 a、b口输出 c口输入
play:
mov al,1h
mov dx,ioportb
out dx,al;输出b口 选择个位
mov dx,ioportc
in al,dx;输入c口数据
and al,0fh;
mov bx,offset led
xlat;
mov dx,ioporta
out dx,al;从a口输出
call delay

mov al,2h
mov dx,ioportb
out dx,al;
mov dx,204h
in al,dx;输入c口数据
and al,0f0h
mov cl,4
shr al,cl
mov bx,offset led
xlat;
mov dx,ioiporta
out dx,al;
call delay
jmp play

;延时子程序
delay proc
push cx
push ax
mov ax,6
x1:	mov cx,0080h;调整可以更改延迟时间
x2:	dec cx
jne x2
dec ax
jne x1
pop ax
pop cx
ret
delay endp
mov ah,4ch
int 21h
end start
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: