home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / internal / i386-emul / preparecontext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.6 KB  |  75 lines

  1. #include <exec/types.h>
  2. #include <aros/libcall.h>
  3.  
  4. /*****************************************************************************
  5.  
  6.     NAME */
  7.  
  8.     __AROS_LH3I(APTR, PrepareContext,
  9.  
  10. /*  SYNOPSIS */
  11.     __AROS_LA(APTR, stackPointer, A0),
  12.     __AROS_LA(APTR, entryPoint,   A1),
  13.     __AROS_LA(APTR, fallBack,     A2),
  14.  
  15. /*  LOCATION */
  16.     struct ExecBase *, SysBase, 9, Exec)
  17.  
  18. /*  FUNCTION
  19.     Allocates the space required to hold a new set of registers on the
  20.     Stack given by stackPointer and clears the area except for pc which
  21.     is set to the address given by entryPoint.
  22.  
  23.     INPUTS
  24.     stackPointer - Pointer to a scpecific stack
  25.     entryPoint   - Address of the function to call when the new context
  26.                becomes active.
  27.     fallBack     - Address to be called when the entryPoint function ended
  28.                with an rts.
  29.  
  30.     RESULT
  31.     The new Stackpointer with the underlying context.
  32.  
  33.     NOTES
  34.     This function is for internal use by exec only.
  35.  
  36.     This function is processor dependant.
  37.  
  38.     EXAMPLE
  39.  
  40.     BUGS
  41.  
  42.     SEE ALSO
  43.     SwitchTasks()
  44.  
  45.     INTERNALS
  46.  
  47.     HISTORY
  48.  
  49. ******************************************************************************/
  50. {
  51.     __AROS_FUNC_INIT
  52.     UBYTE *sp=(UBYTE *)stackPointer;
  53.     int i;
  54.  
  55.     /* i386 version. No FPU supported yet. */
  56.  
  57.     /* Push fallback address */
  58.     sp-=sizeof(APTR);
  59.     *(APTR *)sp=fallBack;
  60.  
  61.     /* Now push the context. Prepare returnaddress (pc). */
  62.     sp-=sizeof(APTR);
  63.     *(APTR *)sp=entryPoint;
  64.  
  65.     /* Push 7 registers */
  66.     for(i=0;i<7;i++)
  67.     {
  68.     sp-=sizeof(LONG);
  69.     *(LONG *)sp=0;
  70.     }
  71.  
  72.     return sp;
  73.     __AROS_FUNC_EXIT
  74. } /* PrepareContext */
  75.