1
/* bug #21955: pgm_read_xxxx() does not use enhanced LPM instruction
2
$Id: bug-21955.c,v 1.1.2.2 2008/01/13 00:53:31 dmix Exp $
4
Idea is to force 'region text is full': pgm_read_word() takes 5 words
5
in case of classic LPM, and takes 2 words with enhanced LPM. */
9
/* There are not sense to check host computer. */
18
#include <avr/pgmspace.h>
20
/* avr-gcc 4.1.2, Avr-libc 1.6.1, main() contains only 1 line with
22
MIN_SIZE == 90 --> Fault
23
MIN_SIZE == 100 --> OK
24
So, for 50 lines it would:
25
100 + 8*49 = 492 for enhanced
26
100 + 14*49 = 786 for enhanced
27
No use __AVR_HAVE_LPMX__ for preprocessing. */
28
#if (__AVR_ARCH__ == 2) || (__AVR_ARCH__ == 3)
34
#define NWORDS ((FLASHEND - _VECTORS_SIZE - MIN_SIZE)/2)
35
void very_big_function (void)
38
".rept (%0)*256 + %1 \n\t"
41
:: "M" (NWORDS / 256),
52
/* 10*4 words with enhanced LPM
53
10*7 words with classic LPM */
54
addr = pgm_read_word (addr) & 0x7FF;
55
addr = pgm_read_word (addr) & 0x7FF;
56
addr = pgm_read_word (addr) & 0x7FF;
57
addr = pgm_read_word (addr) & 0x7FF;
58
addr = pgm_read_word (addr) & 0x7FF;
59
addr = pgm_read_word (addr) & 0x7FF;
60
addr = pgm_read_word (addr) & 0x7FF;
61
addr = pgm_read_word (addr) & 0x7FF;
62
addr = pgm_read_word (addr) & 0x7FF;
63
addr = pgm_read_word (addr) & 0x7FF; /* 10 */
65
/* 10*4 words with enhanced LPM
66
10*7 words with classic LPM */
67
addr = pgm_read_word (addr) & 0x7FF;
68
addr = pgm_read_word (addr) & 0x7FF;
69
addr = pgm_read_word (addr) & 0x7FF;
70
addr = pgm_read_word (addr) & 0x7FF;
71
addr = pgm_read_word (addr) & 0x7FF;
72
addr = pgm_read_word (addr) & 0x7FF;
73
addr = pgm_read_word (addr) & 0x7FF;
74
addr = pgm_read_word (addr) & 0x7FF;
75
addr = pgm_read_word (addr) & 0x7FF;
76
addr = pgm_read_word (addr) & 0x7FF; /* 20 */
78
/* 10*4 words with enhanced LPM
79
10*7 words with classic LPM */
80
addr = pgm_read_word (addr) & 0x7FF;
81
addr = pgm_read_word (addr) & 0x7FF;
82
addr = pgm_read_word (addr) & 0x7FF;
83
addr = pgm_read_word (addr) & 0x7FF;
84
addr = pgm_read_word (addr) & 0x7FF;
85
addr = pgm_read_word (addr) & 0x7FF;
86
addr = pgm_read_word (addr) & 0x7FF;
87
addr = pgm_read_word (addr) & 0x7FF;
88
addr = pgm_read_word (addr) & 0x7FF;
89
addr = pgm_read_word (addr) & 0x7FF; /* 30 */
91
/* 10*4 words with enhanced LPM
92
10*7 words with classic LPM */
93
addr = pgm_read_word (addr) & 0x7FF;
94
addr = pgm_read_word (addr) & 0x7FF;
95
addr = pgm_read_word (addr) & 0x7FF;
96
addr = pgm_read_word (addr) & 0x7FF;
97
addr = pgm_read_word (addr) & 0x7FF;
98
addr = pgm_read_word (addr) & 0x7FF;
99
addr = pgm_read_word (addr) & 0x7FF;
100
addr = pgm_read_word (addr) & 0x7FF;
101
addr = pgm_read_word (addr) & 0x7FF;
102
addr = pgm_read_word (addr) & 0x7FF; /* 40 */
104
/* 10*4 words with enhanced LPM
105
10*7 words with classic LPM */
106
addr = pgm_read_word (addr) & 0x7FF;
107
addr = pgm_read_word (addr) & 0x7FF;
108
addr = pgm_read_word (addr) & 0x7FF;
109
addr = pgm_read_word (addr) & 0x7FF;
110
addr = pgm_read_word (addr) & 0x7FF;
111
addr = pgm_read_word (addr) & 0x7FF;
112
addr = pgm_read_word (addr) & 0x7FF;
113
addr = pgm_read_word (addr) & 0x7FF;
114
addr = pgm_read_word (addr) & 0x7FF;
115
addr = pgm_read_word (addr) & 0x7FF; /* 50 */