I used the push and pop instruction in my simple multitasker (http://massmind.org/techref/microchip/language/c/MultiTask.c.htm ). I've never tried argument passing on the stack. It SEEMS, though, that you could do this pretty easily. You'd push arguments on the stack, then do the call, which places the return address on the stack. Inside the routine, you'd have to pop the return address off the stack and save it, then pop the arguments. You could push any return values onto the stack, then put the return PC back, then do a return. The main code would then pop the return values off the stack. It would be nice, of course, if you could just index off the stack pointer to locate parameters on the stack. The main line code could push parameters then push the return address. The subroutine would index back onto the stack from the current SP to find the parameters. It could also replace parameters with return values. At the end, the subroutine would do a return to the PC address on the stack. The main line code would then pop the returned values (or dummy values if there are fewer returned values than input parameters). Then, all is well. The PIC18, however, does not let us index into the stack. We have only have sequential access to the data on it. So we have to pop a bunch of stuff off, storing it, to find what we want, then put stuff back. Back when I was doing 6800 stuff, I used push and pop (pull on the 6800) a lot to store registrs I'd mess with in a subroutine. Parameters and return values were passed in the accumulator or an index register. Registers that weren't used for parameter passing, but were "messed with" in the subroutine , were pushed to the stack on the way in and popped back on the way out. Harold > Is there a "standard" subroutine linkage for the PIC18 series? > Having a limited and quirky stack, are there registers that > are (by convention) never saved in a subroutine? Are there > registers that convention says are always preserved? Is the > stack used at all, and if so, for what? Can I manipulate the > stack pointer explicitly (incf, decf) if I turn of interrupts, > or is that considered a no-no (why does the "pop" instruction > even exist!?) > > Remember my comment about string-output using variables stored > after the call instruction? I figured I'd go an try to implement > that, as a PIC exercise, and I'm frustrated by the apparent fact > that if I save any registers (say, TBLPTRx) to the stack, it becomes > a pain to fetch the old PC address... > > Thanks > Bill W > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist