要求用8255作为键盘和数码管接口。用行扫描法从试验台上小键盘的数字字母区读取‘0’-‘9’或‘A’-‘F’按键值,并显示在某数码管上。
8255作键盘和数码管接口综合设计实验:
实验要求:要求用8255作为键盘和数码管接口。用行扫描法从试验台上小键盘的数字字母区读取‘0’-‘9’或‘A’-‘F’按键值,并显示在某数码管上。
程序:
data segment
io8255a equ 288h
io8255b equ 289h
io8255c equ 28ah
io8255z equ 28bh
key db 37h,38h,39h,41h,54h,52h
db 34h,35h,36h,42h,53h,4dh
db 31h,32h,33h,43h,48h,4ch
db 30h,46h,45h,44h,58h,4eh
led1 db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,6fh
led2 db 77h,7ch,39h,5eh,79h,71h
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
lp0:
mov dx,io8255z
mov al,90h
out dx,al
lp1:mov di,0
mov si,0
mov ah,11111110b
mov cx,4
lp2:mov al,ah
mov dx,io8255c
out dx,al
mov dx,io8255a
in al,dx
and al,00111111b
cmp al,00111111b
jnz realy
rol ah,1
loop lp2
要求用8255作为键盘和数码管接口。用行扫描法从试验台上小键盘的数字字母区读取‘0’-‘9’或‘A’-‘F’按键值,并显示在某数码管上。
jmp lp1
realy:
push ax
mov dx,io8255a in al,dx
nop
nop
nop
nop
and al,3fh
cmp al,3fh
jnz realy
pop ax
l4: mov cx,6
lp4:shr al,1
jnc l3
inc si
loop lp4
l3: mov cx,4
mov al,ah lp3:shr al,1
jnc lp5
inc di
loop lp3
lp5:mov bx,di
mov al,6
mul bl
add ax,si
disp:
mov bx,offset key xlat
cmp al,39h jl ll
cmp al,40h jg lll
ll: sub al,30h
mov bx,offset led1
要求用8255作为键盘和数码管接口。用行扫描法从试验台上小键盘的数字字母区读取‘0’-‘9’或‘A’-‘F’按键值,并显示在某数码管上。
xlat
mov dx,io8255b out dx,al
jmp lp1
lll: sub al,41h
mov bx,offset led2 xlat
mov dx,io8255b out dx,al
jmp lp1
exit:
mov ah,4ch int 21h
delay proc near push cx
mov cx,20h l1: loop l1 pop cx
ret
delay endp
code ends
end start