实验源程序
P55A equ 288h ;8255A口输出
P55C equ 28ah ;8255C口输入
P55CTRL equ 28bh ;8255控制口
DATA SEGMENT
BUF db 0
MES DB 'K0-K6 ARE SPEED CONTROL',0AH,0DH
DB 'K6 IS THE LOWEST SPEED',0AH,0DH
DB 'K0 IS THE LOWEST SPEED',0AH,0DH
DB 'K7 IS THE DIRECTION CONTROL',0AH,0DH
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,CS
MOV DS,AX
MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET MES
MOV AH,09H
INT 21H
MOV DX,P55CTRL
MOV AL,8BH
OUT DX,AL ;8255C输入,A输出
MOV BUF,33H
OUT1:
MOV AL,BUF
MOV DX,P55A
OUT DX,AL
MOV AH,1
INT 16H
JE IN1 ;有无键按下
MOV AH,4CH
INT 21H
IN1:
MOV DX,P55C
IN AL,DX ;读开关状态
TEST AL,01H
JNZ K0
TEST AL,02H
JNZ K1
TEST AL,04H
JNZ K2
TEST AL,08H
JNZ K3
TEST AL,10H
JNZ K4
TEST AL,20H
JNZ K5
TEST AL,40H
JNZ K6
STOP:
MOV DX,P55A
MOV AL,0FFH
JMP OUT1
K0:
MOV BL,10H
SAM:
TEST AL,80H ;K7是否为
JZ ZX0
JMP NX0
K1:
MOV BL,18H
JMP SAM
K2:
MOV BL,20H
JMP SAM
K3:
MOV BL,40H
JMP SAM
K4:
MOV BL,80H
JMP SAM
K5:
MOV BL,0C0H
JMP SAM
K6:
MOV BL,0FFH
JMP SAM
ZX0:
CALL DELAY
MOV AL,BUF
ROR AL,1 ;循环右移
MOV BUF,AL
JMP OUT1
NX0:
CALL DELAY
MOV AL,BUF
ROL AL,1 ;循环左移
MOV BUF,AL
JMP OUT1
DELAY PROC NEAR
DELAY1:
MOV CX,05A4H
DELAY2:
LOOP DELAY2
DEC BL
JNZ DELAY1
RET
DELAY ENDP
CODE ENDS
END START
温馨提示:答案为网友推荐,仅供参考