这个电路哪里有问题,I/O译码出的信号有问题但是找不出来。代码如下
A8255 EQU 0000H
B8255 EQU 0002H
C8255 EQU 0004H
CTR8255 EQU 0006H
CH0 EQU 0200H
CTR8253 EQU 0206H
AD245 EQU 0100H ; 74LS245地址
CODE SEGMENT 'CODE'
ASSUME DS:DATA,CS:CODE,SS:SSEG
START:MOV AX,SSEG
MOV SS,AX
MOV AX,TOP
MOV SP,AX
MOV AX,DATA
MOV DS,AX
CLI
MOV AX,0
MOV ES,AX
MOV BX,2*4
MOV AX,OFFSET INTR_KEY
MOV WORD PTR ES:[BX],AX
MOV AX,SEG INTR_KEY
MOV WORD PTR ES:[BX+2],AX
STI
MOV AX,DATA
MOV ES,AX
MOV AL,89H
MOV DX,CTR8255
OUT DX,AL
RUN:
CALL RUNNING
JMP RUN
INTR_KEY PROC
PUSH AX
PUSH BX
PUSHF
CALL KEY
TEST AL,01H
JZ K1
TEST AL,02H
JZ K2
TEST AL,04H
JZ K3
K1: MOV KEYST,1
JMP FIN
K2: MOV KEYST,2
INC PAUSEKEY
JMP FIN
K3: MOV KEYST,3
JMP FIN
FIN: POPF
POP BX
POP AX
IRET
INTR_KEY ENDP
RUNNING PROC
AGAIN: CMP KEYST,1
JZ T1
CMP KEYST,2
JZ T2
CMP KEYST,3
JZ T3
JMP E0
T1: CALL TIME
JMP E0
T2: TEST PAUSEKEY,1
JZ T1
JMP E0
T3: CALL RESET
E0: CALL DISP
RET
RUNNING ENDP
TIME PROC
PUSH AX
PUSH SI
LEA SI,TIMEBUF
MOV AX,[SI]
INC AH
CMP AH,100
JZ S1
MOV [SI],AH
JMP S5
S1:MOV AH,0
MOV [SI],AH
MOV AH,[SI+1]
INC AH
CMP AH,60
JZ S2
MOV [SI+1],AH
JMP S5
S2:MOV AH,0
MOV [SI+1],AH
MOV AH,[SI+2]
INC AH
CMP AH,60
JZ S3
MOV [SI+2],AH
JMP S5
S3:MOV AH,0
MOV [SI+2],AH
MOV AH,[SI+3]
INC AH
CMP AH,24
JZ S4
MOV [SI+3],AH
JMP S5
S4:MOV AL,0
LEA DI,TIMEBUF
MOV CX,4
CLD
REP STOSB
S5:CALL DIGIT
CALL DELAY8253
POP SI
POP AX
RET
TIME ENDP
DIGIT PROC
PUSH AX
PUSH BX
PUSH CX
PUSH SI
PUSH DI
MOV BL,4
LEA DI,LEDBUF
LEA SI,TIMEBUF
NEXT:LODSB
MOV AH,0
MOV CL,10
DIV CL
XCHG AH,AL
STOSB
MOV AL,AH
STOSB
DEC BL
JNZ NEXT
POP DI
POP SI
POP CX
POP BX
POP AX
RET
DIGIT ENDP
DISP PROC
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH SI
LEA BX,LEDTAB
LEA SI,LEDBUF
MOV CX,8
MOV AH,7FH
LOOP1:
MOV AL,[SI]
XLAT
MOV DX,A8255
OUT DX,AL
MOV AL,AH
MOV DX,B8255
OUT DX,AL
CALL DELAY
ROR AH,1
INC SI
CALL CLRLED
LOOP LOOP1
POP SI
POP DX
POP CX
POP BX
POP AX
RET
DISP ENDP
CLRLED PROC
PUSH AX
PUSH DX
MOV AL,0FFH
MOV DX,B8255
OUT DX,AL
POP DX
POP AX
RET
CLRLED ENDP
DELAY8253 PROC
PUSH AX
PUSH DX
MOV DX,CTR8253
MOV AL,10H;计数器0方式0
OUT DX,AL
MOV DX,CH0
MOV AX,100;1600
OUT DX,AL
MOV AL,AH
OUT DX,AL
MOV DX,AD245
W1: IN AL,DX
TEST AL,01H
JZ W1
POP DX
POP AX
RET
DELAY8253 ENDP
DELAY PROC
PUSH CX
MOV CX,50
WAIT1: LOOP WAIT1
POP CX
RET
DELAY ENDP
RESET PROC
PUSH AX
PUSH CX
PUSH DI
MOV AL,0
LEA DI,TIMEBUF
MOV CX,13
CLD
REP STOSB
POP DI
POP CX
POP AX
RET;;;
RESET ENDP
KEY PROC
MOV DX,C8255
IN AL,DX
RET
KEY ENDP
CODE ENDS
DATA SEGMENT
LEDTAB DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H
DB 7FH,6FH,77H,7CH,39H,5EH,79H,71H
TIMEBUF DB 0,0,0,0
LEDBUF DB 0,0,0,0,0,0,0,0
PAUSEKEY DB 0
KEYST DB 0
DATA ENDS
SSEG SEGMENT PARA STACK 'STACK'
SDAT DB 1000 DUP(?)
TOP EQU LENGTH SDAT
SSEG ENDS
END START