#975 reverse subtraction

closed-fixed
5
2013-05-25
2005-08-25
Anonymous
No

SDCC-Version: 2.5.2 #1100 (Aug 24 2005) (MINGW32)
OS: Win2K
Target: 8051
Compiler-Call: "sdcc -o Main.hex Main.c".
----------------------
The compiler produces wrong code for the
line "w = 100-(i*2);". In this example, w gets
the wrong vaules 0xFF64, 0xFF62 and 0xFF60
(for i = 0,1,2). The foo()-Call is just for avoiding
the deletion of "w" by the optimizer.
----------------------

void main(void)
{
char i;
unsigned short w;

while( 1 )
{
for(i=0; i<3; i++ )
{ w = 100-(i*2); // w = 0xFF64, 0xFF62, 0xFF60
foo(w);
}
}
}

There seems to be a problem within the loop-body,
the signed-char "i", the unsigned short "w" and the
multiplication.

More Infos at "mail@grasbon.de".

Nice greetings ...
Reimar

Discussion

  • Bernhard Held

    Bernhard Held - 2005-10-26
    • milestone: --> fixed
    • assigned_to: nobody --> bernhardheld
    • summary: 8 to 16 bit multiplication problem --> reverse subtraction
    • status: open --> closed-fixed
     
  • Bernhard Held

    Bernhard Held - 2005-10-26

    Logged In: YES
    user_id=203539

    Fixed in mcs51/gen.c 1.232, build 1125

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks