【正文】
qu 1403h 。8255 的控制寄存器地址 mode_a db 10001001b 。控制字 data ends code segment assume cs:code,ds:data start: MOV DX, 1406H 。寫控制口 MOV AL, 90H OUT DX, AL READ: MOV DX, 1400H 。寫 A 端口 IN AL, DX MOV DX, 1402H 。寫 B 端口 。倒計時過程 到了 0 開始搶答 MOV SI, 5 TIME: 。延時等待 MOV CX, 0FFFFH delay: LOOP delay MOV AL, TABLE[SI] OUT DX, AL DEC SI JNZ TIME MOV BL, AL A1: TEST AL, 01H JZ key1 A2: TEST AL, 02H JZ key2 A3: TEST AL, 04H CMP AL, 0FFH A4: TEST AL, 08H JZ key4 A5: TEST AL, 10H JZ key5 A6: TEST AL, 20H JZ key6 A7: TEST AL, 40H JZ key7 A8: TEST AL, 80H JZ key8 。無人搶答 MOV AL, TABLE[0] OUT DX, AL NEXT: 。等待輸入空格鍵或者 Esc 到下一輪搶答或者退出程序 MOV AH, 1 INT 21H 。 CMP AL, 32 。是否為 空格 JZ READ CMP AL, 27 。是否為 Esc JZ END key1: MOV AL, TABLE[1] OUT DX, AL JMP NEXT key2: MOV AL, TABLE[2] OUT DX, AL JMP NEXT key3: MOV AL, TABLE[3] OUT DX, AL JMP NEXT key4: MOV AL, TABLE[4] OUT DX, AL JMP NEXT key5: MOV AL, TABLE[5] OUT DX, AL JMP NEXT key6: MOV AL, TABLE[6] OUT DX, AL JMP NEXT key7: MOV AL, TABLE[7] OUT DX, AL JMP NEXT key8: MOV AL, TABLE[8] OUT DX, AL JMP NEXT 。 OUT DX, AL 。 JMP READ END: mov ax, 4c00h int 21h CODE ENDS end start