avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] Strange asm output


From: Nicolas Schodet
Subject: Re: [avr-libc-dev] Strange asm output
Date: Thu, 11 Nov 2004 00:43:35 +0100
User-agent: Mutt/1.5.6+20040722i

* Dmitry K. <address@hidden> [041110 23:50]:
> > I have a little piece of code which produce a very strange code:
> > I can not understand why gcc do not just test the 23th bit.
> I have try:
> [...]

I change my original code, so I writed a new one:

/* toto.c */
#include <inttypes.h>

int32_t
toto (int32_t a)
{
    if (a & (1L << 23))
        return 1;
    else
        return 0;
}

Command line:

avr-gcc -g -Wall -O2 -mmcu=atmega128 -MMD -S -o toto.s toto.c

Gcc version:

avr-gcc (GCC) 3.4.1

Result:

.global toto
        .type   toto, @function
toto:   
        .stabn 68,0,6,.LM1-toto
.LM1:
/* prologue: frame size=0 */
/* prologue end (size=0) */
        movw r26,r24
        movw r24,r22
        .stabn 68,0,7,.LM2-toto
.LM2:   
        ldi r18,23
1:      lsr r27
        ror r26
        ror r25
        ror r24
        dec r18
        brne 1b
        andi r24,lo8(1)
        andi r25,hi8(1)
        or r24,r25
        breq .L2
        .stabn 68,0,8,.LM3-toto
.LM3:   
        ldi r22,lo8(1)
        ldi r23,hi8(1)
        ldi r24,hlo8(1)
        ldi r25,hhi8(1)
        ret
.L2:
        .stabn 68,0,10,.LM4-toto
.LM4:   
        ldi r22,lo8(0)
        ldi r23,hi8(0)
        ldi r24,hlo8(0)
        ldi r25,hhi8(0)
        .stabn 68,0,11,.LM5-toto
.LM5:   
        ret
/* epilogue: frame size=0 */
        ret
/* epilogue end (size=1) */
/* function toto size 24 (23) */
        .size   toto, .-toto

Tell me if you need more informations.

/Nicolas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]