⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interrup.asm

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 ASM
📖 第 1 页 / 共 4 页
字号:
        movzx   ebp,bp
        movzx   eax,w[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+(2+2)]
        jmp     @@Use16Bit19
@@Use32Bit19:   mov     eax,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+(4+4)]
@@Use16Bit19:   mov     [ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)],eax
        mov     edx,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4)]
        sub     edx,offset IntNN386Catch
        shr     edx,3
        mov     d[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4)],0
        ;
        mov     edi,ebp
        push    ss
        pop     es
        ;
        ;If this is a "hardware" interrupt we should mark it as
        ;busy if it isn't already marked.
        ;
        mov     ebx,edx
        push    ds
        mov     ax,KernalDS
        mov     ds,ax
        assume ds:_cwRaw
        mov     al,[ebx+Int2CallCheck]
        or      al,al           ;Hardware?
        jz      @@c2
        sub     bl,al
        shl     ebx,3           ;*8
        mov     eax,ebx
        shl     ebx,1           ;*16
        add     ebx,eax         ;*24
        add     ebx,offset CallBackTable
        test    CallBackFlags[ebx],1
        jz      @@c2
        test    CallBackFlags[ebx],128  ;already busy?
        jnz     @@c2
        or      CallBackFlags[ebx],128  ;mark it as busy.
        mov     d[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4)],ebx
        assume ds:_cwDPMIEMU
@@c2:   pop     ds
        ;
        ;Now pass control to the INT simulator.
        ;
        mov     eax,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)]
        and     eax,1111100011111111b
        push    eax
        popfd
        mov     ebx,edx
        mov     es:Real_SP[edi],0
        mov     es:Real_SS[edi],0
        call    EmuRAWSimulateINT
        ;
        cmp     d[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4)],0
        jz      @@NoCall
        push    ds
        mov     esi,d[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4)]
        mov     ax,KernalDS
        mov     ds,ax
        assume ds:_cwRaw
        and     CallBackFlags[esi],255-128
        assume ds:_cwDPMIEMU
        pop     ds
@@NoCall:       ;
        ;Update the flags.
        ;
        mov     ax,es:Real_Flags[edi]
        and     ax,1000100011111111b            ;lose IF.
        ;
        test    DpmiEmuSystemFlags,1
        jz      @@Use32Bit
        mov     bx,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+(2+2)]
        and     bx,0111011100000000b            ;retain IF.
        or      ax,bx
        mov     [ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+(2+2)],ax
        popad
        add     sp,10*2
        popm    ds,es,fs,gs
        add     sp,4+4+4
        db 66h
        iret                    ;Switch back to calling program.
        ;
@@Use32Bit:     mov     bx,[ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+(4+4)]
        and     bx,0111011100000000b            ;retain IF.
        or      ax,bx
        mov     [ebp+(4+4+4+4+4+4+4+4)+(10*2)+(4+4+4+4)+(4+4+4)+(4+4)],ax
        popad
        add     esp,10*2
        popm    ds,es,fs,gs
        add     esp,4+4+4
        iretd                   ;Switch back to calling program.
IntNN386        endp


;-------------------------------------------------------------------------------
;
;An unhandled low level exception has occured so terminate the program.
;
ExcepNN386      proc    far
        pushm   eax,ds
        mov     ax,DpmiEmuDS
        mov     ds,ax
        mov     eax,[esp+(4+4)]
        sub     eax,offset ExcepNN386Catch
        shr     eax,3
        mov     ExceptionIndex,eax
        popm    eax,ds
        add     esp,4           ;skip return address
        ;
        pushm   ds,es,fs,gs
        pushm   eax,ebx,ecx,edx,esi,edi,ebp             ;save general registers.
        mov     ax,DpmiEmuDS            ;make our data addresable.
        mov     ds,ax           ;/
        test    DpmiEmuSystemFlags,1
        jz      @@Use32Bit16
        movzx   eax,w[esp+(4+4+4+4)+(4+4+4+4+4+4+4)+(2+2)]
        mov     ExceptionEFL,eax
        jmp     @@Use16Bit16
@@Use32Bit16:   mov     eax,[esp+(4+4+4+4)+(4+4+4+4+4+4+4)+(4+4)]
        mov     ExceptionEFL,eax
        ;
@@Use16Bit16:   ;Retrieve register values and get outa here.
        ;
        mov     ax,DpmiEmuDS            ;make sure our data is addresable.
        mov     es,ax           ;/
        assume es:_cwDPMIEMU
        mov     ax,ss
        mov     ds,ax
        assume ds:nothing
        mov     esi,esp
        mov     edi,offset ExceptionEBP
        mov     ecx,(4+4+4+4+4+4+4)+(4+4+4+4)
        cld
        db 67h
        rep     movsb           ;copy registers off the stack.
        ;
        test    cs:DpmiEmuSystemFlags,1
        jz      @@Use32Bit17
        add     esi,2+2+2               ;skip return address/flags.
        db 67h
        movsw
        add     edi,2
        db 67h
        movsw
        add     edi,2
        db 67h
        movsw
        add     edi,2
        jmp     @@Use16Bit17
@@Use32Bit17:   add     esi,4+4+4               ;skip return address/flags.
        mov     ecx,4+4+4
        cld
        db 67h
        rep     movsb           ;get real return address.
@@Use16Bit17:   ;
        test    cs:DpmiEmuSystemFlags,1
        jz      @@Use32Bit678
        movzx   eax,w[esi]
        mov     es:ExceptionESP,eax
        mov     ax,[esi+2]
        mov     es:ExceptionSS,ax
        jmp     @@Use16Bit678
        ;
@@Use32Bit678:  mov     eax,[esi]
        mov     es:ExceptionESP,eax
        mov     ax,[esi+4]
        mov     es:ExceptionSS,ax
@@Use16Bit678:  ;
        push    es
        pop     ds
        assume es:nothing
        assume ds:_cwDPMIEMU
;
;Now switch to PL0 to get CR0-3 values.
;
        call    EmuRawPL32PL0
        str     ax              ;get TR
        mov     ExceptionTR,ax
        mov     eax,cr0
        mov     ExceptionCR0,eax
        mov     eax,cr2
        mov     ExceptionCR2,eax
        mov     eax,cr3
        mov     ExceptionCR3,eax
        mov     cx,MainSS
        mov     edx,offset _cwStackEnd-256
        call    EmuRawPL02PL3
;
;Convert register values into ASCII ready for printing.
;
        mov     eax,ExceptionIndex
        mov     ecx,2
        mov     edi,offset ExceptionINum
        call    Bin2HexE
        mov     eax,ExceptionCode       ;high word undefined upto 486.
        mov     ecx,4
        mov     edi,offset ExceptionENum
        call    Bin2HexE
        ;
        movzx   eax,ExceptionTR
        mov     ecx,4
        mov     edi,offset ExceptionTRt
        call    Bin2HexE
        mov     eax,ExceptionCR0
        mov     ecx,8
        mov     edi,offset ExceptionCR0t
        call    Bin2HexE
        mov     eax,ExceptionCR2
        mov     ecx,8
        mov     edi,offset ExceptionCR2t
        call    Bin2HexE
        mov     eax,ExceptionCR3
        mov     ecx,8
        mov     edi,offset ExceptionCR3t
        call    Bin2HexE
        ;
        mov     eax,ExceptionEAX
        mov     ecx,8
        mov     edi,offset ExceptionEAXt
        call    Bin2HexE
        mov     eax,ExceptionEBX
        mov     ecx,8
        mov     edi,offset ExceptionEBXt
        call    Bin2HexE
        mov     eax,ExceptionECX
        mov     ecx,8
        mov     edi,offset ExceptionECXt
        call    Bin2HexE
        mov     eax,ExceptionEDX
        mov     ecx,8
        mov     edi,offset ExceptionEDXt
        call    Bin2HexE
        mov     eax,ExceptionESI
        mov     ecx,8
        mov     edi,offset ExceptionESIt
        call    Bin2HexE
        mov     eax,ExceptionEDI
        mov     ecx,8
        mov     edi,offset ExceptionEDIt
        call    Bin2HexE
        mov     eax,ExceptionEBP
        mov     ecx,8
        mov     edi,offset ExceptionEBPt
        call    Bin2HexE
        mov     eax,ExceptionESP
        mov     ecx,8
        mov     edi,offset ExceptionESPt
        call    Bin2HexE
        mov     eax,ExceptionEIP
        mov     ecx,8
        mov     edi,offset ExceptionEIPt
        call    Bin2HexE
        mov     eax,ExceptionEFL
        mov     ecx,8
        mov     edi,offset ExceptionEFLt
        call    Bin2HexE
        ;
        movzx   eax,ExceptionCS
        mov     ecx,4
        mov     edi,offset ExceptionCSt
        call    Bin2HexE
        movzx   eax,ExceptionDS
        mov     ecx,4
        mov     edi,offset ExceptionDSt
        call    Bin2HexE
        movzx   eax,ExceptionES
        mov     ecx,4
        mov     edi,offset ExceptionESt
        call    Bin2HexE
        movzx   eax,ExceptionFS
        mov     ecx,4
        mov     edi,offset ExceptionFSt
        call    Bin2HexE
        movzx   eax,ExceptionGS
        mov     ecx,4
        mov     edi,offset ExceptionGSt
        call    Bin2HexE
        movzx   eax,ExceptionSS
        mov     ecx,4
        mov     edi,offset ExceptionSSt
        call    Bin2HexE
        mov     edi,offset ExceptionSysFlags
        mov     eax,DpmiEmuSystemFlags
        mov     ecx,8
        call    Bin2HexE
;
;Copy register details into the transfer buffer.
;
        push    ds
        mov     ax,MainDS
        mov     ds,ax
        assume ds:_cwMain
        movzx   edi,TransferReal
        assume ds:_cwDPMIEMU
        pop     ds
        shl     edi,4
        mov     esi,offset ExceptionHeader
        mov     ecx,offset ExceptionHeaderEnd-ExceptionHeader
        mov     ax,KernalZero
        mov     es,ax
        rep     movsb
        push    ds
        pop     es
;
;Print the message.
;
        push    ds
        mov     ax,MainDS
        mov     ds,ax
        assume ds:_cwMain
        mov     ax,TransferReal
        assume ds:_cwDPMIEMU
        pop     ds
        mov     edi,offset ExceptionIntBuffer
        mov     Real_DS[edi],ax
        mov     Real_EDX[edi],0
        mov     Real_EAX[edi],0900h
        mov     Real_SP[edi],0
        mov     Real_SS[edi],0
        mov     bl,21h
        call    EmuRawSimulateINT
;
;Now switch back to exit code.
;
        mov     ax,InitDS
        mov     ds,ax
        assume ds:_cwInit
        mov     IErrorNumber,0
        mov     ax,InitCS
        push    ax
        mov     ax,offset InitError
        push    ax
        db 66h
        retf
        assume ds:_cwDPMIEMU
ExcepNN386      endp

;
DpmiEmuSystemFlags dd 0
;
; do NOT change order of these variables (you can add at the end), MED 01/08/96
ExceptionCode   dd 0
ExceptionFlags  dd 0
ExceptionIndex dd 0
;
ExceptionEBP    dd ?
ExceptionEDI    dd ?
ExceptionESI    dd ?
ExceptionEDX    dd ?
ExceptionECX    dd ?
ExceptionEBX    dd ?
ExceptionEAX    dd ?
ExceptionGS     dw ?,?
ExceptionFS     dw ?,?
ExceptionES     dw ?,?
ExceptionDS     dw ?,?
ExceptionEIP    dd ?
ExceptionCS     dw ?,?
ExceptionEFL    dd ?
ExceptionESP    dd ?
ExceptionSS     dw ?,?
ExceptionTR     dw ?
ExceptionCR0    dd ?
ExceptionCR2    dd ?
ExceptionCR3    dd ?
;
ExceptionHeader label byte
        db 13,10,"CauseWay Error 09 : Unrecoverable internal exception, program terminated.",13,10
        db 13,10,'Exception: '
ExceptionINum   db '00, Error code: '
ExceptionENum   db '0000',13,10,13,10
        db 'EAX='
ExceptionEAXt   db '00000000 '
        db 'EBX='
ExceptionEBXt   db '00000000 '
        db 'ECX='
ExceptionECXt   db '00000000 '
        db 'EDX='
ExceptionEDXt   db '00000000 '
        db 'ESI='
ExceptionESIt   db '00000000 '
        db 13,10
        db 'EDI='
ExceptionEDIt   db '00000000 '
        db 'EBP='
ExceptionEBPt   db '00000000 '
        db 'ESP='
ExceptionESPt   db '00000000 '
        db 'EIP='
ExceptionEIPt   db '00000000 '
        db 'EFL='
ExceptionEFLt   db '00000000 '
        db 13,10,13,10
        db 'CS='
ExceptionCSt    db '0000 '
        db 'DS='
ExceptionDSt    db '0000 '
        db 'ES='
ExceptionESt    db '0000 '
        db 'FS='
ExceptionFSt    db '0000 '
        db 'GS='
ExceptionGSt    db '0000 '
        db 'SS='
ExceptionSSt    db '0000 '
        db 13,10,13,10
        db 'CR0='
ExceptionCR0t   db '00000000 '
        db 'CR2='
ExceptionCR2t   db '00000000 '
        db 'CR3='
ExceptionCR3t   db '00000000 '
        db 'TR='
ExceptionTRt    db '0000'
        db 13,10,13,10
        db 'SystemFlags='
ExceptionSysFlags db '00000000 '
        db 13,10,13,10,'$'
ExceptionHeaderEnd      label byte
;
ExceptionIntBuffer db size RealRegsStruc dup (?)
;


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -