-
Notifications
You must be signed in to change notification settings - Fork 1
/
distance_calculator_final.asm
110 lines (88 loc) · 1.15 KB
/
distance_calculator_final.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
ORG 0000H
MOV P1,#00H
MOV P0,#00H
CLR P1.0
SETB P1.1
MOV R4,#00H
MOV B,#0AH
MOV A,#38H
ACALL COMWRT
ACALL DELAY
MOV A,#0EH
ACALL COMWRT
ACALL DELAY
MOV A,#01H
ACALL COMWRT
ACALL DELAY
MOV A,#06H
ACALL COMWRT
ACALL DELAY
MOV R2,#0FFH
MAIN:MOV TMOD,#20H
MOV TL1,#0C5H
MOV TH1,#0C5H
MOV A,#00H
SETB P1.0
ACALL DELAY10
CLR P1.0
HERE: JNB P1.1,HERE
BACK: SETB TR1
HERE1: JNB TF1,HERE1
CLR TR1
CLR TF1
INC A
JB P1.1,BACK
MOV R4,A
ACALL DISPLAY
here2:SJMP main
DISPLAY:
MOV A,R4
MOV B,#0AH
DIV AB
MOV 42H,B
MOV B,#0AH
DIV AB
MOV 41H,B
MOV B,#0AH
DIV AB
MOV 40H,B
MOV A,#84H
ACALL COMWRT
ACALL DELAY
MOV A,40H
ADD A,#30H
MOV 50H,A
ACALL DATAWRT
ACALL DELAY
MOV A,41H
ADD A,#30H
MOV 51H,A
ACALL DATAWRT
ACALL DELAY
MOV A,42H
ADD A,#30H
MOV 52H,A
ACALL DATAWRT
ACALL DELAY
ret
DELAY10: MOV R6,#02H // 10uS delay
LABEL1: DJNZ R6,LABEL1
RET
COMWRT: MOV P2,A
CLR P3.7
CLR P3.6
SETB P3.5
ACALL DELAY
CLR P3.5
RET
DATAWRT: MOV P2,A
SETB P3.7
CLR P3.6
SETB P3.5
ACALL DELAY
CLR P3.5
RET
DELAY: MOV R7,#0FFH
LABEL2: DJNZ R7,LABEL2
RET
END