--- In AVR-Chat@yahoogroups.com, David VanHorn <microbrix@...> wrote: > lcd_putc(pgm_read_byte_near(&(BootString[i]))); > what was I passing it without the &? The ampersand is the "address of" operator. Without it, the value being passed was the byte in RAM whose address happens to be the same as the address of the i-th element of the array in Flash. You may not get a warning for this in C but you probably would in C++ which is much more type-strict. By the way, some would prefer to write the statement above slightly differently, e.g. lcd_putc(pgm_read_byte_near(BootString + i)); This works correctly because the name of an array evaluates to the address of the array and adding an index to the address is done in terms of the array element size. Consequently "BootString + i" is exactly equivalent to "&BootString[i]". Similarly, "array[i]" is exactly equivalent to "*(array + i)". Here, the asterisk serves as the "indirection" operator. Don Kinzer ZBasic Microcontrollers http://www.zbasic.net
Message
Re: WinAVR / GCC question re Stack
2009-03-25 by Don Kinzer
Attachments
- No local attachments were found for this message.