Re: [avr-gcc-list] Add 'OS_main' and 'OS_task' attributes in avr-gcc 4.2.1
On Mon, Jul 23, 2007 at 2:48 PM, Anatoly Sokolov [EMAIL PROTECTED] wrote: This patch add OS_main and 'OS_task' attributes in GCC 4.2.1. Function with OS_main and 'OS_task' attributes do not save any call-saved registers. I had hoped that using OS_main would get rid of the call to main, wastes stack space, and all of the dead _exit code, which is not allowed under some design guidelines (as well as taking space), that will never be executed, but it doesn't. Is there an attribute that would? using 'noreturn' does not work on main, causes: Main/main.cpp: In function 'int main()': Main/main.cpp:60: warning: function declared 'noreturn' has a 'return' statement Removing 'int' from main causes different errors. Test case: int main( void ) __attribute__ ((OS_main)); int main( void ) { for(;;) ; } generates the following where main will never return and _exit will never be executed. 5a: 02 d0 rcall .+4 ; 0x60 main 5c: 02 c0 rjmp.+4 ; 0x62 _exit 005e __bad_interrupt: 5e: d0 cf rjmp.-96; 0x0 __vectors 0060 main: int main( void ) 60: ff cf rjmp.-2 ; 0x60 main 0062 _exit: 62: f8 94 cli 0064 __stop_program: 64: ff cf rjmp.-2 ; 0x64 __stop_program ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
Re: [avr-gcc-list] Add 'OS_main' and 'OS_task' attributes in avr-gcc 4.2.1
On Tuesday 09 December 2008 14:39, Bob Paddock wrote: I had hoped that using OS_main would get rid of the call to main, wastes stack space, and all of the dead _exit code, which is not allowed under some design guidelines (as well as taking space), that will never be executed, but it doesn't. Is there an attribute that would? I am aware of two solutions. First, and most rigorous, is writing your own startup code and link with option -nostartfiles. Please note this requires that you generate a vector table yourself, and has other drawbacks. (for example no .data section possible) Second, and this trick works in some situations: http://www.mail-archive.com/avr-gcc-list@nongnu.org/msg02390.html For me the latter was not reliable enough, so i use the first option most of the time. If you exactly know which interrupts to expect, you may even utilize part of the vector table for code. But the most beautiful would be to have a compiler option like -embedded or so, which gets rid of all junk. I would be more that happy to hear how others solved this. Below three examples (gcc 4.3.2 with patches): 1) Standard compile 2) Overwriting __methodes (Bjoern's trick) 3) with -nostartfiles + custom startup code Note that, since the data section was empty in this example the whole data copy loop is wasted space two. Btw, if you compile with -Wno-main then you can use: void main(void) __attribute__ (( OS_main )) which reduces code somewhat more 1) Standard compile === __vectors: 0: 12 c0 rjmp.+36; 0x26 __ctors_end 2: 2c c0 rjmp.+88; 0x5c __bad_interrupt 4: 2b c0 rjmp.+86; 0x5c __bad_interrupt 6: 2a c0 rjmp.+84; 0x5c __bad_interrupt 8: 29 c0 rjmp.+82; 0x5c __bad_interrupt a: 28 c0 rjmp.+80; 0x5c __bad_interrupt c: 27 c0 rjmp.+78; 0x5c __bad_interrupt e: 26 c0 rjmp.+76; 0x5c __bad_interrupt 10: 25 c0 rjmp.+74; 0x5c __bad_interrupt 12: 24 c0 rjmp.+72; 0x5c __bad_interrupt 14: 23 c0 rjmp.+70; 0x5c __bad_interrupt 16: 22 c0 rjmp.+68; 0x5c __bad_interrupt 18: 21 c0 rjmp.+66; 0x5c __bad_interrupt 1a: 20 c0 rjmp.+64; 0x5c __bad_interrupt 1c: df c0 rjmp.+446 ; 0x1dc __vector_14 1e: 1e c0 rjmp.+60; 0x5c __bad_interrupt 20: 1d c0 rjmp.+58; 0x5c __bad_interrupt 22: 1c c0 rjmp.+56; 0x5c __bad_interrupt 24: 1b c0 rjmp.+54; 0x5c __bad_interrupt 0026 __ctors_end: 26: 11 24 eor r1, r1 28: 1f be out 0x3f, r1; 63 2a: cf e6 ldi r28, 0x6F ; 111 2c: d0 e0 ldi r29, 0x00 ; 0 2e: de bf out 0x3e, r29 ; 62 30: cd bf out 0x3d, r28 ; 61 0032 __do_copy_data: 32: 10 e0 ldi r17, 0x00 ; 0 34: a0 e6 ldi r26, 0x60 ; 96 36: b0 e0 ldi r27, 0x00 ; 0 38: e8 e3 ldi r30, 0x38 ; 56 3a: f2 e0 ldi r31, 0x02 ; 2 3c: 02 c0 rjmp.+4 ; 0x42 .do_copy_data_start 003e .do_copy_data_loop: 3e: 05 90 lpm r0, Z+ 40: 0d 92 st X+, r0 0042 .do_copy_data_start: 42: a0 36 cpi r26, 0x60 ; 96 44: b1 07 cpc r27, r17 46: d9 f7 brne.-10; 0x3e __SP_H__ 0048 __do_clear_bss: 48: 10 e0 ldi r17, 0x00 ; 0 4a: a0 e6 ldi r26, 0x60 ; 96 4c: b0 e0 ldi r27, 0x00 ; 0 4e: 01 c0 rjmp.+2 ; 0x52 .do_clear_bss_start 0050 .do_clear_bss_loop: 50: 1d 92 st X+, r1 0052 .do_clear_bss_start: 52: a3 37 cpi r26, 0x73 ; 115 54: b1 07 cpc r27, r17 56: e1 f7 brne.-8 ; 0x50 .do_clear_bss_loop 58: 5c d0 rcall .+184 ; 0x112 main 5a: ec c0 rjmp.+472 ; 0x234 _exit 0112 main: 112: 0a d0 rcall .+20; 0x128 portInit 0234 _exit: 234: f8 94 cli 0236 __stop_program: 236: ff cf rjmp.-2 ; 0x236 __stop_program 2) Overwriting __methodes (Bjoern's trick) __vectors: 0: 12 c0 rjmp.+36; 0x26 __ctors_end 2: 26 c0 rjmp.+76; 0x50 __bad_interrupt 4: 25
[avr-gcc-list] Binding a register pair to a pointer
Hello all, I have a time critical application where I have to process an external interrupt request. When the interrupt occurs, I have to read a port and store this data pointed by a pointer. In order to reduce the time taken by pushes and pops, I would like to bind a register pair to a char pointer. My search for examples has not yielded any results. I have tried something like unsigned char *ptr asm (x) but this is throwing out an error. Can some one show me an example on how to achieve this? Thank you. Nayani P ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Binding a register pair to a pointer
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] org] On Behalf Of Parthasaradhi Nayani Sent: Tuesday, December 09, 2008 11:45 AM To: avr-gcc-list@nongnu.org Subject: [avr-gcc-list] Binding a register pair to a pointer Hello all, I have a time critical application where I have to process an external interrupt request. When the interrupt occurs, I have to read a port and store this data pointed by a pointer. In order to reduce the time taken by pushes and pops, I would like to bind a register pair to a char pointer. My search for examples has not yielded any results. I have tried something like unsigned char *ptr asm (x) but this is throwing out an error. Can some one show me an example on how to achieve this? Thank you. This is describe in the avr-libc user manual, in the FAQ. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Add 'OS_main' and 'OS_task' attributes in avr-gcc4.2.1
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] org] On Behalf Of Ruud Vlaming Sent: Tuesday, December 09, 2008 7:44 AM To: avr-gcc-list@nongnu.org Subject: Re: [avr-gcc-list] Add 'OS_main' and 'OS_task' attributes in avr-gcc4.2.1 Below three examples (gcc 4.3.2 with patches): 1) Standard compile 2) Overwriting __methodes (Bjoern's trick) 3) with -nostartfiles + custom startup code Note that, since the data section was empty in this example the whole data copy loop is wasted space two. Hi Ruud, As a side note, a fix for this enhancement bug for GCC would be very helpful in getting rid of other parts of the startup code when they are not needed: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18145 Eric ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
RE: [avr-gcc-list] Binding a register pair to a pointer
Hello Weddington, Thanks for the mail, but the FAQ example is as follows: register unsigned char counter asm (r3) The above is an example for a single byte value, but I would like to bind a pointer which is a 16 bit value and perhaps the X register may be used. I tried using constraints also but the complier complains. An example line of code on how to do this will be highly appreciated. Thank you. Regards Nayani --- On Wed, 12/10/08, Weddington, Eric [EMAIL PROTECTED] wrote: From: Weddington, Eric [EMAIL PROTECTED] Subject: RE: [avr-gcc-list] Binding a register pair to a pointer To: [EMAIL PROTECTED], avr-gcc-list@nongnu.org Date: Wednesday, December 10, 2008, 12:45 AM This is describe in the avr-libc user manual, in the FAQ. ___ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list