home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / catch / xception.asm < prev    next >
Encoding:
Assembly Source File  |  1987-11-13  |  1.4 KB  |  53 lines

  1.     public    Catch
  2.     public    Throw
  3.  
  4. BreakPnt struc
  5. cSS     dw      ?
  6. cSP    dw    ?
  7. cBP    dw    ?
  8. cIP    dw    ?            ; offset is low word
  9. cCS    dw    ?
  10. tIP     dw      ?
  11. tCS     dw      ?
  12. BreakPnt ends
  13.  
  14. code    segment    word    public
  15.  
  16. Catch    proc    far
  17.     pop    dx            ; Ofs(return address)
  18.     pop    bx            ; Seg(Return address}
  19.     pop    di            ; Ofs(Break)
  20.     pop    es            ; Seg(Break)
  21.     cld                             ; we use STOSW to save
  22.                                         ; a few bytes
  23.         mov     ax,ss                   ; get the stack segment
  24.     stosw                ; save the stack ptr
  25.         mov     ax,sp                   ; get the stack ptr
  26.     stosw                ; save the stack ptr
  27.     mov    ax,bp            ; get the base ptr
  28.     stosw                ; save the base ptr
  29.     mov    ax,dx            ; get Ofs(Return address)
  30.     stosw                ; save Ofs(Return address)
  31.     mov    ax,bx            ; get Seg(Return address)
  32.     stosw                       ; save Seg(Return address)
  33.     xor     ax,ax                   ; Return BreakPointSet
  34.         jmp     dword ptr es:[di-4]     ; eIP
  35. Catch    endp
  36.  
  37. Throw    proc    far
  38.     pop    ax            ; Ofs(return address)
  39.     pop    dx            ; Seg(return address)
  40.     pop    di            ; get Ofs(BreakPnt)
  41.     pop    es            ; get Seg(BreakPnt)
  42.         mov    es:[di].tCS,dx          ; save the Throw-ing point
  43.         mov     es:[di].tIP,ax
  44.     mov    ss,es:[di].cSS        ; restore Catch's SS
  45.     mov    sp,es:[di].cSP        ; restore Catch's SP
  46.     mov    bp,es:[di].cBP        ; restore Catch's BP
  47.     mov    ax,1                    ; Return BreakPointUsed
  48.     jmp     dword ptr es:[di].cIP
  49. Throw    endp
  50.  
  51. code    ends
  52.     end
  53.