北大“接口技术”上机类型题目及答案(2)
5. 8255方式0,A口输入C口输出,如果A口的PA7输入为0,则L5、L2灯亮,PA7 为1,则L7、L0灯亮,有键按下返回DOS,无键按下继续执行。
code segment
assume cs:code
start: mov dx,28bh
mov al,90h
out dx,al
l3: mov dx,288h
in al,dx
test al,80h
jz l1
mov al,81h
mov dx,28ah
out dx,al
l2: mov ah,1
int 16h
jz l3
mov ah,4ch
int 21h
l1: mov dx,28ah
mov al,24h
out dx,al
jmp l2
code ends
end start
6. 8255方式0,A口输出C口输入,C口输入高2为位取反低6位不变,用键盘控制程序,有键按下返回DOS,无键按下程序继续执行。
code segment
assume cs:code
start: mov dx,28bh
mov al,89h
out dx,al
l1: mov dx,28ah
in al,dx
xor al,0c0h
mov dx,288h
out dx,al
mov ah,1
int 16h
jz l1
mov ah,4ch
int 21h
code ends
end start
7. 8255方式0,A口输出到LED灯上,让灯按顺序从左到右移动显示,每显示一个灯延时一秒在显示下一个灯,有键按下返回DOS,无键按下继续执行。
code segment
assume cs:code
start: mov dx,28bh
mov al,80h
out dx,al
mov dx,288h
mov al,01h
l1: out dx,al
call time
rol al,1
mov ah,1
int 16h
jz l1
mov ah,4ch
int 21h
time proc near
push cx
mov si,0200h
t2: mov cx,0
t1: loop t1
dec si
jnz t2
pop cx
ret
time endp
code ends
end start
8. 8255方式0,C口输入0~Fh,A口输出在数码管上显示和计算机显示器显示相应数, 有键按下返回DOS,无键按下继续执行。
data segment
led db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,67h,77h,7ch,39h,5eh,79h,71h
data ends
code segment
assume cs:code,ds:data
start: mov dx.,28bh
mov al,89h
out dx,al
lea bx,led
l1: mov dx,28ah
in al,dx
and al,0fh
call disp
xlat
mov dx,288h
out dx,al
mov ah,1
int 16h
jz l1
mov ah,4ch
int 21h
disp proc near
push dx
push ax
mov dl,al
cmp dl,0ah
jb d1
add dl,7
d1: add dl,30h
mov ah,02
int 21h
mov dl,0dh
int 21h
mov dl,0ah
int 21h
pop ax
pop dx
disp endp
code ends
end start
9. 8255方式0,C口输入0~Fh,A口输出在数码管上显示对应数,计算机显示器显示该数加1, 有键按下返回DOS,无键按下继续执行。(在计算机显示器上即输入0显示1,输入F时显示G)。
data segment
led db 3fh,06h,5bh,4fh,66h,6dh,7dh,07h,7fh,67h,77h,7ch,39h,5eh,79h,71h
data ends
code segment
assume cs:code,ds:data
start: mov dx.,28bh
mov al,89h
out dx,al
lea bx,led
l1: mov dx,28ah
in al,dx
and al,0fh
call disp
xlat
mov dx,288h
out dx,al
mov ah,1
int 16h
jz l1
mov ah,4ch
int 21h
disp proc near
push dx
push ax
add al,1
mov dl,al
cmp dl,0ah
jb d1
add dl,7
d1: add dl,30h
mov ah,02
int 21h
mov dl,0dh
int 21h
mov dl,0ah
int 21h
pop ax
pop dx
disp endp
code ends
end start