On Wed, 9 Feb 2000, Rich Leggitt wrote: > Something like this would work for two tasks in the same page. A more > generic solution would be an interesting challenge but seemingly doable. > Certainly this kind of thing is way more efficient than using explicit > state machines. if you're willing to add one variable for each task, you can stream line this somewhat switch macro _from_, _to_ movlw $+4 movwf _from_ movf _to_,w movwf pcl endm now the 18cxxx.... well there's probably a dozen ways to do this. I wish I had time right now to explore them... Scott > > context equ 0x20 > > switch macro ; macro to switch tasks > movlw $+2 ; load return 'return' address > goto dispatch > endm > > org 0 > goto 4 > org 4 > > ; init task switcher > movlw task2 ; 'suspend' task 2 > movw context > ; fall into task 1 > > task1 do some stuff > switch > do some more stuff > switch > etc. > goto task1 > > > task2 do some stuff > switch > blah > goto task2 > > > dispatch > xorwf context,f ; exchange w and context > xorwf context,w > xorwf context,f > movw pcl ; jump to old context >