实验四:
(引用讲义上已给出的图)
实验五:
开始 扫描键盘 否 是否有键按下 是
四 源程序
实验三
DATA SEGMENT DATA ENDS
STACK SEGMENT STACK 'STACK' DB 100 DUP(?) STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA MOV DS,AX
MOV DX,28BH ;8255初始化,10001001,C口输入,A口输出 MOV AL,89H OUT DX,AL
LOOP1: MOV DX,28AH ;C口输入 IN AL,DX
MOV DX,288H ;A口输出 OUT DX,AL
MOV AH,01H INT 16H
JNZ EXIT ;ZF=0说明有按键输入,故退出 JMP LOOP1
EXIT: MOV AX,4C00H INT 21H CODE ENDS
END START
实验四
DATA SEGMENT DATA ENDS
STACK SEGMENT STACK 'STACK' DB 100 DUP(?) STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA MOV DS,AX
MOV DX,28BH ;8255 MOV AL,80H ; OUT DX,AL ;
DIGITAL:MOV DX,28AH ; MOV AL,00H OUT DX,AL
MOV DX,288H ;A MOV AL,6DH OUT DX,AL
MOV DX,28AH ;C MOV AL,01H OUT DX,AL
控制寄存器端口地址28BH 工作方式为0 初始化8255 熄灭数码管 口显示5 口00000001(位码) MOV DX,28AH ;熄灭数码管 MOV AL,00H OUT DX,AL
MOV DX,288H ;A口显示2 MOV AL,5BH OUT DX,AL
MOV DX,28AH ;C口00000010(位码) MOV AL,02H OUT DX,AL
MOV DX,28AH ; MOV AL,00H OUT DX,AL
MOV DX,288H ;A MOV AL,7DH OUT DX,AL MOV DX,28AH
MOV AL,04H ;C OUT DX,AL
MOV DX,28AH ; MOV AL,00H OUT DX,AL
MOV DX,288H ;A MOV AL,3FH OUT DX,AL
MOV DX,28AH
MOV AL,08H ;C OUT DX,AL
MOV DX,28AH ; MOV AL,00H OUT DX,AL
MOV AH,01H INT 16H
JNZ EXIT ;ZF=0 JMP DIGITAL
EXIT: MOV AX,4C00H INT 21H
CODE ENDS
END START
熄灭数码管 口显示6 口00000100(位码) 熄灭数码管 口显示0 口00001000(位码) 熄灭数码管 说明有按键输入,故退出