This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc for any microcontroller?


tm_gccmail at mail dot kloo dot net wrote:
o Special areas of memory which can only be accessed by special addressing
  modes and/or banked memory

  This usually applies to DSPs and DSP-like processors which have internal
  memory which can be accessed in parallel with the external bus, or to
  funky processors that have been extended past their normal lifespan by
  artificially extending the address space.

Applies to: 8051, etc

One major drawback with GCC is that is does not support multiple memory-space addressing. Some microcontrollers and DSP's have separate memory-space for code and for data (for performance reasons). E.g. address 0x1000 can both refer to a point in the code memory (usually flash or similar) and to a point into data memory. These processors usually uses different op-codes and addressing methods to access the correct address and memory-space.


Applies to: AVR, 8051, high-performance DSP's.

Today, gcc selects one of these spaces (usually the data-space) and sticks to it. If the user needs to access another memory-space, e.g. constants in flash, he needs to do it manually himself (usually by inline assembly).


Technical about gcc's limitation: ---------------------------------

If it would be possible to declare attributes on pointers in gcc, this limitation could be solved in a rather simple way. Example:

1)	int in_flash __attribute__((progmem)) = 1234;
2)	int in_data = 5678;
3)	int * __attribute__((progmempointer)) code_pointer = &in_flash;
4)      int * data_pointer = &in_data;
5)      printf("%d %d\n",*code_pointer);
6)      data_pointer = code_pointer;

1) stores some information in the flash/code memory (this works today with the AVR port).
2) stores some information in data memory
3) declares a pointer to code memory using the proposed attribute
4) declares a pointer to data memory
5) will generate the target-specific opcodes required to access the data from progmem (because of the progmempointer attribute)
6) would fail because the types are different.


But as the operation in 3) is not possible with gcc, this need work with gcc. You can declare attributes on storages and implementations, but not on pointers. Gcc need to have these new features:

- Possibility to declare attributes of pointers. I.e. the attribute becomes a part of the type definition.

- For those targets with multiple memory-spaces, add the new memory-access methods. (E.g. in the AVR use 'lpm' to access code-memory, and 'lds' to access data-memory.)


Svein



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]