第1个回答 推荐于2017-10-06
DATA SEGMENT
TIM DB 7FH ;设置初始值
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,0EEE0H
IN AL,DX ;读取当前端口状态
AND AL,TIM
JNZ OVR
MOV AL,7FH ;先点亮第一个灯
MOV DX,0EEE0H
LOOP1: OUT DX,AL
CALL DELAY
MOV BL,AL
ROR AL,1 ;右移,点亮下一个灯
MOV BL,AL
MOV AH,0BH ;检测键盘输入
INT 21H
OR AL,AL
JZ LOOP1 ;循环点亮
MOV AX,4C00H ;程序结束
INT 21H
OVR:NOP
RET
DELAY PROC NEAR ;延时子程序
NOP
PUSH CX
MOV CX,0FFFFH
CONTI: LOOP CONTI
POP CX
RET
DELAY ENDP
MOV AX,4C00H
INT 21H
CODE ENDS
END START本回答被提问者采纳