-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacro.inc
167 lines (156 loc) · 2.28 KB
/
macro.inc
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
;âûâåñòè ÷èñëî
;OUTI ðåãèñòð çíà÷åíèå
.macro OUTI
;PUSH R16
LDI temp,@1
.if @0 < 0x40
OUT @0,temp
.else
STS @0,temp
.endif
;POP R16
.endm
;óíèâåðñàëüíûé âûâîä
;UOUT ðåãèñòð çíà÷åíèå
.macro UOUT
.if @0 < 0x40
OUT @0,@1
.else
STS @0,@1
.endif
.endm
;ïîìåñòèòü ðåãèñòð SREG â ñòýê
;PUSHF
.MACRO PUSHF
PUSH R16
IN R16,SREG
PUSH R16
.ENDM
;äîñòàòü ðåãèñòð SREG èç ñòåêà
;POPF
.MACRO POPF
POP R16
OUT SREG,R16
POP R16
.ENDM
;óñòàíîâèòü áèò ñ èñïîëüçîâàíèåì ñòåêà
;SETBM ðåãèñòð áèò
.MACRO SETBM
.if @0 < 0x20
SBI @0,@1
.else
.if @0<0x40
PUSH R17
IN R17,@0
ORI R17,1<<@1
OUT @0,R17
POP R17
.else
PUSH R17
LDS R17,@0
ORI R17,1<<@1
STS @0,R17
POP R17
.endif
.endif
.ENDM
;óñòàíîâèòü áèò ñ èñïîëüçîâàíèåì ðåãèñòðà
;SETB ðåãèñòð áèò ðåãèñòð_áóôåð
.MACRO SETB
.if @0 < 0x20 ; Low IO
SBI @0,@1
.else
.if @0<0x40 ; High IO
IN @2,@0
ORI @2,1<<@1
OUT @0,@2
.else ; Memory
LDS @2,@0
ORI @2,1<<@1
STS @0,@2
.endif
.endif
.ENDM
;î÷èñòèòü áèò ñ èñïîëüçîâàíèåì ðåãèñòðà
;CLRB ðåãèñòð áèò ðåãèñòð_áóôåð
.MACRO CLRB
.if @0 < 0x20 ; Low IO
CBI @0,@1
.else
.if @0<0x40 ; High IO
IN @2,@0
ANDI @2,~(1<<@1)
OUT @0,@2
.else ; Memory
LDS @2,@0
ANDI @2,~(1<<@1)
STS @0,@2
.endif
.endif
.ENDM
;î÷èñòòèòü áèò ñ èñïîëüçîâàíèåì ñòåêà
;CLRBM ðåãèñòð áèò
.MACRO CLRBM
.if @0 < 0x20
CBI @0,@1
.else
.if @0<0x40
PUSH R17
IN R17,@0
ANDI R17,~(1<<@1)
OUT @0,R17
POP R17
.else
PUSH R17
LDS R17,@0
ANDI R17,~(1<<@1)
STS @0,R17
POP R17
.endif
.endif
.ENDM
;èíâåðòèðîâàíèå áèòà ñ èñïîëüçîâàíèåì äâóõ ðåãèñòðîâ
;INVB ðåãèñòð áèò ðåãèñòð_áóôåð_1 ðåãèñòð_áóôåð_2
.MACRO INVB
.if @0 < 0x40
IN @2,@0
LDI @3,1<<@1
EOR @3,@2
OUT @0,@3
.else
LDS @2,@0
LDI @3,1<<@1
EOR @2,@3
STS @0,@2
.endif
.ENDM
;èíâåðòèðîâàíèå áèòà ñ èñïîëüçîâàíèåì ñòåêà
;INVBM ðåãèñòð áèò
.MACRO INVBM
.if @0 < 0x40
PUSH R16
PUSH R17
IN R16,@0
LDI R17,1<<@1
EOR R17,R16
OUT @0,R17
POP R17
POP R16
.else
PUSH R16
PUSH R17
LDS R16,@0
LDI R17,1<<@1
EOR R17,R16
STS @0,R17
POP R17
POP R16
.endif
.ENDM
;òóïèòü çàäàííîå êîëè÷åñòâî òàêòîâ
;WAIT êîëè÷åñòâî_òàêòîâ_òóïèòü
.MACRO WAIT
LDI temp, @0
DEC temp
BRNE PC-1
.ENDM