home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / config / m68k-native / runprocess.s < prev    next >
Encoding:
Text File  |  1996-11-26  |  1.6 KB  |  57 lines

  1. /*
  2.      (C) 1995-96 AROS - The Amiga Replacement OS
  3.      $Id: runprocess.s,v 1.2 1996/11/26 00:21:43 aros Exp $
  4.  
  5.      Desc: Run a process ( invoked by dos/Runcommand() )
  6.      Lang:
  7.  
  8.   LONG RunProcess ( struct Process         * proc,
  9.              struct StackSwapStruct * sss,
  10.              STRPTR             argptr,
  11.              ULONG             argsize,
  12.              LONG_FUNC             entry,
  13.              struct DosLibrary       * DOSBase
  14. */
  15.  
  16.     #include "machine.i"
  17.  
  18.     # Stackframe
  19.     FirstArg    = 4+(2*4)    /* Return-address + registers */
  20.     proc        = FirstArg
  21.     sss        = proc+4
  22.     argptr        = sss+4
  23.     argsize        = argptr+4
  24.     entry        = argsize+4
  25.     DOSBase        = entry+4
  26.  
  27.     .text
  28.     .balign 16
  29.     .globl    AROS_SLIB_ENTRY(RunProcess,Dos)
  30.     .type    AROS_SLIB_ENTRY(RunProcess,Dos),@function
  31. AROS_SLIB_ENTRY(RunProcess,Dos):
  32.     movem.l    a5-a6,-(sp)        /* Save some registers */
  33.  
  34.     move.l    sss(sp),a0        /* Fetch the arguments off the stack */
  35.     move.l    entry(sp),a5        /* "     "   "         "   "   " */
  36.  
  37.     move.l    stk_Upper(a0),a1    /* Move upper bounds of the new stack into a1 */
  38.     move.l    a0,-(a1)        /* Push sss onto the new stack */
  39.     move.l    DOSBase(sp),a6        /* Get SysBase */
  40.     move.l    dl_SysBase(a6),a6    /* "   " */
  41.     move.l    a6,-(a1)        /* Push SysBase onto the new stack */
  42.     move.l    a1,stk_Pointer(a0)    /* Store Switch Point in sss */
  43.  
  44.     jsr    StackSwap(a6)        /* Switch stacks (a0=sss) */
  45.  
  46.     jsr    (a5)            /* Call the specified routine */
  47.     move.l    d0,a5            /* Save return value */
  48.  
  49.     move.l    (sp)+,a6        /* Pop SysBase off the new stack */
  50.     move.l    (sp)+,a0        /* Pop sss off the new stack */
  51.     jsr    StackSwap(a6)        /* Switch stacks back */
  52.  
  53.     move.l    a5,d0            /* Put result in d0 where our caller expects it */
  54.  
  55.     movem.l    (sp)+,a5-a6        /* Restore registers */
  56.     rts
  57.