C8279 EQU 20AH
D8279 EQU 208H
C8255 EQU 203H
P8255 EQU 202H
CODE SEGMENT
ASSUME CS:CODE,DS:CODE
START: PUSH CS
POP DS
INI:MOV DX,C8255
MOV AL,80H
OUT DX,AL
MOV DX,C8279
MOV AL,00H
OUT DX,AL
MOV AL,2AH
OUT DX,AL
MOV AL,90H
OUT DX,AL
MOV AL,0DH
OUT DX,AL
JMP SHORT $+2
WAITI:IN AL,DX
MOV AH,AL
AND AL,80H
JNZ WAITI
MOV AL,AH
AND AL,0FH
CMP AL,00H
JE WAITI
LEA BX,STEP
RUN:
CALL CHEKKEY
CALL DISPLAY
MOV CX,08H
LOOP3: MOV DX,P8255C
MOV AL,[SI]
OUT DX,AL
INC SI
CALL DELAY
LOOP LOOP3
JMP RUN
CHKKEY PROC NEAR
RDKEY: MOV DX,C8279
IN AL,DX
MOV AH,AL
AND AL,80H
CMP AL,80H
JE RDKEY
MOV AL,AH
AND AL,0FH
CMP AL,00H
JE RTN
MOV AL,40H
OUT DX,AL
MOV DX,D8279
IN AL,DX
CHY: CMP AL,15H
JE QUIT
CMP AL,0AH
JNC DIRE
MOV DELAYTIME,AL
JMP RTN
DIRE:CMP AL,12H
JNE NEXT
MOV DIRDSP,40H
LEA BX,STEP
JMP RTN
NEXT:CMP AL,13H
JNE RTN
MOV DIRDSP,46H
LEA BX,STEP
ADD BX,07H
RTN: MOV SI,BX
RET
CHKKEY ENDP
DELAY PROC NEAR
PUSH CX
MOV CX,0AH
SUB CL,DELAYTIME
LOOP1 PUSH CX
MOV CX,03FFH
LOOP2:NOP
LOOP LOOP2
POP CX
LOOP LOOP1
POP CX
RET
DELAY ENDP
DISPLAY PROC NEAR
PUSH BX
MOV DX,D8279
MOV AL,DELAYTIME
LEA BX,LED
XLAT
OUT DX,AL
MOV AL,DIRDSP
OUT DX,AL
MOV CX,0006H
LEA BX,DSP
LOOP4: MOV AL,[BX]
OUT DX,AL
INC BX
LOOP LOOP4
MOV DX,C8279
MOV AL,0C2H
OUT DX,AL
POP BX
RET
DISPLAY ENDP
QUIT: MOV DX,C8279
MOV AL,0D2H
OUT DX,AL
JMP $
LED DB 3FH,06H,5BH,4FH,66H
DB 6DH,7DH,07H,7FH,6FH
DSP DB 5EH,79H,79H,73H,6DH,0EDH
DELAYTIME DB 01H
STEP DB 04H,05H,01H,09H,08H
DB 0AH,02H,06H,02H,0AH
DB 08H,09H,01H,05H,04H
DIRDSP DB 40H
CODE ENDS
END START
步进机实验
最新推荐文章于 2023-12-03 14:50:12 发布