北大接口所有上机类型题目和答案(2)
3.8255方式0,C口低4位输入数据取反,在8255的C口高4位输出,有键按下返回DOS,无键按下继续执行。
code segment
assume cs:code
start: mov dx,28bh
mov al,81h
out dx,al
l1: mov dx,28ah
in al,dx
mov cl,4
shl al,cl
xor al,0f0h
mov dx,28ah
out dx,al
mov ah,1
int 16h
jz l1
mov ah,4ch
int 21h
code ends
4. 8255方式0,A口输入,C口输出。如果A口输入的数大于等于128,从C口输出80H;否则将输入的数高4位不变低4位取反从C口输出,有键按下返回DOS,无键按下继续执行。
code segment
assume cs:code
start: mov dx,28bh
mov al,90h
out dx,al
l3: mov dx,288h
in al,dx
cmp al,80h
jae l1
xor al,0fh
mov dx,28ah
out dx,al
l2: mov ah,1
int 16h
jz l3
mov ah,4ch
int 21h
l1: mov al,80h
mov dx,28ah
out dx,al
jmp l2
code ends
end start
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