From: SourceForge.net <no...@so...> - 2012-05-16 12:15:46
|
Bugs item #3527285, was opened at 2012-05-16 05:15 Message generated for change (Tracker Item Submitted) made by speccy2007 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=3527285&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: syd (speccy2007) Assigned to: Nobody/Anonymous (nobody) Summary: Variable allocated to registers is damaged. Initial Comment: 1. Code: #include <stdio.h> unsigned long GetX() { return 0x12345678; } char GetY() { return 1; } int main() __reentrant { unsigned long x; char buff[20]; x = GetX(); if( GetY() != 0 ) { sprintf( buff, "%.8lx", x ); } return 0; } Variable "x" (allocated to registers r4-r7) is damaged. ; test0003.c:21: sprintf( buff, "%.8lx", x ); push ar4 push ar5 push ar6 push ar7 mov r3,_bp inc r3 mov ar2,r3 mov r3,#0x00 mov r7,#0x40 // here the "x" is damaged push ar4 push ar5 push ar6 push ar7 // here the "x" is pushed to stack as sprintf argument mov a,#__str_0 push acc mov a,#(__str_0 >> 8) push acc mov a,#0x80 push acc push ar2 push ar3 push ar7 lcall _sprintf mov a,sp add a,#0xf6 mov sp,a 2. Cmd line "sdcc test0003.c" 3. SDCC : mcs51/gbz80/z80/z180/r2k/ds390/pic16/pic14/TININative/ds400/hc08 3.1.5 #7708 (May 16 2012) (MINGW32) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=3527285&group_id=599 |