具体要求:基于8086芯片实现。按键要求能够实现对二极管的点亮与熄灭的控制,用S1~S4组成的键盘分别控制4个发光二极管的点亮,S5按键来熄灭各二极管。按键具有防抖动功能,例如:S1点亮1号灯,按S5可以将其熄灭。S2点亮2号灯,按S5可以将其熄灭。这是我网上找的其他魔改的,只能到这一步了,请各位大哥门请教指正一下看看图,看看代码能不能简化,小弟拜上。
代码如下:CODE SEGMENT ASSUME CS:CODE
IOCON EQU 8006H IOA EQU 8000H IOB EQU 8002H
START:
MOV AL, 90H ; MOV DX, IOCON ; OUT DX, AL ;
MOV DX, IOA ; MOV AL, 0FFH OUT DX, AL
MOV AL, 0FFH ; MOV DX, IOB OUT DX, AL
MOV BL,0FFH TIMER: MOV DX, IOA ; IN AL, DX ;
CALL DELAY_MS ; IN AL, DX ;
CMP AL, 0FEH ; JE LED0 CMP AL, 0FDH JE LED1 CMP AL, 0FBH JE LED2 CMP AL, 0F7H JE LED3 CMP AL, 07FH JE LED_OFF
JMP TIMER ; LED0: AND AL, BL MOV DX, IOB OUT DX, AL MOV BL,AL JMP TIMER
LED1: AND AL, BL MOV DX, IOB OUT DX, AL MOV BL,AL JMP TIMER
LED2: AND AL, BL MOV DX, IOB OUT DX, AL MOV BL,AL JMP TIMER
LED3: AND AL, BL MOV DX, IOB OUT DX, AL MOV BL,AL JMP TIMER
LED_OFF: MOV AL, 0FFH MOV BL,0FFH MOV DX, IOB OUT DX, AL JMP TIMER DELAY_MS: PUSH CX MOV CX, 1000 JMP DELAY_LOOP
DELAY_LOOP: DEC CX ; JNZ DELAY_LOOP
POP CX RET ; CODE ENDS END START
|