1
/* Test of _SFR's macroses. Default usage without any definition.
2
$Id: sfr-1.c,v 1.1.2.2 2008/05/02 08:47:36 dmix Exp $ */
7
#define cli() asm volatile ("cli")
8
#define sei() asm volatile ("sei")
9
#define nop() asm volatile ("nop")
14
volatile unsigned char *p;
17
#if defined (__AVR_AT90S8515__)
20
if (i != 0x5F) exit (__LINE__);
21
i = _SFR_MEM_ADDR (SREG);
22
if (i != 0x5F) exit (__LINE__);
23
i = _SFR_IO_ADDR (SREG);
24
if (i != 0x3F) exit (__LINE__);
25
if (!_SFR_IO_REG_P (SREG)) exit (__LINE__);
27
i = _SFR_ADDR (WDTCR);
28
if (i != 0x41) exit (__LINE__);
29
i = _SFR_MEM_ADDR (WDTCR);
30
if (i != 0x41) exit (__LINE__);
31
i = _SFR_IO_ADDR (WDTCR);
32
if (i != 0x21) exit (__LINE__);
33
if (!_SFR_IO_REG_P (WDTCR)) exit (__LINE__);
35
i = _SFR_ADDR (EEARH);
36
if (i != 0x3F) exit (__LINE__);
37
i = _SFR_MEM_ADDR (EEARH);
38
if (i != 0x3F) exit (__LINE__);
39
i = _SFR_IO_ADDR (EEARH);
40
if (i != 0x1F) exit (__LINE__);
41
if (!_SFR_IO_REG_P (EEARH)) exit (__LINE__);
44
if (i != 0x28) exit (__LINE__);
45
i = _SFR_MEM_ADDR (ACSR);
46
if (i != 0x28) exit (__LINE__);
47
i = _SFR_IO_ADDR (ACSR);
48
if (i != 0x08) exit (__LINE__);
49
if (!_SFR_IO_REG_P (ACSR)) exit (__LINE__);
51
#elif defined (__AVR_ATmega8__)
54
if (i != 0x5F) exit (__LINE__);
55
i = _SFR_MEM_ADDR (SREG);
56
if (i != 0x5F) exit (__LINE__);
57
i = _SFR_IO_ADDR (SREG);
58
if (i != 0x3F) exit (__LINE__);
59
if (!_SFR_IO_REG_P (SREG)) exit (__LINE__);
61
i = _SFR_ADDR (UCSRC);
62
if (i != 0x40) exit (__LINE__);
63
i = _SFR_MEM_ADDR (UCSRC);
64
if (i != 0x40) exit (__LINE__);
65
i = _SFR_IO_ADDR (UCSRC);
66
if (i != 0x20) exit (__LINE__);
67
if (!_SFR_IO_REG_P (UCSRC)) exit (__LINE__);
69
i = _SFR_ADDR (EEARH);
70
if (i != 0x3F) exit (__LINE__);
71
i = _SFR_MEM_ADDR (EEARH);
72
if (i != 0x3F) exit (__LINE__);
73
i = _SFR_IO_ADDR (EEARH);
74
if (i != 0x1F) exit (__LINE__);
75
if (!_SFR_IO_REG_P (EEARH)) exit (__LINE__);
78
if (i != 0x20) exit (__LINE__);
79
i = _SFR_MEM_ADDR (TWBR);
80
if (i != 0x20) exit (__LINE__);
81
i = _SFR_IO_ADDR (TWBR);
82
if (i != 0x00) exit (__LINE__);
83
if (!_SFR_IO_REG_P (TWBR)) exit (__LINE__);
85
#elif defined (__AVR_ATmega128__)
87
i = _SFR_ADDR (UCSR1C);
88
if (i != 0x9D) exit (__LINE__);
89
i = _SFR_MEM_ADDR (UCSR1C);
90
if (i != 0x9D) exit (__LINE__);
91
if (_SFR_IO_REG_P (UCSR1C)) exit (__LINE__);
94
if (i != 0x61) exit (__LINE__);
95
i = _SFR_MEM_ADDR (DDRF);
96
if (i != 0x61) exit (__LINE__);
97
if (_SFR_IO_REG_P (DDRF)) exit (__LINE__);
100
if (i != 0x5F) exit (__LINE__);
101
i = _SFR_MEM_ADDR (SREG);
102
if (i != 0x5F) exit (__LINE__);
103
i = _SFR_IO_ADDR (SREG);
104
if (i != 0x3F) exit (__LINE__);
105
if (!_SFR_IO_REG_P (SREG)) exit (__LINE__);
107
i = _SFR_ADDR (SFIOR);
108
if (i != 0x40) exit (__LINE__);
109
i = _SFR_MEM_ADDR (SFIOR);
110
if (i != 0x40) exit (__LINE__);
111
i = _SFR_IO_ADDR (SFIOR);
112
if (i != 0x20) exit (__LINE__);
113
if (!_SFR_IO_REG_P (SFIOR)) exit (__LINE__);
115
i = _SFR_ADDR (EEARH);
116
if (i != 0x3F) exit (__LINE__);
117
i = _SFR_MEM_ADDR (EEARH);
118
if (i != 0x3F) exit (__LINE__);
119
i = _SFR_IO_ADDR (EEARH);
120
if (i != 0x1F) exit (__LINE__);
121
if (!_SFR_IO_REG_P (EEARH)) exit (__LINE__);
123
i = _SFR_ADDR (PINF);
124
if (i != 0x20) exit (__LINE__);
125
i = _SFR_MEM_ADDR (PINF);
126
if (i != 0x20) exit (__LINE__);
127
i = _SFR_IO_ADDR (PINF);
128
if (i != 0x00) exit (__LINE__);
129
if (!_SFR_IO_REG_P (PINF)) exit (__LINE__);
135
/* SREG: mem addr is 0x5F (avr2..avr5) */
138
if (SREG & (1 << SREG_I)) exit (__LINE__);
140
if (!(SREG & (1 << SREG_I))) exit (__LINE__);
142
p = (void *)_SFR_ADDR (SREG);
144
if (*p & (1 << SREG_I)) exit (__LINE__);
146
if (!(*p & (1 << SREG_I))) exit (__LINE__);
148
p = (void *)_SFR_MEM_ADDR (SREG);
150
if (*p & (1 << SREG_I)) exit (__LINE__);
152
if (!(*p & (1 << SREG_I))) exit (__LINE__);
155
asm volatile ("in %0,%1" : "=r" (c) : "I" (_SFR_IO_ADDR (SREG)));
156
if (c & (1 << SREG_I)) exit (__LINE__);
158
asm volatile ("in %0,%1" : "=r" (c) : "I" (_SFR_IO_ADDR (SREG)));
159
if (!(c & (1 << SREG_I))) exit (__LINE__);
161
/* TODO: it is needed to update simulavr: do not ask PINx value, if DDRx
164
/* PORTB: mem addr is small */
169
if ((PINB & 3) != 1) exit (__LINE__);
172
if ((PINB & 3) != 2) exit (__LINE__);