diff options
| author | Keith Packard <keithp@keithp.com> | 2009-04-12 21:33:46 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-04-12 21:33:46 -0700 | 
| commit | 3d3f849c9af9028f667cef4afedc0798d39a9efc (patch) | |
| tree | 181af2302ef11f3a302e7cb8a656d473897df132 | |
| parent | f72c4cbc8fd9412dd1cce0fc446e7bbd2edc2d34 (diff) | |
SP points at last pushed byte
| -rw-r--r-- | ao_task.c | 11 | 
1 files changed, 6 insertions, 5 deletions
@@ -74,9 +74,9 @@ ao_yield(void) _naked  		/* Push ACC first, as when restoring the context it must be restored  		 * last (it is used to set the IE register). */  		push	ACC -		/* Store the IE register then disable interrupts. */ +		/* Store the IE register then enable interrupts. */  		push	_IEN0 -		clr	_EA +		setb	_EA  		push	DPL  		push	DPH  		push	b @@ -98,7 +98,7 @@ ao_yield(void) _naked  	if (ao_cur_task_id != AO_NO_TASK)  	{  		/* Save the current stack */ -		stack_len = SP - AO_STACK_START; +		stack_len = SP - (AO_STACK_START - 1);  		ao_cur_task->stack_count = stack_len;  		stack_ptr = (uint8_t __data *) AO_STACK_START;  		save_ptr = (uint8_t __xdata *) ao_cur_task->stack; @@ -107,7 +107,7 @@ ao_yield(void) _naked  	}  	/* Empty the stack; might as well let interrupts have the whole thing */ -	SP = AO_STACK_START; +	SP = AO_STACK_START - 1;  	/* Find a task to run. If there isn't any runnable task,  	 * this loop will run forever, which is just fine @@ -123,11 +123,12 @@ ao_yield(void) _naked  	/* Restore the old stack */  	stack_len = ao_cur_task->stack_count; +	SP = AO_STACK_START - 1 + stack_len; +  	stack_ptr = (uint8_t __data *) AO_STACK_START;  	save_ptr = (uint8_t __xdata *) ao_cur_task->stack;  	while (stack_len--)  		*stack_ptr++ = *save_ptr++; -	SP = (uint8_t) (stack_ptr - 1);  	_asm  		pop		_bp  | 
