Richard Blakesley

HCS08 CW 5.1: Unnecessary saving/restoring of index register to stack

Discussion created by Richard Blakesley on Sep 6, 2006
Latest reply on Sep 14, 2006 by CompilerGuru

We're having a problem with the HCS08 compiler as we migrate from CodeWarrior v3.1 to v5.1. We're seeing some cases where the newer compiler, even for very simple C code, appears to produce assembler that messes about unnecessarily with saving the X register to the stack, and restoring it from the stack when it hasn't actually been changed.

The two examples attached show the sort of thing that we're seeing, compiled using both CW 3.1 and 5.1 with the same compiler options (-Cs08 -Ms -Ot -OiLib -Or -TE1uE).

I'd be very grateful for any advice or suggestions on how to make the newer compiler behave properly in these kind of situations.

Many thanks!