; EXEC is the kernel entry for tasks. The kernel assumes exclusive use
; of registers R6 and R7 in each task register bank. Up to 4 tasks are
; supported by the kernel, as the 8051 has 4 register banks.
; Entry: R6 contains task blocking-time request.
exec:
mov r7,sp ;save task stack state
mov a,psw ;fetch current tsk reg bank ptr
bump_bank:
add a,#8 ; & bump it to next task's bank
anl a,#18h
mov psw,a
jnz bump_task_timer ;branch fwd if not last tsk in list
jnb new_tick,$ ;wait for next realtime tick
clr new_tick ; then reset realtime tick flag
bump_task_timer:
djnz r6,bump_bank
mov sp,r7 ;restore task stack state
ret ; & exit to task