问题:
程序开头段如下
CONTROLWORD EQU 10001000B
CT8255SET EQU 43H
CODE SEGMENT
MAIN PROC FAR
ASSUME CS: CODE,DS:CODE
START: PUSH CS
POP DS
MOV DL,CT8255SET
MOV AL,CONTROLWORD
OUT DX,AL
MOV DI,0
CALL INIT
ROTATE:CALL KEY
CALL DISPLAY
JMP ROTATE
RET
MAIN ENDP
仿真中 OUT DX,AL部分无法正确的向8255写入控制字,每次仿真写入8255的控制字总是DX中的内容,甚至有时会莫名写入00H,但是在写入00H的情况下,总是可以正确的设置了C口第一位为0,但是控制字写入却毫无反应。
全部源程序如下:
CONTROLWORD EQU 10001000B
CT8255SET EQU 43H
CODE SEGMENT
MAIN PROC FAR
ASSUME CS: CODE,DS:CODE
START: PUSH CS
POP DS
MOV DL,CT8255SET
MOV AL,CONTROLWORD
OUT DX,AL
MOV DI,0
CALL INIT
ROTATE:CALL KEY
CALL DISPLAY
JMP ROTATE
RET
MAIN ENDP
INIT PROC NEAR
MOV AH,0FFH
MOV AL,AH
MOV DX,41H
OUT DX,AL
MOV DX,40H
MOV AL,00H
OUT DX,AL
RET
INIT ENDP
KEY PROC NEAR
MOV AL,00H
MOV DX,42H
OUT DX,AL
BCA: IN AL,DX
AND AL,0F0H
CMP AL,0F0H
JZ EXIT
CALL DELAY1
MOV AH,0FEH
MOV CX,4
CAB: MOV AL,AH
OUT DX,AL
IN AL,DX
AND AL,0F0H
CMP AL,0F0H
MOV BL,AL
JNZ ACB
ROL AH,1
LOOP CAB
JMP EXIT
ACB: MOV DX,42H
IN AL,DX
AND AL,0F0H
CMP AL,0F0H
JNZ ACB
MOV AL,BL
MOV CL,4
SHL AH,CL
ROR AL,CL
ADD AL,AH
CALL TRAN
EXIT: RET
KEY ENDP
TRAN PROC NEAR
XOR BH,BH
MOV BL,0
LOP1: CMP AL,DS:SCAN[BX]
JZ LOP2
INC BL
JMP LOP1
LOP2: CMP DI,8
JNZ LOP3
MOV DI,0
LOP3: MOV DS:MEM[DI],BL
INC DI
RET
TRAN ENDP
DISPLAY PROC NEAR
PUSH CX
PUSH AX
PUSH DX
PUSH SI
MOV CX,50
ROTATE1: PUSH CX
MOV CX,8
MOV SI,0
MOV AH,01H
NEXT1: MOV AL,AH
MOV DX,41H
OUT DX,AL
MOV AL,DS:MEM[SI]
LEA BX,LED
XLAT
MOV DX,40H
OUT DX,AL
CALL DELAY
ROL AH,1
INC SI
LOOP NEXT1
POP CX
DEC CX
CMP CX,0
JNZ ROTATE1
POP SI
POP DX
POP BX
POP AX
POP CX
RET
DISPLAY ENDP
DELAY PROC NEAR
PUSH CX
PUSH DX
MOV CX,20H
L1: LOOP L1
POP DX
POP CX
RET
DELAY ENDP
DELAY1 PROC NEAR
PUSH CX
PUSH DX
MOV CX,0F0H
L2: LOOP L2
POP DX
POP CX
RET
DELAY1 ENDP
MEM DB 8 DUP(10H)
SCAN DB 0EEH,0EDH,0EBH,0E7H,0DEH,0DDH,0DBH,0D7H,0BEH,0BDH,0BBH,0B7H,7EH,7DH,7BH,77H
LED DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,77H,7CH,39H,5EH,79H,71H,0FFH
CODE ENDS
END START
FH