单片机蜂鸣程序 汇编 帮我看看吧

单片机蜂鸣程序 汇编 帮我看看吧,第1张

ORG 0000H

STAR:

JB P1.0,$ p1.0作为开关 打态念开程序才能继续下去

CALL DI 发音200ms

CALL NO_DI 静音200ms

CALL DI

CALL NO_DI

CALL DI

CALL NO_DI

SJMP STAR继续从头执帆仔困行程序

-------------------

DI:

MOV R1,#100 发音200ms

D2:

CLR P1.7

LCALL DEL 约1ms

SETB P1.7

LCALL DEL设置蜂鸣声音的频率戚辩高低

DJNZ R1, D2

RET

-------------------

NO_DI:

MOV R1,#100 静音200ms

ND2:

CLR P1.7

LCALL DEL 约1ms

SETB P1.7

LCALL DEL设置蜂鸣声音的频率高低

DJNZ R1, ND2

RET

-------------------

DEL: 约1ms

MOV R7,#5

DLY1:

MOV R6,#100

DJNZ R6,$

DJNZ R7,DLY1

RET

END

 两个子程序均实现延时1秒的功能,实现方式略有不同,但机制是一样的。

 

 

        CODE  SEGMENT

              ASSUME    CS:CODE

              ORG       100H

      START:  PUSH      CS

              POP       DS

              PUSH      CS

              POP       ES

              MOV       CX,10

              MOV       毁衫DL,7         蜂鸣

        @00:

              MOV       AH,2

              INT       21H

              CALL      DELAY_PROC

              LOOP      @00

              

              MOV       AH,4CH

              INT       21H

     DELAY1S  PROC      NEAR

              PUSH      AX

              差虚PUSH      CX

              PUSH      DX

              PUSH      SI

              PUSH      DI

              PUSHF

              MOV       AH,0

              INT       1AH

              MOV       SI,CX

              MOV       DI,DX

     @DELAY:

              MOV       AH,0

              INT       1AH

              SUB       DX,DI

              SBB       CX,SI

              CMP       DX,18        延时1秒

              JB        @DELAY

              POPF

              POP       DI

              POP       SI

              POP       DX

              POP       CX

              POP       AX

              RET

     DELAY1S  ENDP

  ================================================================

  DELAY_PROC  PROC      NEAR

              PUSH      ES

              PUSH      DX

              MOV       DX,40H

              MOV       ES,DX

              MOV       DX,ES:[006CH]

              ADD       DX,18        延时1秒

    DELAY10:

              CMP       ES:[006CH],DX

              JBE       DELAY10

     纤庆腔         POP       DX

              POP       ES

              RET

  DELAY_PROC  ENDP

       

      

        CODE  ENDS

              END       START


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12496827.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存