From: Patrick E. <pa...@pa...> - 2001-07-18 08:35:12
|
On Wednesday 18 July 2001 00:07, you wrote: > I have looked into this in the past. You definitely can't do it > easily, because the PICs are designed to use the hardware stack. > To impliment a software stack (which is what is needed for > recursion), it is nice to be able to read the program counter. If > you allow your code to be non-relocatable, the compiler will know > the absolute address of all the commands, and thus the program > counter for each command. It would then theoretically be possible > to save the high bits of the program counter somewhere. This would > be quite tedious, it seems to me. > > The AVR line, on the other hand, seems to allow reading of the PC > in an indirect way: if you call a function, the address is pushed > (in two bytes) onto the stack. You can then pop the stack into > register space and play with it. This makes a true software stack > for both code and data possible. > > Have you had a chance to look at the AVR datasheets yet? I'm > looking at the instruction set doc, and the 90S1200 and 90S8535 > (doc is the same as 90S4433). > > I'm unsure how hard it would be to make the compiler work for > both situations... maybe not that hard. I would be interested in making it possible to work with both situations. I imagine it would be possible to do with some sort of generic variable request system. If you need a variable, you ask it for code to get to that variable. It decides if it's going to be local or global in scope based on if the processor supports local variables/recursion. I haven't thought about it that much yet. The AVR line sounds pretty good for compilers. I wonder if they had compilers in mind when they were designed. Perhaps to act more like regular computers. I don't want to only support the AVR line though, especially since I don't even know if I can easily aquire them locally without special ordering them. The PIC is a popular chip, and having a free compiler for it couldn't hurt at all. :) I didn't look at the datasheets for the AVR chips. I suppose they support 20MHz as well? That was the only question I had about them. Perhaps I should take a look when thinking about these memory allocation issues. Patrick Earl |