From: SourceForge.net <no...@so...> - 2003-11-12 08:45:06
|
Bugs item #840148, was opened at 2003-11-11 12:14 Message generated for change (Comment added) made by epetrich You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=840148&group_id=599 Category: msc51(8051) target >Group: fixed >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Stas Sergeev (stsp) >Assigned to: Erik Petrich (epetrich) Summary: unsafe interrupt handlers Initial Comment: Hi. It seems sdcc has a bug and forgets to generate a registers save/restore code for the interrupt handlers. Looking in the sdcc sources, the logic looks simple: save/restore the regs only if the inthandler calls another function, otherwise save only the registers it uses itself. Unfortunately there is a miss somewhere, and if the inthandler calls another function, the registers are not being saved/restored:( The example that demonstrates the problem, is attached. Here is how the generated asm look like: --- ;intr.c:9: void timer() interrupt 1 ; ----------------------------------------- ; function timer ; ----------------------------------------- _timer: push acc push b push dpl push dph push ar2 push psw mov psw,#0x00 ;intr.c:11: timer_expired++; [very few regs are saved] [skip] 00107$: ;intr.c:13: test_func(); ; genCall lcall _test_func [function call that corrupts the rest of the regs] 00103$: --- Adding a hack to gen.c to work-around that problem was easy, but that yelded a great success! All the random crashes I had are gone and some programs are finally, for the first time I am trying sdcc, are running properly (not all of them yet, but getting there). You have a very nice compiller guys, and you are doing a great work, keep it that way! (just my 2 pences:) ---------------------------------------------------------------------- >Comment By: Erik Petrich (epetrich) Date: 2003-11-12 02:44 Message: Logged In: YES user_id=635249 It's already supposed to save _all_ the registers if any function call is found. However, in certain circumstances (the function call immediately preceeded a control flow merge point) a bug caused the function call to be unnoticed. Fixed in src/SDCCBBlock.c 1.31 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=840148&group_id=599 |