home *** CD-ROM | disk | FTP | other *** search
- .lall
- .286p
- .model Huge,C
-
- .data
- errmsg db 'INTERP() RETURNED IN COSWITCH',0
-
- .code
- extrn syserr:far
- extrn interp:far
- Public coswitch
- ; void coswitch(oldstate,newstate,first)
- ; int *oldstate, *newstate;
- ; int first;
- coswitch Proc Far oldstate:Far Ptr, newstate:Far Ptr, first:Word
- ;
- ; oldstate[0] = stack pointer;
- ;
- Les Bx,oldstate
- Mov Ax,Ss ; get current stack address
- Mov Cx,Sp
- Mov Es:[Bx+2],Ax ; stash away..
- Mov Es:[Bx+0],Cx
- Mov Es:[Bx+4],Si
- Mov Es:[Bx+6],Di
- ; if (first) {
- Cmp first,0
- Jnz notfirst
- ; stackp = newstate[0];
- ;-----
- ; We have to do some special processing here..
- ; Since this is the first time through, we have to
- ; set sp equal to stksize.
- ;
- Les Bx,newstate
- Mov Ax,Es:[Bx+2]
- Mov Cx,Es:[Bx+0]
- Mov Si,Es:[Bx+4]
- Mov Di,Es:[Bx+6]
- Mov Ss,Ax
- Mov Sp,Cx
- Push Bp
- Mov Bp,Sp
- ; interp(0,NULL);
-
- push 0
- push 0
- push 0
- call interp
- Add sp,4
- ; syserr("interp() returned in coswitch");
- push ds
- push offset errmsg
- call syserr
- ; }
- ; else {
- notfirst:
- ; stackp = newstate[0];
- Les Bx,newstate
- Mov Ax,Es:[Bx+2]
- Mov Cx,Es:[Bx+0]
- Mov Si,Es:[Bx+4]
- Mov Di,Es:[Bx+6]
- Mov Ss,Ax
- Mov Sp,Cx
- Mov Bp,Sp
- Ret
- coswitch Endp
- End
-