Given the logic below, what would you expect for result?

unsigned long test (unsigned long x, signed short y, signed short z)
{
   return x + (signed long) (y - z) * 10;
}

   result = test (10, 0, 1);

CW5, CW6 (Optimization level 0) and VC++ 5.0 all give result = 0.
CW6 (Optimization levels 1-4) give result = 655360 (0x000a0000).

The suspect code generated is:

      move.w       12(a6),d0
      sub.w        14(a6),d0
      mulu.w       #10,d0         <---- should be muls.w?
      add.l        8(a6),d0

Stephen Best
Bitware Australia



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palm.com/devzone/mailinglists.html

Reply via email to