From: Kevin S. <sch...@kw...> - 2010-11-09 23:20:35
|
At 9:35 pm +0100 2010/11/09, you wrote: >If i remember correctly, when i worked with CodeWarrior for the HC08s, >placing a const qualifier directly meant placing the data in ROM That's fine when you have a single address space, but on the AVR, you'd have to fake one in software, which would be fatal for performance. Consider for example: int a[] = { 1, 2 }; const int b[] = { 3, 4 }; extern int f(const int*); int g(void) { return f(&a[0]) + f(&b[0]); } &a[0] is an address in RAM, but, if you magically put any object declared const into ROM, &b[0] is a an address in flash. How is f() supposed to deal with that? >However how >should we treate inline strings like printf("hello")? place them in ROM by >default? because declaring a ptr for each string similar to what gcc does >is a bit insane. In principle, you could have an optimization pass that would, for instance, replace __builtin_printf(const char *, ...) with __builtin_printf(__flash const char *, ...) while placing the format string in ROM. To do much more than that, for C, sounds to me like a large research project. >I'm going to ask about this to a friend who is a compiler expert, and i'll >reply about his thoughts, probably during this weekend, im very busy these >days. Until 2004, I did commercial compiler work on quite a few oddball processors that would make the AVR look like a model of simplicity. These days I'm doing compiler work professionally again, which means I'm not really inclined to do it recreationally as well, but I'm usually happy to comment. Obviously all the real decisions, especially on what's worth spending time on, need to be made by the people actually spending their time doing the work. -- Kevin Schoedel <sch...@kw...> VA3TCS |