home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / i386-emul / switch.s < prev   
Encoding:
Text File  |  1996-07-16  |  923 b   |  55 lines

  1.     Dispatch    =    -35
  2.     Enqueue     =    -225
  3.     ThisTask    =    284
  4.     TaskReady   =    428
  5.     tc_Flags    =    16
  6.     tc_State    =    17
  7.     TS_RUN        =    2
  8.     TS_READY    =    3
  9.     TF_EXCEPT   =    32
  10.  
  11.     .text
  12.     .align    16
  13.     .globl    Exec_Switch
  14.     .type    Exec_Switch,@function
  15. Exec_Switch:
  16.     /* Make room for Dispatch() address.
  17.     subl    $4,%esp
  18.  
  19.     /* Preserve registers */
  20.     pushl    %eax
  21.     pushl    %ebx
  22.     pushl    %ecx
  23.     pushl    %edx
  24.  
  25.     /* Get SysBase */
  26.     movl    24(%esp),%ebx
  27.  
  28.     /* If current state is TS_RUN and TF_EXCEPT is 0... */
  29.     movl    ThisTask(%ebx),%ecx
  30.     movw    tc_Flags(%ecx),%eax
  31.     andb    $TF_EXCEPT,%al
  32.     cmpw    $TS_RUN*256,%ax
  33.     jne    disp
  34.  
  35.     /* ...move task to the ready list */
  36.     movb    $TS_READY,tc_State(%ecx)
  37.     leal    Enqueue(%ebx),%edx
  38.     pushl    %ebx
  39.     pushl    %ecx
  40.     leal    TaskReady(%ebx),%eax
  41.     pushl    %eax
  42.     call    *%edx
  43.     addl    $12,%esp
  44.  
  45.     /* Prepare dispatch */
  46. disp:    leal    Dispatch(%ebx),%eax
  47.     movl    %eax,16(%esp)
  48.  
  49.     /* restore registers and dispatch */
  50.     popl    %edx
  51.     popl    %ecx
  52.     popl    %ebx
  53.     popl    %eax
  54.     ret
  55.