基于單片機的超聲波測距儀LED顯示電路的設計
;*** ****距離計算程序**********
WORK: PUSH ACC
PUSH PSW
PUSH B
MOV PSW,#18H
MOV R3,45H
MOV R2,44H
MOV R1,00D
MOV R0,17D
LCALL MUL2BY2
MOV R3,#03H
MOV R2,0E8H
LCALL DIV4BY2
LCALL DIV4BY2
MOV 40H,R4
MOV A,40H
JNZ JJ0
MOV 40H,#0AH
JJ0: MOV A, R0
MOV R4, A
MOV A, R1
MOV R5, A
MOV R3, 00D
MOV R2, #100D
LCALL DIV4BY2
MOV 41H,R4
MOV A,41H
JNZ JJ1
MOV A,40H
SUBB A,#0AH
JNZ JJ1
MOV 41H,#0AH
JJ1: MOV A,R0
MOV R4,A
MOV A,R1
MOV R5,A
MOV R3,#00D
MOV R2,10D
LCALL DIV4BY2
MOV 42H,R4
JNZ JJ2
MOV A,41H
SUBB A,#0AH
JNZ JJ2
MOV 42H,#0AH
JJ2: MOV 43H,R0
POP B
POP PSW
POP ACC
RET
MUL2BY2:CLR A
MOV R7,A
MOV R6,A
MOV R5,A
MOV R4,A
MOV 46H,#10H
MULLOOP1:CLR C
MOV A,R4
RLC A
MOV R4,A
MOV A,R5
RLC A
MOV R5,A
MOV A,R6
RLC A
MOV R6,A
MOV A,R7
RLC A
MOV R7,A
MOV A,R0
RLC A
MOV R0,A
MOV A,R1
RLC A
MOV R1,A
JNC MULLOOP2
MOV A,R4
ADD A,R2
MOV R4,A
MOV A,R5
ADDC A,R3
MOV R5,A
MOV A,R6
ADDC A,#00H
MOV R6,A
MOV A,R7
ADDC A,#00H
MOV R7,A
MULLOOP2:DJNZ 46H,MULLOOP1
RET
DIV4BY2:MOV 46H,#20H
MOV R0,#00H
MOV R1,#00H
DIVLOOP1:MOV A,R4
RLC A
MOV R4,A
MOV A,R5
RLC A
MOV R5,A
MOV A,R6
RLC A
MOV R6,A
MOV A,R7
RLC A
MOV R7,A
MOV A,R0
RLC A
MOV R0,A
MOV A,R1
RLC A
MOV R1,A
CLR C
MOV A,R0
SUBB A,R3
JC DIVLOOP2
MOV R0,B
MOV R1,A
DIVLOOP2:CPL C
DJNZ 46H,DIVLOOP1
MOV A,R4
RLC A
MOV R4,A
MOV A,R5
RLC A
MOV R5,A
MOV A,R6
RLC A
MOV R6,A
MOV A,R7
RLC A
MOV R7,A
RET
END PIXTEL_MMI_EBOOK_2005>9 /PIXTEL_MMI_EBOOK_2005>
51單片機相關文章:51單片機教程
晶振相關文章:晶振原理
評論