home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / config / i386 / switch.s < prev    next >
Encoding:
Text File  |  1997-01-09  |  1.7 KB  |  94 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: switch.s,v 1.11 1996/12/10 13:44:07 aros Exp $
  4.  
  5.     Desc:
  6.     Lang:
  7. */
  8.  
  9. /******************************************************************************
  10.  
  11.     NAME
  12.  
  13.     AROS_LH0(void, Switch,
  14.  
  15.     LOCATION
  16.     struct ExecBase *, SysBase, 9, Exec)
  17.  
  18.     FUNCTION
  19.     Tries to switch to the first task in the ready list. This
  20.     function works almost like Dispatch() with the slight difference
  21.     that it may be called at any time and as often as you want and
  22.     that it does not lose the current task if it is of type TS_RUN.
  23.  
  24.     INPUTS
  25.  
  26.     RESULT
  27.  
  28.     NOTES
  29.     This function is CPU dependant.
  30.  
  31.     This function is for internal use by exec only.
  32.  
  33.     This function preserves all registers.
  34.  
  35.     EXAMPLE
  36.  
  37.     BUGS
  38.  
  39.     SEE ALSO
  40.     Dispatch()
  41.  
  42.     INTERNALS
  43.  
  44.     HISTORY
  45.  
  46. ******************************************************************************/
  47.  
  48.     #include "machine.i"
  49.  
  50.     .text
  51.     .balign 16
  52.     .globl    AROS_SLIB_ENTRY(Switch,Exec)
  53.     .type    AROS_SLIB_ENTRY(Switch,Exec),@function
  54. AROS_SLIB_ENTRY(Switch,Exec):
  55.     /* Make room for Dispatch() address. */
  56.     subl    $4,%esp
  57.  
  58.     /* Preserve registers */
  59.     pushl    %eax
  60.     pushl    %ebx
  61.     pushl    %ecx
  62.     pushl    %edx
  63.  
  64.     /* Get SysBase */
  65.     movl    24(%esp),%ebx
  66.  
  67.     /* If current state is TS_RUN and TF_EXCEPT is 0... */
  68.     movl    ThisTask(%ebx),%ecx
  69.     movw    tc_Flags(%ecx),%eax
  70.     andb    $TF_EXCEPT,%al
  71.     cmpw    $TS_RUN*256,%ax
  72.     jne    disp
  73.  
  74.     /* ...move task to the ready list */
  75.     movb    $TS_READY,tc_State(%ecx)
  76.     leal    Enqueue(%ebx),%edx
  77.     pushl    %ebx
  78.     pushl    %ecx
  79.     leal    TaskReady(%ebx),%eax
  80.     pushl    %eax
  81.     call    *%edx
  82.     addl    $12,%esp
  83.  
  84.     /* Prepare dispatch */
  85. disp:    leal    Dispatch(%ebx),%eax
  86.     movl    %eax,16(%esp)
  87.  
  88.     /* restore registers and dispatch */
  89.     popl    %edx
  90.     popl    %ecx
  91.     popl    %ebx
  92.     popl    %eax
  93.     ret
  94.