From: SourceForge.net <no...@so...> - 2011-09-18 14:21:39
|
Bugs item #2350456, was opened at 2008-11-26 12:20 Message generated for change (Settings changed) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2350456&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: pic14 target Group: known bugs Status: Open Resolution: Later Priority: 5 Private: No Submitted By: Nestor Amigo Cairo (nestoramigo) Assigned to: Raphael Neider (tecodev) >Summary: PIC14: STK00 gets overwritten when calling some functions. Initial Comment: Hello. I attach the Makefile I use for the project, just do "make" and "make sim". This is a driver for the T6963 LCD screen. You just need to simulate it to see that something is wrong. I'm using sdcc 2.8.0 on Debian Etch. When making the simulation, please, put a Breakpoint on line 578: CLRF _TRISB Then, Run it and when it starts a loop, put two logical ones on input ports B0 and B1, this is to simulate the behaviour of the LCD. Then, when it reaches line 578, see that STK00 is zero, it is correct because if you read at the code variable "carmelomelo" (this strange name is to assure it's different from everything else) is initialized with zero on toggle_led.c:142: dt2(0,0); But repeat the process two more times, Run and when it stops, Step by and see the output of PORTB. You'll see that the following one is also zero, which is correct, but then, it's one, and it should be 0x40!! (toggle_led.c:143) I think that the problem is that the compiler uses the same STK00 register for all the parameters that all functions use through the program, and this gets overwritten before using it, because yo do something like: sleep(time) { do nothing but return; } cmd(data) { sleep(50000); // Now, STK00 so data is overwritten. PORTB = data; // Wrong value, not zero. } Pantini() { cmd(0) } ---------------------------------------------------------------------- Comment By: Nestor Amigo Cairo (nestoramigo) Date: 2008-11-28 01:43 Message: Thank you. I have tried with latest CVS version, and it works flawlessly with --no-overlay. The old "stable" version is not very good at this task. I'm going to comment any further incidence, I'm very interested in the port to PIC14. ---------------------------------------------------------------------- Comment By: Raphael Neider (tecodev) Date: 2008-11-27 23:57 Message: The problem is your calling sdcc with the --stack-auto argument, which is not supported by the pic14 port. The --stack-auto switch causes the arguments to a function to be reversed in SDCCast.c (decorateType), l. 4747, which is not compensated/honored in the pic14 backend. Just leave out the --stack-auto switch and you should be fine. Working around another compiler bug (that also causes registers to be reused incorrectly), you might want to add --nooverlay instead. This disables an optimization and thus increases the memory footprint, but the resulting code should be more likely to work properly. Good luck, Raphael ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2350456&group_id=599 |