>>> But, how do we put data (other than the PC) on the stack? > > Is *that* stack realy ment for that ? > > Jan-Erik. This week I've been messing with this some more. The datasheet talks about a push putting the PC on the stack, but it really is putting the TOS data on the stack (or incrementing the stack pointer to the next empty location above TOS). So, it DOES allow arbitrary data to be put on the stack. So, what's it good for? I've pretty much got an extremely simple cooperative multitasking system running. Ive done this a lot before with state machines, but it's a pain when you've got some depth of function calls and you may want to go to the next task at any depth. So, what I'm doing is keeping an array of stack copies. A typical task looks like this: void Task0(void){ InitTask(0); // copies current stack to array, but returns here while(1){ DoSomething(); DoSomethingElse(); NextRask(); // saves current stack, loads stack for next task } // then returns } The NextTask() is typically in a loop where we're waiting for input. It can be several subroutines or function calls down. Local variables, however, have to be static. Automatic variables get pretty confused when you go through a task switch. It's pretty much working, but I want to do some more testing. I'll post it when I'm done. Harold -- 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