URL: <http://savannah.nongnu.org/bugs/?43828>
Summary: wdt.h: Wrong inline assembler arguments Project: AVR C Runtime Library Submitted by: gjlayde Submitted on: Mo 15 Dez 2014 19:25:34 GMT Category: Header Severity: 3 - Normal Priority: 5 - Normal Item Group: Header files Status: None Percent Complete: 0% Assigned to: None Originator Email: Open/Closed: Open Discussion Lock: Any Release: 1.8.0 Fixed Release: None _______________________________________________________ Details: wdt.h comes with wrong inline assembler arguments. Let me give an example (2014-12-15 SVN trunk r2641): #define wdt_enable(timeout) \ do { \ uint8_t temp = 0; \ __asm__ __volatile__ ( \ "in __tmp_reg__, %[rampd]" "\n\t" \ "out %[rampd], __zero_reg__" "\n\t" \ "out %[ccp_reg], %[ioreg_cen_mask]" "\n\t" \ "sts %[wdt_reg], %[wdt_enable_timeout]" "\n\t" \ "1:lds %[tmp], %[wdt_status_reg]" "\n\t" \ "sbrc %[tmp], %[wdt_syncbusy_bit]" "\n\t" \ "rjmp 1b" "\n\t" \ "out %[rampd], __tmp_reg__" "\n\t" \ : "=r" (temp) \ : [rampd] "M" (_SFR_MEM_ADDR(RAMPD)), \ [ccp_reg] "I" (_SFR_MEM_ADDR(CCP)), \ [ioreg_cen_mask] "r" ((uint8_t)CCP_IOREG_gc), \ [wdt_reg] "M" (_SFR_MEM_ADDR(WDT_CTRL)), \ [wdt_enable_timeout] "r" ((uint8_t)(WDT_CEN_bm | WDT_ENABLE_bm | timeout)), \ [wdt_status_reg] "M" (_SFR_MEM_ADDR(WDT_STATUS)), \ [wdt_syncbusy_bit] "I" (WDT_SYNCBUSY_bm), \ [tmp] "r" (temp) \ : "r0" \ ); \ } while(0) Operand %[tmp] (%8) is changed but not indicated as so by means of constraint modifiers. Notice that the compiler may allocate different registers to %0 and %8. Hence, the fix is to refer to %0 instead of to %[tmp] resp. moving %[tmp] to the first operand. Also notice that %8 is unused and can be dropped. temp is loaded with 0 but respective content of %[tmp] is discarded by LDS. The other asm in wdt.h (or maybe even more headers or source files) might suffer from the same or similar flaws. _______________________________________________________ Reply to this item at: <http://savannah.nongnu.org/bugs/?43828> _______________________________________________ Nachricht gesendet von/durch Savannah http://savannah.nongnu.org/ _______________________________________________ AVR-libc-dev mailing list AVR-libc-dev@nongnu.org https://lists.nongnu.org/mailman/listinfo/avr-libc-dev