Re: [avr-gcc-list] introducing a new section in data memory
--- On Sat, 2/21/09, Georg-Johann Lay a...@gjlay.de wrote: The trouble might return if .data/.bss will grow and then overlap(s) No sir, I needed 256 bytes buffers two and the other variables may total to about 10 or so. The problem is that you cannot introduce holes in a section, i.e. start with .data, reserve a hole of 0x100 (or put .stuff in it) and then proceed with .data. Therefore, there may be a waste of RAM of up to 0xff bytes. If .data and .test are two adjacent sections, I guess there will be no issue (well they need not be adjacent for that matter). If my .test section starts at a page boundary, it is enough. The only safe way to do this is -- supplying own linker script that introduces alignment as needed. -- supplying own linker script that introduces sections .data.lo at 0x60, .test at 0x100, .data.hi at 0x200. But depending on the size of .data, you will have to split .bss instead and explicitely say that has to go in the .data fragments. Not nice. -- or allocate 0x1ff bytes and compute the effective address at runtime. But then you must access indirect through a pointer. -- Maybe it's best to take the space from the top of RAM. Then you will waste just 0x60 bytes (or can put some other stuff there), and you can use direct addressing if you prefer or need that. Yust init the stach pointer to an other value by means of -minit-stack from command line or simply by __builtin_alloca (0x160) resp. auto char test_buffer[0x160] upon entering main(). Just realize that because your variable is now in the .test section, don't expect the toolchain to automatically initialize the variable to zeros in the future. Thank you for the clue. I will take care to init the section myself. It may do that now, but the toolchain will change to not include the __do_clear_bss if it detects that there is nothing in the .bss section. The variable is now outside the .bss, so there are no guarantees that it will be initialized to a known value (zeros) in the startup code. This can be fixed by renaming the section to .bss.test, as far as you refer to http://lists.gnu.org/archive/html/avr-gcc-list/2009-01/msg00162.html But note that the linker assumes one monolithic section, and resp. does the code in __do_clear_bss resp. __do_copy_data! Also nothe that there are some bugs in the patch cited above. I will fix them as soon I will find the time for it. By the way, what is the specification for the handling of orphans? Seems as if they are assumed to be adopted by .data? Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] introducing a new section in data memory
--- On Sat, 2/21/09, Weddington, Eric ewedding...@cso.atmel.com wrote: It works for me. See attached demo. After the build look at the .map file and the disassembly file (.dis). Just realize that because your variable is now in the .test Attachment error. Trying again for the list. Thank you very much. Will compile, check and revert. Regards Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
[avr-gcc-list] How to tell avr-gcc not to use some registers in the whole program?
Hello, everyone! In my project, I need to bind four registers to two 16 bit pointers because the two pointers are used frequently. But I don't know exactly how to do it. Does anyone know something about it? ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] How to tell avr-gcc not to use some registers in thewhole program?
-Original Message- From: avr-gcc-list-bounces+eweddington=cso.atmel@nongnu.org [mailto:avr-gcc-list-bounces+eweddington=cso.atmel@nongnu. org] On Behalf Of Lin Nan Sent: Saturday, February 21, 2009 8:41 AM To: avr-gcc-list@nongnu.org Subject: [avr-gcc-list] How to tell avr-gcc not to use some registers in thewhole program? Hello, everyone! In my project, I need to bind four registers to two 16 bit pointers because the two pointers are used frequently. But I don't know exactly how to do it. Does anyone know something about it? The description is in the avr-libc user manual, in the FAQ. Although it should be used with caution. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] How to tell avr-gcc not to use some registers in the whole program?
Lin Nan schrieb: Hello, everyone! In my project, I need to bind four registers to two 16 bit pointers because the two pointers are used frequently. But I don't know exactly how to do it. Does anyone know something about it? You can do this by introducing two global register variables like register foo_t * pfoo asm (r2); But note: If doing so /all/ of the sources that contribute to your project must include this line and be aware of the new convention for R2/R3, even if a module does not use the register: It must not alloc them for register allocation. This includes libraries, so you must be sure that no library you link against uses R2 or R3 (in the example showed above). Also note the command line option -ffixed-2 -ffixed-3 that turn R2/R3 into fixed registers (in contrast to R2/R3 beeing call-saved-regs, which is the default for them). Also note that you most probably won't experience the desired reduction of program memory and/or execution time. This is because the compiler must move R2 to X, Y, or Z to access a location. Making Y or Z global regs will crash the compiler sooner or later. I would not recommend to make X global, either. Best way to save program space is to gather stuff in a struct an pass a pointer to the object to functions dealing with the object: void foo (foo_t *pfoo); This applies even if just one entity of foo_t exists. For small functions this can reduce code size, but for more complex functions that are no leaf the code may get worse. So there is nor general recommendation. Georg-Johann ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] How to tell avr-gcc not to use some registers in the whole program?
--- On Sun, 2/22/09, Georg-Johann Lay a...@gjlay.de wrote: You can do this by introducing two global register variables like register foo_t * pfoo asm (r2); Also note the command line option -ffixed-2 -ffixed-3 that turn R2/R3 into fixed registers (in contrast to R2/R3 beeing call-saved-regs, which is the default for them). Also note that you most probably won't experience the desired reduction of program memory and/or execution time. This is because the compiler must move R2 to X, Y, or Z to access a location. Making Y or Z global regs will crash the compiler sooner or later. I would not recommend to make X global, either. In your sample code above only R2 (8 bit) is bound to the variable. I had a similar requirement for using 16 bit (say X register) as pointer, can you post a sample line of code on how to do this? Thank you. Nayani ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list