Z8279 EQU 212H D8279 EQU 210H LEDMOD EQU 00h ;左邊輸入,八位顯示外部譯碼八位顯示 LEDFEQ EQU 38H ;掃描頻率 CODE SEGMENT ASSUME CS:CODE,DS:CODE START: ;初始化 \ PUSH CS OUT DX,AL POP ds MOV DX,Z8279 MOV AL,LEDMOD MOV AL,LEDFEQ OUT DX,AL MOV DX,D8279 MOV AL,7FH OUT DX,AL MOV DX,D8279 MOV AL,7FH OUT DX,AL MOV DX,D8279 MOV AL,7DH OUT DX,AL MOV DX,D8279 MOV AL,7FH OUT DX,AL MOV DX,D8279 MOV AL,70H OUT DX,AL MOV DX,D8279 MOV AL,5bH OUT DX,AL MOV DX,D8279 MOV AL,70H OUT DX,AL MOV DX,D8279 MOV AL,76H OUT DX,AL ;以上為寫(HKZK88) NOP MOV DX,Z8279 MOV AL,0C2H OUT DX,AL ;置空FIFO暫存器 MOV CL,00H ;改 WAIIT: NOP IN AL,DX MOV BL,AL AND AL,80H CMP AL,80H JE WAIIT ;FIFO正在清除期間則跳轉等待 MOV AL,BL AND AL,0FH CMP AL,00H JE WAIIT ;無鍵按下則等待 CMP CL,02H JE OUTPUT NEXT: MOV AL,40H ;寫 讀FIFO RAM命令字 OUT DX,AL MOV DX,D8279 ;讀入FIFO RAM內容 IN AL,DX NOP CMP AL,3bH JE FINI ;查表,將鍵碼放入AL中 LEA BX,LED XLAT MOV DX,D8279 ;將AL中內容寫到數碼管上 OUT DX,AL MOV DX,Z8279 ;清FIFO RAM暫存器 MOV AL,0C2H OUT DX,AL inc cl and cl,07h JMP WAIIT ;等待下一次鍵輸入 FINI:MOV DX,Z8279 MOV AL,0D3H OUT DX,AL JMP $ LED DB 07H,66H,06H,3FH DB 00H,00H,00H,00H DB 7FH,6DH,5BH,71H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 6FH,7DH,4FH,79H DB 00H,00H,00H,00H DB 77H,7CH,39H,5EH DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H output: ;改 push dx push ax mov dx,d8279 mov al,7fh ;8 out dx,al mov dx,d8279 mov al,7fh ;8 oUt dx,al inc cl inc cl pop ax pop dx jmp next CODE ENDS END START
Z8279 EQU 212H D8279 EQU 210H LEDMOD EQU 00h ;左邊輸入,八位顯示外部譯碼八位顯示 LEDFEQ EQU 38H ;掃描頻率 CODE SEGMENT ASSUME CS:CODE,DS:CODE START: ;初始化 \ PUSH CS OUT DX,AL POP ds MOV DX,Z8279 MOV AL,LEDMOD MOV AL,LEDFEQ OUT DX,AL MOV DX,D8279 MOV AL,7FH OUT DX,AL MOV DX,D8279 MOV AL,7FH OUT DX,AL MOV DX,D8279 MOV AL,7DH OUT DX,AL MOV DX,D8279 MOV AL,7FH OUT DX,AL MOV DX,D8279 MOV AL,70H OUT DX,AL MOV DX,D8279 MOV AL,5bH OUT DX,AL MOV DX,D8279 MOV AL,70H OUT DX,AL MOV DX,D8279 MOV AL,76H OUT DX,AL ;以上為寫(HKZK88) NOP MOV DX,Z8279 MOV AL,0C2H OUT DX,AL ;置空FIFO暫存器 MOV CL,00H ;改 WAIIT: NOP IN AL,DX MOV BL,AL AND AL,80H CMP AL,80H JE WAIIT ;FIFO正在清除期間則跳轉等待 MOV AL,BL AND AL,0FH CMP AL,00H JE WAIIT ;無鍵按下則等待 CMP CL,02H JE OUTPUT NEXT: MOV AL,40H ;寫 讀FIFO RAM命令字 OUT DX,AL MOV DX,D8279 ;讀入FIFO RAM內容 IN AL,DX NOP CMP AL,3bH JE FINI ;查表,將鍵碼放入AL中 LEA BX,LED XLAT MOV DX,D8279 ;將AL中內容寫到數碼管上 OUT DX,AL MOV DX,Z8279 ;清FIFO RAM暫存器 MOV AL,0C2H OUT DX,AL inc cl and cl,07h JMP WAIIT ;等待下一次鍵輸入 FINI:MOV DX,Z8279 MOV AL,0D3H OUT DX,AL JMP $ LED DB 07H,66H,06H,3FH DB 00H,00H,00H,00H DB 7FH,6DH,5BH,71H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 6FH,7DH,4FH,79H DB 00H,00H,00H,00H DB 77H,7CH,39H,5EH DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H DB 00H,00H,00H,00H output: ;改 push dx push ax mov dx,d8279 mov al,7fh ;8 out dx,al mov dx,d8279 mov al,7fh ;8 oUt dx,al inc cl inc cl pop ax pop dx jmp next CODE ENDS END START