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

📄 api.asm

📁 开放源码的编译器open watcom 1.6.0版的源代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
        ret
cwAPI_SetDump   ENDP

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
; change CW.ERR file name, with optional path/drivespec
;
;On Entry:
;
; AX = 0ff32h
; CX:[E]DX = new CW.ERR ASCIIZ file name
;
;Returns:
;
; None
;
cwAPI_CWErrName PROC    NEAR
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        mov     edx,[ebp+Int_EDX]
        test    BYTE PTR cs:apiSystemFlags,1
        jz      cen2
        movzx   edx,dx  ; 16-bit, zero high word of edx

cen2:
        mov     ax,[ebp+Int_CX]
        mov     es,ax
        mov     ebx,OFFSET NewCWErrName ; ds:ebx -> destination, es:edx -> source
        mov     cx,80           ; don't allow more than 80 chars in file name

cenloop:
        mov     al,es:[edx]
        test    al,al
        je      centerm         ; at null terminator
        mov     ds:[ebx],al
        inc     edx
        inc     ebx
        dec     cx
        jne     cenloop

centerm:
        mov     BYTE PTR ds:[ebx],0
        ret
cwAPI_CWErrName ENDP

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Setup user buffer display in CW.ERR file
;
;On Entry:
;
; AX = 0ff2fh
; ES:[E]DI -> user buffer to display in CW.ERR
; CX = count of bytes to display from buffer in CW.ERR
; BL = 'A' if ASCII dump (non-binary display of bytes, control characters
;      display as periods)
; BH = nonzero if preset ASCII buffer to word value, ignored for non-ASCII
; DX = word value to fill ASCII dump buffer if BH is nonzero, ignored
;      for non-ASCII
;
;Returns:
;
; Carry set on ASCII dump invalid buffer address
;
cwAPI_UserDump  PROC    NEAR
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        mov     ax,[ebp+Int_ES]
        verr    ax
        jnz     udfail                  ; can't read to user selector
        mov     DebugUserSel,ax
        mov     es,ax

        mov     edi,[ebp+Int_EDI]
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     api9_0
        movzx   edi,di
api9_0:
        mov     DebugUserOff,edi
        mov     cx,[ebp+Int_CX]
        mov     DebugUserCount,cx

; check for out of bounds
        movzx   edx,cx
        add     edx,edi
        jc      udfail
        dec     edx                             ; make relative 0
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,edx
        jb      udfail

        mov     al,[ebp+Int_BL]
        cmp     al,'A'
        je      aflag
        xor     al,al

aflag:
        mov     DebugAsciiFlag,al
        test    al,al
        je      udret                   ; if not ASCII then no fill
        mov     al,[ebp+Int_BH] ; check fill flag
        test    al,al           ; no fill, carry flag reset by default
        je      udret

; fill the allocation with value in dx to count specified in cx
        mov     ax,es
        verw    ax
        jnz     udfail                  ; can't write to user selector
        mov     ax,[ebp+Int_DX]
        push    ax
        push    ax
        pop     eax
        push    ecx
        shr     ecx,1
        rep     stosd
        pop     ecx
        and     cx,3
        je      udsuccess
        mov     es:[edi],al             ; finish off remainder bytes
        dec     cx
        je      udsuccess
        inc     edi
        mov     es:[edi],ah
        dec     cx
        je      udsuccess
        inc     edi
        mov     es:[edi],al

udsuccess:
        clc                                     ; flag success
        jmp     udret

udfail:
        mov     DebugUserCount,0
        stc                                     ; flag failure

udret:
        cwAPI_C2C
        ret
cwAPI_UserDump  ENDP

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Get CauseWay identifier, return PageDIRLinear and Page1stLinear info
;
;Returns:
;
;EDX    - Linear address of patch table.
;
cwAPI_ID        proc    near
        push    ds
        assume ds:nothing
        mov     ax,KernalDS
        mov     ds,ax
        assume ds:_cwRaw
        mov     esi,PageDIRLinear
        mov     edi,Page1stLinear
        pop     ds
        mov     ecx,"CAUS"
        mov     edx,"EWAY"
        mov     [ebp+Int_ESI],esi
        mov     [ebp+Int_EDI],edi
        mov     [ebp+Int_EDX],edx
        mov     [ebp+Int_ECX],ecx
        xor     al,al
        cwAPI_AL2C
        ret
cwAPI_ID        endp

;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Get patch table address.
;
;Returns:
;
;EDX    - Linear address of patch table.
;
cwAPI_GetPatch  proc    near
        assume ds:nothing
        mov     bx,cs:apiDDSeg
        sys     GetSelDet32
        add     edx,offset PatchTable
        assume ds:_apiCode
        mov     [ebp+Int_EDX],edx
        xor     al,al
        cwAPI_AL2C
        ret
cwAPI_GetPatch  endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Get address of transfer buffer.
;
;Returns:
;
;BX     - Real mode segment
;DX     - Protected mode selector.
;ECX    - Buffer size.
;
cwAPI_GetDOSTrans proc near
        assume ds:nothing
        mov     es,cs:apiDSeg
        assume es:_cwMain
        mov     es,es:PSPSegment
        assume es:nothing
        assume ds:_apiCode
        mov     ax,WORD PTR es:[EPSP_Struc.EPSP_TransReal]
        mov     [ebp+Int_BX],ax
        mov     ax,WORD PTR es:[EPSP_Struc.EPSP_TransProt]
        mov     [ebp+Int_DX],ax
        mov     eax,DWORD PTR es:[EPSP_Struc.EPSP_TransSize]
        mov     [ebp+Int_ECX],eax
        ret
cwAPI_GetDOSTrans endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Set real mode transfer buffer address.
;
;On Entry:
;
;BX     - Real mode segment.
;DX     - Protected mode selector.
;ECX    - Buffer size.
;
cwAPI_SetDOSTrans proc near
        mov     bx,[ebp+Int_BX]
        mov     dx,[ebp+Int_DX]
        mov     ecx,[ebp+Int_ECX]
        assume ds:nothing
        mov     es,cs:apiDSeg
        assume es:_cwMain
        mov     es,es:PSPSegment
        assume es:nothing
        assume ds:_apiCode
        mov     WORD PTR es:[EPSP_Struc.EPSP_TransReal],bx
        mov     WORD PTR es:[EPSP_Struc.EPSP_TransProt],dx
        cmp     ecx,10000h
        jc      api13_0
        mov     ecx,65535
api13_0:        mov     DWORD PTR es:[EPSP_Struc.EPSP_TransSize],ecx
        ret
cwAPI_SetDOSTrans endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Get various useful variable contents.
;
;Returns:
;
;AX     - 0-4G selector.
;BX     - Current PSP selector.
;ECX    - Transfer buffer size.
;DX     - Transfer buffer real mode segment.
;ESI    - Transfer buffer offset.
;DI     - System flags.
;ES     - Transfer buffer protected mode selector.
;
cwAPI_Info      proc    near
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        mov     di,w[SystemFlags]
        mov     ax,RealSegment
        mov     bx,PspSegment
        mov     es,bx
        mov     dx,WORD PTR es:[EPSP_Struc.EPSP_TransReal]
        mov     ecx,DWORD PTR es:[EPSP_Struc.EPSP_TransSize]
        mov     es,WORD PTR es:[EPSP_Struc.EPSP_TransProt]
        xor     esi,esi
        assume ds:_apiCode
        mov     [ebp+Int_AX],ax
        mov     [ebp+Int_BX],bx
        mov     [ebp+Int_ECX],ecx
        mov     [ebp+Int_DX],dx
        mov     [ebp+Int_ESI],esi
        mov     [ebp+Int_DI],di
        mov     [ebp+Int_ES],es
        ret
cwAPI_Info      endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Pass control to a real mode interrupt handler.
;
;On Entry:
;
;BL     - INT number.
;ES:[E]DI       - Real mode register structure.
;
cwAPI_IntXX     proc    near
        mov     edi,[ebp+Int_EDI]
        mov     es,[ebp+Int_ES]
;       mov     bl,[ebp+Int_BL]
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     api15_0
        movzx   edi,di
api15_0:        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        cmp     ProtectedType,2
        assume ds:_apiCode
        jnz     api15_NoStack0
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        sub     DPMIStackOff,RawStackDif
        mov     ax,DPMIStackOff
        add     ax,RawStackDif
        mov     es:RealRegsStruc.Real_SP[edi],ax
        mov     ax,DPMIStackSeg
        mov     es:RealRegsStruc.Real_SS[edi],ax

; MED 05/23/96
        test    BYTE PTR cs:apiSystemFlags,1
        jz      medUse32Bit8
        mov     ebx,Int_Flags16
        jmp     medUse16Bit8

medUse32Bit8:
        mov     ebx,Int_Flags32

medUse16Bit8:
        mov     ax,ss:[ebp+ebx]
        and     ax,1111110011111111b    ;clear Trap and INT flag.
        mov     es:RealRegsStruc.Real_Flags[edi],ax     ; explicitly set flags on DPMI 300h call

        assume ds:_apiCode
        jmp     api15_DoneStack0
api15_NoStack0:
        mov     es:RealRegsStruc.Real_SP[edi],0 ;use DPMI provided stack.
        mov     es:RealRegsStruc.Real_SS[edi],0
api15_DoneStack0:
        xor     cx,cx           ;No stack parameters.
        mov     bh,ch           ;no flags.

        mov     bl,ss:[ebp+Int_BL]      ; MED 05/23/96

        mov     ax,0300h
        cwAPI_CallOld
        cwAPI_C2C
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        cmp     ProtectedType,2
        assume ds:_apiCode
        jnz     api15_DoneStack1
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        add     DPMIStackOff,RawStackDif
        assume ds:_apiCode
api15_DoneStack1:       assume ds:nothing
        test    BYTE PTR cs:apiSystemFlags,1
        assume ds:_apiCode
        jz      api15_Use32Bit8
        mov     ebx,Int_Flags16
        jmp     api15_Use16Bit8
api15_Use32Bit8:        mov     ebx,Int_Flags32
api15_Use16Bit8:        mov     ax,ss:[ebp+ebx]
        and     ax,0000011000000000b            ;retain IF.
        and     es:RealRegsStruc.Real_Flags[edi],1111100111111111b      ;lose IF.
        or      es:RealRegsStruc.Real_Flags[edi],ax
        ret
cwAPI_IntXX     endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Pass control to a real mode far routine.
;
;On Entry:
;
;ES:[E]DI       - Real mode register structure.
;
cwAPI_FarCallReal proc near
        mov     edi,[ebp+Int_EDI]
        mov     es,[ebp+Int_ES]
        xor     eax,eax
        mov     ax,es
        lsl     eax,eax
        cmp     eax,10000h
        jnc     api16_0
        movzx   edi,di
api16_0:        pushf
        pop     es:RealRegsStruc.Real_Flags[edi]
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        cmp     ProtectedType,2
        assume ds:_apiCode
        jnz     api16_NoStack1
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        sub     DPMIStackOff,RawStackDif
        mov     ax,DPMIStackOff
        add     ax,RawStackDif
        mov     es:RealRegsStruc.Real_SP[edi],ax
        mov     ax,DPMIStackSeg
        mov     es:RealRegsStruc.Real_SS[edi],ax
        assume ds:_apiCode
        jmp     api16_DoneStack2
api16_NoStack1: mov     es:RealRegsStruc.Real_SP[edi],0 ;use DPMI provided stack.
        mov     es:RealRegsStruc.Real_SS[edi],0
api16_DoneStack2:       xor     cx,cx           ;No stack parameters.
        xor     bx,bx           ;no flags.
        mov     ax,0301h
        cwAPI_CallOld
        cwAPI_C2C
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        cmp     ProtectedType,2
        assume ds:_apiCode
        jnz     api16_DoneStack3
        assume ds:nothing
        mov     ds,cs:apiDSeg
        assume ds:_cwMain
        add     DPMIStackOff,RawStackDif
        assume ds:_apiCode
api16_DoneStack3:       ;
        assume ds:nothing
        test    BYTE PTR cs:apiSystemFlags,1
        assume ds:_apiCode
        jz      api16_Use32Bit8
        mov     ebx,Int_Flags16
        jmp     api16_Use16Bit8
api16_Use32Bit8:        mov     ebx,Int_Flags32
api16_Use16Bit8:        mov     ax,ss:[ebp+ebx]
        and     ax,0000011000000000b            ;retain IF.
        and     es:RealRegsStruc.Real_Flags[edi],1111100111111111b      ;lose IF.
        or      es:RealRegsStruc.Real_Flags[edi],ax
        ret
cwAPI_FarCallReal endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Allocate a selector.
;
;Returns:
;
;Carry set on error (no more selectors) else,
;
;BX     - new selector.
;
cwAPI_GetSel    proc    near
        xor     eax,eax
        xor     ebx,ebx
        call    _SetSelector
        cwAPI_C2C
        jc      api17_9
        mov     [ebp+Int_BX],bx
api17_9:        ret
cwAPI_GetSel    endp


;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
;
;Allocate multiple selectors.
;
;On Entry:
;
;CX     - Number of selectors.
;
;Returns:
;
;Carry set on error (not enough selectors) else,
;
;BX     - Base selector.
;
cwAPI_GetSels   proc    near
;
;Get selectors from DPMI.
;
        mov     cx,[ebp+Int_CX]
        mov     ax,0000h
        cwAPI_CallOld
        cwAPI_C2C
        jc      api18_9
;

⌨️ 快捷键说明

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