> I believe a PIC can have a stack. This is especially true for 16f877. > On a 16f877, the RAM on bank 3 is used rarely and the 80 bytes of ram in > bank 4 is used very very rarely. So, if we could write a piece of code which > could > just Push and Pop the value in the W register, we could have a working stack > of > around 75 bytes (5 bytes for housekeeping). And thats quite good for a PIC I > believe. > As a matter of fact, I've already written the code for a Stack Library with > underflow > and overflow protection. Do tell me if you are interested in it. > > I had always dreamt of a Compiler for PIC 16F877s with recursive functions. > JAL can't do it (It does'nt have a stack). But PUSHW and POPW instructions > are quite > hefty. they take around 5 to 10 instructions. But I believe thats ok with > the advantage > which stack gives. I have a software stack implemented via my PUSHREGS and POPREGS macros in STD.INS.ASPIC at http://www.embedinc.com/pic. These macros push and pop any subset of the "general registers" also defined in that file. I use the stack mostly so that subroutines can preserve the general registers to the caller but use them as scratch internally. This is built into the GLBSUB, LEAVEREST, and other macros. ******************************************************************** Olin Lathrop, embedded systems consultant in Littleton Massachusetts (978) 742-9014, olin@embedinc.com, http://www.embedinc.com -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu