【實驗】動態顯示二位七段數碼管

【實驗內容】

8255APA0PA6分別與七段數碼管的段碼驅動輸入端ag相連(方式0),位碼驅動輸入端S2S18255C口的PB1PB0PC0~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



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章