anchor.diff:      begin
         eint? if \ Only enter sleep mode if interrupts have been enabled
           dint up-alone? if ( ."  Sleep " ) sleep then eint
  +        pause
         then
  -      pause
       again
  +;
  +
  +\ --------------------------------------------------
  +\  Convenience fonctions
  +\ --------------------------------------------------
  +
  +: ms ( ms_delay -- ) \ `ms` which allows other tasks to run
  +  millis swap   ( start ms_delay )
  +  begin
  +    wfi pause running \ switch to `wfi` to let lowpower-task go to sleep
  +    2dup millis rot
  +  - < until
  +  2drop
   ;
   
   \ --------------------------------------------------
  
positive.code: 
  \ Internal stucture of task memory:
  \  0: Pointer to next task
  \  4: Task currently active ?
  \  8: Saved stack pointer
  \ 12: Handler for Catch/Throw
  \  Parameter stack space
  
negative.code:     save-task @ sp! rp!  \ restore pointers
      unloop ;              \ pop { r4  r5 } to restore the loop registers
  
  : wake ( task -- ) 1 cells +  true swap ! ; \ Wake a task (IRQ safe)
  : idle ( task -- ) 1 cells + false swap ! ; \ Idle a task (IRQ safe)
  
  \ -------------------------------------------------------
  \  Round-robin list task handling - do not use in IRQ !
  \ -------------------------------------------------------
  
  : stop    ( -- ) false task-state ! pause ; \ Stop current task
  : running ( -- ) true task-state ! pause ;  \ Mark current task as running
  : wfi     ( -- ) 1 task-state ! pause ;     \ Mark task as waiting-for-interrupt
  : multitask  ( -- ) ['] (pause) hook-pause ! ;
  : singletask ( -- ) [']  nop    hook-pause ! ;
  
  