On Fri, 2006-05-26 at 14:19 +0800, Bin Chen wrote:
> In my program the gcc produce two lines of binary code:
>
> 100020e0: ffc20000 sd v0,0(s8)
> 100020e4: dfc20000 ld v0,0(s8)
>
> first store v0->[s8], then load from [s8]->v0, why?
without knowing the source-code that got compiled it's guessing...
and I'd guess that [s8] might have been marked as a volatile location
(assuming the compiler isn't set to dumb-mode wrt to optimization ;-)
e.g. a code like the following
extern int cb(void);
int set(volatile int *p)
{
return *p = cb();
}
will lead to something similar to the fragment below (with s0 being the
pointer p):
[..]
38: ae020000 sw v0,0(s0)
3c: 8e020000 lw v0,0(s0)
[..]
regards,
hvr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD8DBQBEdqxHSYHgZIg/QUIRAmLNAJ9aYiVRSnr9F4A+LhZOVB8pSCYL1ACeIq48
Q+6zs8VJ6u0iNAVUEsVBupE=
=iTAC
-----END PGP SIGNATURE-----