Hi,
The attached patch fixes a problem with pre-decrement store instructions
on the SH simulator.
The problem can be demonstrated with the following program:
#include <stdio.h>
int
main()
{
int i[2] = {0,0};
int *p = &i[1];
asm ("mov.l %0,@-%0\n" : "+r" (p));
if ((int*)i[0] == &i[1])
printf ("PASS: Value Correct.\n");
else
printf ("FAIL: Incorrect value written.\n");
return 0;
}
The issue is that, when both operands use the same register, the *value*
to be stored is decremented, but only the *address* of the store should
have been decremented. I.e. in the example, it is supposed to store "p"
at "p - 4", but actually stores "p - 4" at "p - 4".
Note that GCC has a similar error which means that the two work together
(probably not an accident), but the binaries may not work on real
silicon. I think a patch for this problem will be submitted to GCC
sometime soon.
:ADDPATCH sh sim:
Unfortunately, I can't test it on the latest GDB because CVS isn't
accessible (corporate IT issue), but I'm fairly sure it works in the
sources I do have. For the same reason, I'll have to ask somebody else
to do the commit for me.
Thanks
Andrew Stubbs