Fellows,
I will probably stick on gcc-3.-current version of the compiler and will
add new feateres and such to this branch. I checked the code generated
here and find it reasonable. In many cases current versin generates better
code than 3.0...

So, new I committed new version of gcc with some improvements:
1. Improved movstr() insn. (movstr is a built-in compiler command)
2. Added trampolines (aka nested functions)

Several words about it:
Nested functions are function declared within a function declaration and
can refer to local variables. This is usefull for some cleanups due to
interrupted call or external alarm. Another advantage - almost everything
can be done on stack. For example:

void dummy_example(int circumstance)   
{
        int stop = 0, res;
        char buf[256];
        void st(int a)
        {
                stop = a;
                // device_read() interrupted
                // clean up input buffer
                cleanup(buf);
        }
        void st1()
        {
                stop = 1;
        }

        // register internal callback (for any event like IO error
        // or external interrupt)
        register_callback(c?st:st1, 5);

        while(stop == 0)
        {
                if((res = device_read (buf)) == -1)
                        st(1);  // break
                else if(res == 0)
                        // no data in buffer
                        break;
                else
                        // transfer data to user space
                        uiomove(buf, res);
        }

        unregister_callback(c?st:st1);
}

Here, all data transfers can be done on buffer allocated on stack => 
no .data waste.

Disadvantages:
 - Every nested declaration enlarges code by ~48 bytes.
 - Every nested call preceeds by 2 instructions:
        mov     #SOMECONST, r6
        br      #nestedfunct
 - Something else :)

Anyway, this is a supported feature, which msp430-gcc has (avr does not ;)

4. attribute 'reentrant' added. (Not in includes)

This attribute forces gcc to issue eint/dint on function entry/exit
irrespective to the status register state.



Have fun
~d



/********************************************************************
     ("`-''-/").___..--''"`-._     (\   Dimmy the Wild      UA1ACZ
      `6_ 6  )   `-.  (     ).`-.__.`)  Enterprise Information Sys 
      (_Y_.)'  ._   )  `._ `. ``-..-'   Nevsky prospekt,   20 / 44
    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg,   Russia
   (il),-''  (li),'  ((!.-'             +7 (812)  3468202, 5585314
 ********************************************************************/

Reply via email to