home *** CD-ROM | disk | FTP | other *** search
- public Catch
- public Throw
-
- BreakPnt struc
- cSS dw ?
- cSP dw ?
- cBP dw ?
- cIP dw ? ; offset is low word
- cCS dw ?
- tIP dw ?
- tCS dw ?
- BreakPnt ends
-
- code segment word public
-
- Catch proc far
- pop dx ; Ofs(return address)
- pop bx ; Seg(Return address}
- pop di ; Ofs(Break)
- pop es ; Seg(Break)
- cld ; we use STOSW to save
- ; a few bytes
- mov ax,ss ; get the stack segment
- stosw ; save the stack ptr
- mov ax,sp ; get the stack ptr
- stosw ; save the stack ptr
- mov ax,bp ; get the base ptr
- stosw ; save the base ptr
- mov ax,dx ; get Ofs(Return address)
- stosw ; save Ofs(Return address)
- mov ax,bx ; get Seg(Return address)
- stosw ; save Seg(Return address)
- xor ax,ax ; Return BreakPointSet
- jmp dword ptr es:[di-4] ; eIP
- Catch endp
-
- Throw proc far
- pop ax ; Ofs(return address)
- pop dx ; Seg(return address)
- pop di ; get Ofs(BreakPnt)
- pop es ; get Seg(BreakPnt)
- mov es:[di].tCS,dx ; save the Throw-ing point
- mov es:[di].tIP,ax
- mov ss,es:[di].cSS ; restore Catch's SS
- mov sp,es:[di].cSP ; restore Catch's SP
- mov bp,es:[di].cBP ; restore Catch's BP
- mov ax,1 ; Return BreakPointUsed
- jmp dword ptr es:[di].cIP
- Throw endp
-
- code ends
- end