This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

2.95.3 m68k-elf bug??


Hi,
    I have found a bug in the gcc if I turn on the optimization (-O1), and
pass -m68000 arguement to the compiler.  Here is the code:

/* it is a 7byte long structure (1 + 2 + 2+ 1+ 1) */
struct mystruct
{
    unsigned char a;
    short b;
    short c;
    unsigned char d;
    unsigned char e;
};

int myfunc(struct mystruct test1)
{
    struct mystruct test2;
    test2 = test1;
    test2.b = 3;
    mysubfunc(test2);
    return 0;
}

Here is the assembly listing:
                link.w %a6,#0
                move.l 8(%a6),%d0	/* copy first 4 bytes of structure
to d0 */
                move.l 12(%a6),%d1 /* copy last 4 bytes of structure to d1
*/
                and.w #3,%d1          /* that should be d0, not d1 */
                or.w #3,%d1		/* that should be d0, not d1 */
                move.l %d1,-(%sp)
                move.l %d0,-(%sp)
                jsr mysubfunc
	    ...........
The problem is that the value is not saving to the right register. Value 3
should be store in the lower two bytes of d0, not d1.

Does anyone come across that problem when passing structure using register??
any workaround to solve that problem??

Thanks,

Eddie





------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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