home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_03
/
1103078a
< prev
next >
Wrap
Text File
|
1993-01-05
|
2KB
|
42 lines
; ctxtswc will do a contextswitch by changing stacks.
; the stack in use will be stored on the heap, and the
; new stack which is previously stored on the heap,
; will be loaded.
.MODEL COMPACT
.CODE
EXTRN __stklen:word
EXTRN _PREVIOUS:dword
EXTRN _CURRENT:dword
PUBLIC @ctxtswc$qv
@ctxtswc$qv PROC NEAR
push bp ; save bp
mov cx,__stklen ; put nmbr of bytes
sub cx,sp ; in cx
les bx,dword ptr DGROUP:_PREVIOUS
mov word ptr es:[bx+4],cx ; save sz of usedstk
mov di,word ptr es:[bx+2] ; set adr for stk
mov es,word ptr es:[bx] ; copy in di and es
mov ax,ds ; save ds
mov bx,ss ; set adr of stk in
mov ds,bx ; ds
mov si,sp ; and si
rep movsb ; do copy
mov ds,ax ; reset ds
les bx,dword ptr DGROUP:_CURRENT
mov cx,word ptr es:[bx+4] ; get sz of stk copy
mov ax,ds ; save ds
mov sp,__stklen
sub sp,cx ; set stkPtr
mov si,word ptr es:[bx+2] ; set adr of stored
mov ds,word ptr es:[bx] ; stk in si and ds
mov di,sp ; set dest for copy
mov dx,ss ; di=stkPtr
mov es,dx ; and es=stkSeg
rep movsb ; do copy
mov ds,ax ; reset ds
pop bp ; reset bp
ret
@ctxtswc$qv ENDP
END