home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / config / i386 / preparecontext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.3 KB  |  102 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: preparecontext.c,v 1.6 1996/12/06 11:07:54 aros Exp $
  4.     $Log: preparecontext.c,v $
  5.     Revision 1.6  1996/12/06 11:07:54  aros
  6.     Vector shuffle
  7.  
  8.     Revision 1.5  1996/11/21 10:49:42  aros
  9.     Created macros AROS_SLIB_ENTRY() for assembler files, too, to solve naming
  10.     problems.
  11.  
  12.     The #includes in the header *must* begin in the first column. Otherwise
  13.     makedepend will ignore them (GCC works, though).
  14.  
  15.     Removed a couple of Logs
  16.  
  17.     Revision 1.4  1996/10/24 15:51:12  aros
  18.     Use the official AROS macros over the __AROS versions.
  19.  
  20.     Revision 1.3  1996/08/13 14:04:57  digulla
  21.     Replaced AROS_LA by AROS_LHA
  22.  
  23.     Revision 1.2  1996/08/01 17:41:26  digulla
  24.     Added standard header for all files
  25.  
  26.     Desc:
  27.     Lang:
  28. */
  29. #include <exec/types.h>
  30. #include <aros/libcall.h>
  31.  
  32. /*****************************************************************************
  33.  
  34.     NAME */
  35.     AROS_LH3I(APTR, PrepareContext,
  36.  
  37. /*  SYNOPSIS */
  38.     AROS_LHA(APTR, stackPointer, A0),
  39.     AROS_LHA(APTR, entryPoint,   A1),
  40.     AROS_LHA(APTR, fallBack,     A2),
  41.  
  42. /*  LOCATION */
  43.     struct ExecBase *, SysBase, 6, Exec)
  44.  
  45. /*  FUNCTION
  46.     Allocates the space required to hold a new set of registers on the
  47.     Stack given by stackPointer and clears the area except for pc which
  48.     is set to the address given by entryPoint.
  49.  
  50.     INPUTS
  51.     stackPointer - Pointer to a scpecific stack
  52.     entryPoint   - Address of the function to call when the new context
  53.                becomes active.
  54.     fallBack     - Address to be called when the entryPoint function ended
  55.                with an rts.
  56.  
  57.     RESULT
  58.     The new Stackpointer with the underlying context.
  59.  
  60.     NOTES
  61.     This function is for internal use by exec only.
  62.  
  63.     This function is processor dependant.
  64.  
  65.     EXAMPLE
  66.  
  67.     BUGS
  68.  
  69.     SEE ALSO
  70.     SwitchTasks()
  71.  
  72.     INTERNALS
  73.  
  74.     HISTORY
  75.  
  76. ******************************************************************************/
  77. {
  78.     AROS_LIBFUNC_INIT
  79.     UBYTE *sp=(UBYTE *)stackPointer;
  80.     int i;
  81.  
  82.     /* i386 version. No FPU supported yet. */
  83.  
  84.     /* Push fallback address */
  85.     sp-=sizeof(APTR);
  86.     *(APTR *)sp=fallBack;
  87.  
  88.     /* Now push the context. Prepare returnaddress (pc). */
  89.     sp-=sizeof(APTR);
  90.     *(APTR *)sp=entryPoint;
  91.  
  92.     /* Push 7 registers */
  93.     for(i=0;i<7;i++)
  94.     {
  95.     sp-=sizeof(LONG);
  96.     *(LONG *)sp=0;
  97.     }
  98.  
  99.     return sp;
  100.     AROS_LIBFUNC_EXIT
  101. } /* PrepareContext */
  102.