-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmacros.inc
More file actions
115 lines (107 loc) · 2.79 KB
/
macros.inc
File metadata and controls
115 lines (107 loc) · 2.79 KB
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
;*****************************************************************
;* file: macros.inc
;*
;* Description:
;* Source file for application note AVR001 - Conditional Assembly
;* and Portability Macros.
;*
;* Defines a number of macros that makes it easier to access
;* IO registers and extended IO registers (or SRAM locations up
;* to adress $FF if applicable).
;* The macros can be used to produce code that assembles to
;* any target AVR, without considering if the accessed IO
;* registers are located in low, standard or extended IO space
;*
;* $Revision: 2.2 $
;* $Author: jllassen $
;* $Date: Wednesday, January 26, 2005 10:55:18 UTC $
;*****************************************************************
;*********************************************************
;* BIT access anywhere in IO or lower $FF of data space
;* SETB - SET Bit in IO of data space
;* CLRB - CLeaR Bit in IO of data space
;*********************************************************
.MACRO SETB ;Arguments: Address, Bit, Register
.if @1>7
.message "Only values 0-7 allowed for Bit parameter"
.endif
.if @0>0x3F
lds @2, @0
sbr @2, (1<<@1)
sts @0, @2
.elif @0>0x1F
in @2, @0
sbr @2, (1<<@1)
out @0, @2
.else
sbi @0, @1
.endif
.ENDMACRO
.MACRO CLRB ;Arguments: Address, Bit, Register
.if @1>7
.message "Only values 0-7 allowed for Bit parameter"
.endif
.if @0>0x3F
lds @2, @0
cbr @2, (1<<@1)
sts @0, @2
.elif @0>0x1F
in @2, @0
cbr @2, (1<<@1)
out @0, @2
.else
cbi @0, @1
.endif
.ENDMACRO
;*********************************************************
;* Bit test anywhere in IO or in lower $FF of data space
;* SKBS : SKip if Bit Set
;* SKBC : SKip if Bit Cleared
;*********************************************************
.MACRO SKBS ;Arguments: Address, Bit, Register
.if @1>7
.message "Only values 0-7 allowed for Bit parameter"
.endif
.if @0>0x3F
lds @2, @0
sbrs @2, @1
.elif @0>0x1F
in @2, @0
sbrs @2, @1
.else
sbis @0, @1
.endif
.ENDMACRO
.MACRO SKBC ;Arguments: Address, Bit, Register
.if @1>7
.message "Only values 0-7 allowed for Bit parameter"
.endif
.if @0>0x3F
lds @2, @0
sbrc @2, @1
.elif @0>0x1F
in @2, @0
sbrc @2, @1
.else
sbic @0, @1
.endif
.ENDMACRO
;*********************************************************
;* Byte access anywhere in IO or lower $FF of data space
;* STORE - Store register in IO or data space
;* LOAD - Load register from IO or data space
;*********************************************************
.MACRO STORE ;Arguments: Address, Register
.if @0>0x3F
sts @0, @1
.else
out @0, @1
.endif
.ENDMACRO
.MACRO LOAD ;Arguments: Register, Address
.if @1>0x3F
lds @0, @1
.else
in @0, @1
.endif
.ENDMACRO