gcc inline assembly tends to use output registers as input if not explicitely told to avoid is: "=&" as constraint to the output register avoids that.

This commit is contained in:
Markus Fröschle
2013-11-22 10:03:10 +00:00
parent 4ba1c812ef
commit 7197610c76

View File

@@ -3,7 +3,7 @@
#include <stdint.h>
inline uint32_t set_ipl(uint32_t ipl)
static inline uint32_t set_ipl(uint32_t ipl)
{
uint32_t ret;
@@ -17,7 +17,7 @@ inline uint32_t set_ipl(uint32_t ipl)
" move.w d0,sr\n\t" /* put it in place */
" andi.l #0x0700,%[ret]\r\n" /* mask out ipl bits */
" lsr.l #8,%[ret]\r\n" /* shift them to position */
: [ret] "+d" (ret) /* output */
: [ret] "=&d" (ret) /* output */
: [ipl] "d" (ipl) /* input */
: "d0" /* clobber */
);