home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / icon / dos / src / config / os2 / microsft / rswitch.asm < prev    next >
Encoding:
Assembly Source File  |  1991-04-28  |  1.2 KB  |  70 lines

  1. .lall
  2. .286p
  3. .model Huge,C
  4.  
  5. .data
  6. errmsg    db    'INTERP() RETURNED IN COSWITCH',0
  7.  
  8. .code
  9.     extrn  syserr:far
  10.     extrn  interp:far
  11.     Public coswitch
  12. ; void coswitch(oldstate,newstate,first)
  13. ; int *oldstate, *newstate;
  14. ; int first;
  15. coswitch Proc Far oldstate:Far Ptr, newstate:Far Ptr, first:Word
  16. ;
  17. ;  oldstate[0] = stack pointer;
  18. ;
  19.     Les    Bx,oldstate
  20.     Mov    Ax,Ss        ; get current stack address
  21.     Mov    Cx,Sp
  22.     Mov    Es:[Bx+2],Ax    ; stash away..
  23.     Mov    Es:[Bx+0],Cx
  24.     Mov    Es:[Bx+4],Si
  25.     Mov    Es:[Bx+6],Di
  26. ;  if (first) {
  27.     Cmp    first,0
  28.     Jnz    notfirst
  29. ;      stackp = newstate[0];
  30. ;-----
  31. ; We have to do some special processing here..
  32. ; Since this is the first time through, we have to
  33. ; set sp equal to stksize.
  34. ;
  35.     Les    Bx,newstate
  36.     Mov    Ax,Es:[Bx+2]
  37.     Mov    Cx,Es:[Bx+0]
  38.     Mov    Si,Es:[Bx+4]
  39.     Mov    Di,Es:[Bx+6]
  40.     Mov    Ss,Ax
  41.     Mov    Sp,Cx
  42.     Push    Bp
  43.     Mov    Bp,Sp
  44. ;      interp(0,NULL);
  45.  
  46.     push    0
  47.     push    0
  48.     push    0
  49.     call    interp
  50.     Add    sp,4
  51. ;    syserr("interp() returned in coswitch");
  52.     push    ds
  53.     push    offset errmsg
  54.     call    syserr
  55. ;  }
  56. ;  else {
  57. notfirst:
  58. ;      stackp = newstate[0];
  59.     Les    Bx,newstate
  60.     Mov    Ax,Es:[Bx+2]
  61.     Mov    Cx,Es:[Bx+0]
  62.     Mov    Si,Es:[Bx+4]
  63.     Mov    Di,Es:[Bx+6]
  64.     Mov    Ss,Ax
  65.     Mov    Sp,Cx
  66.     Mov    Bp,Sp
  67.     Ret
  68. coswitch Endp
  69.     End
  70.