home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / spawn / wspawn.asm < prev   
Assembly Source File  |  1988-08-10  |  2KB  |  61 lines

  1.  
  2.  
  3.  
  4. include cmacros.inc
  5.  
  6. externFP   <GlobalCompact>
  7.  
  8. createSeg   ASMCODE,ASMCODE,PARA,PUBLIC,ASMCODE
  9.  
  10. ;;
  11. ;;  Int21Function4B cannot be a discardable segment.  If the segment
  12. ;;  were discardable, the int21 interrupt might cause it to be discarded
  13. ;;  and then reread from disk.  This would set stackSS and stackSP to 0.
  14. ;;  Upon return from int21, SS would be set to 0 and SP would be set to
  15. ;;  0.
  16. ;;
  17. ;;  Warning:  the code is not reentrant.  Multiple sp's cannot be saved.
  18. ;;  Warning:  In applications SS == DS by default.  If the DS should move
  19. ;;  the stored SS would be invalidated.  For maximum reliability it is
  20. ;;  recommended that LockData(), UnlockData() call bracket the call to
  21. ;;  int21function4B.
  22. ;;  Warning:  Should the code segment move using the debugging KERNEL,
  23. ;;  the segment will be checksummed and the write of SS:SP into the
  24. ;;  code segment detected as a fatal error.  To avoid this extraneous
  25. ;;  ( in this one instance ) error condition,
  26. ;;  use the non-debugging kernel or place the code in a fixed segment.
  27. ;;
  28.  
  29. assumes CS,ASMCODE
  30. assumes DS,DATA
  31.  
  32.  
  33. sBegin DATA
  34. sEnd   DATA
  35.  
  36. sBegin ASMCODE
  37.     stackSS dw 0
  38.     stackSP dw 0
  39.  
  40. cProc   Int21Function4B,<PUBLIC,FAR>,<ax,bx,cx,dx,si,di,es,ds>
  41.     parmB mode
  42.     parmD path
  43.     parmD execblock
  44. cBegin
  45.       mov ax,-1
  46.       cCall GlobalCompact,<ax,ax>
  47.     mov cs:[stackSS],ss         ;; EXEC destroys all register. Save SS:SP.
  48.     mov cs:[stackSP],sp
  49.     mov al,mode
  50.     lds dx,path
  51.     les bx,execblock
  52.     mov ah,4bh
  53.     int 21h
  54.     mov ss,cs:[stackSS]
  55.     mov sp,cs:[stackSP]
  56. ; AX is return value
  57. cEnd
  58.  
  59. sEnd ASMCODE
  60. END
  61.