avr-gcc-list
[Top][All Lists]
Advanced

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

AW: [avr-gcc-list] Value negated before call ?


From: Haase Bjoern (PT-BEU/EMT)
Subject: AW: [avr-gcc-list] Value negated before call ?
Date: Fri, 29 Sep 2006 13:47:19 +0200

No. You need to write 2*32000L otherwise the C language enforces a "int" 
multiplication instead of the "unsigned int" multiplication that you want. With 
-Wall you should get a speaking warning message, IIRC.

Bjoern.

-----Ursprüngliche Nachricht-----
Von: address@hidden [mailto:address@hidden Im Auftrag von Royce Pereira
Gesendet: Freitag, 29. September 2006 13:42
An: AVR-GCC
Betreff: [avr-gcc-list] Value negated before call ?

Hi all,

I have a delay loop thus:
//========================
void delay(unsigned long count)
  {
   while(count)
    --count;
  }
//========================
When I call :
       delay(2*33000);
I get:
      878:      60 ed           ldi     r22, 0xD0       ; 208
      87a:      71 e0           ldi     r23, 0x01       ; 1
      87c:      81 e0           ldi     r24, 0x01       ; 1
      87e:      90 e0           ldi     r25, 0x00       ; 0
      880:      e4 dd           rcall   .-1080          ; 0x44a <delay>
//========================
But when I call:
       delay(2*32000);
I get:
      878:      60 e0           ldi     r22, 0x00       ; 0
      87a:      7a ef           ldi     r23, 0xFA       ; 250
      87c:      8f ef           ldi     r24, 0xFF       ; 255
      87e:      9f ef           ldi     r25, 0xFF       ; 255
      880:      e4 dd           rcall   .-1080          ; 0x44a <delay>
//=========================
The value to be passed is negated before call.
Only difference between the 2 is that the 2nd multiplication result fits into a 
word(2 bytes) while the 1st does not. If I append UL to the 32000 in the 2nd 
example, I get the correct result.

But shouldn't both calls compile similarly?

Thanks & Regards,

--Royce


-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


_______________________________________________
AVR-GCC-list mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list




reply via email to

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