-
Notifications
You must be signed in to change notification settings - Fork 0
/
#drugi#
108 lines (74 loc) · 1.14 KB
/
#drugi#
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
(defun mig ()
(sbi (port a) 2)
(wait 200)
(sbi (port a) 2))
(clear (port a))
(main-loop
(mig))
Skutek
clr porta
main:
sbi portA2
[kod procedury wait]
cbi portA
jmp main
Jednak jeżeli zostanie wykonanie dwukrotnie
polecenie zostanie wyciągnięte poza
(defun mig ()
(sbi (port a) 2)
(wait 200)
(sbi (port a) 2))
(clear (port a))
(main-loop
(mig)
(sbi (port b) 2)
(mig)
(cbi (port b) 2))
Dostaniemy
clr porta
main:
rcall mig
sbi PROTB2 2
rcall mig
cbi PROTB2 2
jmp main
mig:
sbi portA2
[kod procedury wait]
cbi portA
ret
Proponowane rozwiązanie
(defun czekaj ()
(let ((lable-name (gemsym)))
(ldi R1 200)
(deflabel label-name)
(umake-asm-label label-name)
(dec R1)
(bine label-name)))
(defun zaswiec ()
(sbi PORTA 1))
(defun zgas ()
(cbi PORTA 1))
(main-loop
(zaswiec)
(call czekaj)
(zgas)
(call caekaj))
I skutkiem tego powinno być...
main: (cbi PORTA 1))
(main-loop
(zaswiec)
(call czekaj)
(zgas)
(call caekaj))
sbi PORTA,1
rcall czeka
cbi PORTA,1
rcall czeka
rjmp main
zeka:
ldi R1 200
G105:
dec R1
bine G105
ret