步进机实验

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值