8人抢答器(简易版 含代码、电路图)
2020-12-09 知乎
电路图
代码
IOY0 EQU 0600H ;片选IOY0对应的端口始地址 MY8255_A EQU IOY0+00H*2 ;8255的A口地址 MY8255_B EQU IOY0+01H*2 ;8255的B口地址 MY8255_C EQU IOY0+02H*2 ;8255的C口地址 MY8255_MODE EQU IOY0+03H*2 ;8255的控制寄存器地址 SSTACK SEGMENT STACK DW 32 DUP(?) SSTACK ENDS CODE SEGMENT ASSUME CS:CODE START: MOV DX, MY8255_MODE MOV AL, 90H OUT DX, AL AA1: MOV DX,MY8255_A IN AL,DX CALL DELAY CMP AL,00H ;判断开关是否按下 JZ AA1 CMP AL,01H ;按下的是第一个开关 0000 0001 JZ T1 CMP AL,02H ;按下的是第二个开关 0000 0010 JZ T2 CMP AL,04H ;按下的是第三个开关 0000 0100 JZ T3 CMP AL,08H ;按下的是第四个开关 0000 1000 JZ T4 CMP AL,10H ;按下的是第五个开关 0001 0000 JZ T5 CMP AL,20H JZ T6 CMP AL,40H JZ T7 CMP AL,80H JZ T8 T1: ;若按下的是第一个 则显示1 送06H给B口 MOV AL,06H MOV DX,MY8255_B OUT DX,AL JMP AA1 T2: MOV AL,5BH MOV DX,MY8255_B OUT DX,AL JMP AA1 T3: MOV AL,4FH MOV DX,MY8255_B OUT DX,AL JMP AA1 T4: MOV AL,66H MOV DX,MY8255_B OUT DX,AL JMP AA1 T5: MOV AL,6DH MOV DX,MY8255_B OUT DX,AL JMP AA1 T6: MOV AL,7CH MOV DX,MY8255_B OUT DX,AL JMP AA1 T7: MOV AL,07H MOV DX,MY8255_B OUT DX,AL JMP AA1 T8: MOV AL,7FH MOV DX,MY8255_B OUT DX,AL JMP AA1 DELAY: PUSH CX MOV CX, 0F000H AA2: PUSH AX POP AX LOOP AA2 POP CX RET CODE ENDS END START