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

📄 int21h.asm

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

IFNDEF DEBUG5
        int     31h
ENDIF

medex2:
        assume ds:nothing
        popad

        push es:Real_Flags[edi] ;save flags.
        mov     eax,es:Real_EAX[edi]
        mov     [ebp+Int_AX],ax ;store errorlevel.
        DOS4GExtend w[ebp+Int_EAX+2]
        ;
        or      dx,dx
        jz      @@Ef15          ;No environment to release.
        mov     es:Real_ES[edi],dx
        mov     es:Real_EAX[edi],4900h  ;release dos memory.
        mov     bl,21h
        sys     IntXX
        ;
@@Ef15: ;Put the DTA back where it's supposed to be.
        ;
        mov     es:Real_EDX[edi],offset DTABuffer
        mov     es:Real_DS[edi],_cwMain
        mov     es:Real_EAX[edi],1a00h
        mov     bl,21h
        sys     IntXX
        ;
        pop     ax
@@Ef13:
        and     ax,1
        call    Int21hAL2Carry
        ret
Int21hExecFile  endp


;------------------------------------------------------------------------------
;
;Function 4E emulation.
;
Int21hFindFirstFile proc near

        mov     es,cs:Int21hDseg        ;point to new source.
        mov     edi,offset DtaBuffer    ;use the real DTA buffer.
        lds     esi,fs:f[EPSP_DTA]      ;point to user buffer.
        mov     ecx,DTASize             ;length to copy.
        rep     movsb           ;copy data returned.

        mov     esi,[ebp+Int_EDX]       ;Point to source data.
        mov     ds,[ebp+Int_DS]
        call    Int21hExtend_DS_ESI     ;Extend [E]SI.
        xor     al,al           ;Character to look for.
        call    Int21hStringLen ;Get length of this string.
        inc     ecx             ;Include terminator.
        mov     es,fs:[EPSP_TransProt]
        xor     edi,edi
        rep     movsb
        mov     edi,offset Int21Buffer
        mov     es,cs:Int21hDSeg
        mov     eax,[ebp+Int_EAX]
        mov     es:Real_EAX[edi],eax
        mov     eax,[ebp+Int_ECX]
        mov     es:Real_ECX[edi],eax
        mov     es:Real_EDX[edi],0
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:Real_DS[edi],ax
        mov     bl,21h
        sys     IntXX
        mov     eax,es:Real_EAX[edi]
        mov     [ebp+Int_AX],ax
        DOS4GExtend w[ebp+Int_EAX+2]
        mov     ax,es:Real_Flags[edi]
        and     al,1
        call    Int21hAL2Carry  ;Set carry.

;       or      al,al
;       jnz     @@9

        mov     ds,cs:Int21hDseg        ;point to new source.
        mov     esi,offset DtaBuffer    ;use the real DTA buffer.
        les     edi,fs:f[EPSP_DTA]      ;point to user buffer.
        mov     ecx,DTASize             ;length to copy.
        rep     movsb           ;copy data returned.
@@9:    ret
Int21hFindFirstFile endp


;------------------------------------------------------------------------------
;
;Function 4F emulation.
;
Int21hFindNextFile proc near
        mov     es,cs:Int21hDseg        ;point to new source.
        mov     edi,offset DtaBuffer    ;use the real DTA buffer.
        lds     esi,fs:f[EPSP_DTA]      ;point to user buffer.
        mov     ecx,DTASize             ;length to copy.
        rep     movsb           ;copy data returned.
        mov     edi,offset Int21Buffer
        mov     es,cs:Int21hDseg
        mov     eax,[ebp+Int_EAX]
        mov     es:Real_EAX[edi],eax
        mov     bl,21h
        sys     IntXX
        mov     eax,es:Real_EAX[edi]
        mov     [ebp+Int_AX],ax
        DOS4GExtend w[ebp+Int_EAX+2]
        mov     ax,es:Real_Flags[edi]
        and     al,1
        call    Int21hAL2Carry  ;Set carry.
;       or      al,al
;       jnz     @@9
        mov     ds,cs:Int21hDseg        ;point to new source.
        mov     esi,offset DtaBuffer    ;use the real DTA buffer.
        les     edi,fs:f[EPSP_DTA]      ;point to user buffer.
        mov     ecx,DTASize             ;length to copy.
        rep     movsb           ;copy data returned.
@@9:    ret
Int21hFindNextFile endp


;------------------------------------------------------------------------------
;
;Function 50 emulation.
;
Int21hSetPSP    proc    near
        mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        mov     ax,[ebp+Int_BX]
        mov     PSPSegment,ax   ;Set current PSP.
        assume ds:nothing
        ret
Int21hSetPSP    endp


;------------------------------------------------------------------------------
;
;Function 51 emulation.
;
Int21hGetPSP    proc    near
        mov     [ebp+Int_BX],fs
        ret
Int21hGetPSP    endp


;------------------------------------------------------------------------------
;
;Function 56 emulation.
;
Int21hRenameFile proc near
        mov     ds,[ebp+Int_DS]
        mov     esi,[ebp+Int_EDX]
        call    Int21hExtend_DS_ESI     ;Extend [E]SI.
        xor     al,al           ;Character to look for.
        call    Int21hStringLen ;Get length of this string.
        inc     ecx
        mov     es,fs:[EPSP_TransProt]
        xor     edi,edi
        push    ecx
        rep     movsb
        pop     edi
        ;
        mov     ds,[ebp+Int_ES]
        mov     esi,[ebp+Int_EDI]
        call    Int21hExtend_DS_ESI     ;Extend [E]SI.
        xor     al,al           ;Character to look for.
        call    Int21hStringLen ;Get length of this string.
        inc     ecx
        mov     es,fs:[EPSP_TransProt]
        push    edi
        rep     movsb
        pop     edx
        ;
        mov     edi,offset Int21Buffer
        mov     es,cs:Int21hDSeg
        mov     ax,fs:[EPSP_TransReal]
        mov     es:Real_EDX[edi],0
        mov     es:Real_EDI[edi],edx
        mov     es:Real_DS[edi],ax
        mov     es:Real_ES[edi],ax
        mov     eax,[ebp+Int_EAX]
        mov     es:Real_EAX[edi],eax
        mov     bl,21h
        sys     IntXX

; return error status, MED 03/13/96
        mov     ax,WORD PTR es:Real_EAX[edi]
        mov     w[ebp+Int_AX],ax
        DOS4GExtend w[ebp+Int_EAX+2]

        mov     ax,es:Real_Flags[edi]
        and     al,1
        call    Int21hAL2Carry  ;Set carry.

        ret
Int21hRenameFile endp


;------------------------------------------------------------------------------
;
;Function 5A emulation.
;
Int21hCreateTemp proc near
        mov     ds,[ebp+Int_DS]
        mov     esi,[ebp+Int_EDX]
        call    Int21hExtend_DS_ESI     ;Extend [E]SI.
        xor     al,al           ;Character to look for.
        call    Int21hStringLen ;Get length of this string.
        inc     ecx
        mov     es,fs:[EPSP_TransProt]
        xor     edi,edi
        rep     movsb
        mov     edi,offset Int21Buffer
        mov     es,cs:Int21hDSeg
        mov     eax,[ebp+Int_EAX]
        mov     es:Real_EAX[edi],eax
        mov     eax,[ebp+Int_ECX]
        mov     es:Real_ECX[edi],eax
        mov     es:Real_EDX[edi],0
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:Real_DS[edi],ax
        mov     bl,21h
        sys     IntXX
        mov     eax,es:Real_EAX[edi]
        mov     [ebp+Int_AX],ax
        DOS4GExtend w[ebp+Int_EAX+2]
        mov     ax,es:Real_Flags[edi]
        and     al,1
        call    Int21hAL2Carry  ;Set carry.
        or      al,al
        jnz     @@9
        mov     ds,fs:[EPSP_TransProt]
        xor     esi,esi
        xor     al,al           ;Character to look for.
        call    Int21hStringLen ;Get length of this string.
        inc     ecx
        mov     es,[ebp+Int_DS]
        mov     edi,[ebp+Int_EDX]
        call    Int21hExtend_ES_EDI     ;Extend [E]SI.
        rep     movsb
@@9:    ret
Int21hCreateTemp endp


;------------------------------------------------------------------------------
;
;Function 5E emulation.
;
Int21hMSNet     proc    near
        cmp     ax,5e00h
        jnz     Int21hNotOurs
        ;
        mov     edi,offset Int21Buffer
        mov     es,cs:Int21hDseg
        mov     eax,[ebp+Int_EAX]
        mov     es:Real_EAX[edi],eax
        mov     es:Real_EDX[edi],0
        mov     ax,fs:w[EPSP_TransReal]
        mov     es:Real_DS[edi],ax
        mov     bl,21h
        sys     IntXX           ;read pen values.
        mov     eax,es:Real_ECX[edi]
        mov     [ebp+Int_CX],ax
        DOS4GExtend w[ebp+Int_ECX+2]
        mov     eax,es:Real_EAX[edi]
        mov     [ebp+Int_AX],ax
        DOS4GExtend w[ebp+Int_EAX+2]
        mov     ax,es:Real_Flags[edi]
        and     al,1
        call    Int21hAL2Carry  ;Set carry.
        or      al,al
        jnz     @@9
        mov     ds,fs:w[EPSP_TransProt]
        xor     esi,esi
        mov     es,[ebp+Int_ES]
        mov     edi,[ebp+Int_EDX]
        call    Int21hExtend_ES_EDI     ;Extend [E]SI.
        mov     ecx,16/4
        rep     movsd           ;copy the results.
@@9:    ret
Int21hMSNet     endp


;------------------------------------------------------------------------------
;
;Function 67 emulation.
;
Int21hSetHandles proc near
;
;Set handle count with DOS.
;
        mov     es,cs:Int21hDSeg
        mov     edi,offset Int21Buffer
        mov     es:Real_EAX[edi],6700h
        mov     ax,[ebp+Int_BX]
        mov     es:Real_EBX[edi],eax
        mov     bl,21h
        sys     IntXX
        test    es:Real_Flags[edi],1
        jz      @@0
        mov     al,1
        call    Int21hAL2Carry  ;Set carry.
        mov     eax,es:Real_EAX[edi]
        mov     [ebp+Int_AX],ax
        DOS4GExtend w[ebp+Int_EAX+2]
        ret
;
;Change succeded so modify handle table selector base.
;
@@0:    mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        movzx   eax,RealPSPSegment
        shl     eax,4
        mov     ds,RealSegment
        assume ds:nothing
        movzx   edx,ds:w[PSP_HandlePtr+2+eax]
        shl     edx,4
        movzx   ebx,ds:w[PSP_HandlePtr+eax]
        add     edx,ebx
        movzx   ecx,ds:w[PSP_Handles+eax]
        mov     bx,fs:w[PSP_HandlePtr+2]
        sys     SetSelDet32
;
;Now modify all PSP handle counts.
;
        mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        mov     esi,BasePSPAddress
        mov     ds,RealSegment
        assume ds:nothing
        mov     bx,[ebp+Int_BX]
@@1:    mov     PSP_Handles[esi],bx
        mov     esi,EPSP_NextPSP[esi]
        or      esi,esi
        jnz     @@1
        ret




        if      0
        mov     bx,[ebp+Int_BX]
        cmp     bx,fs:w[PSP_Handles]    ;more or less?
        jz      @@sh0
        jnc     @@shb0
        ;
        ;Want less handles!
        ;
        mov     ax,fs
        cmp     ax,fs:w[PSP_HandlePtr+2]        ;table still in PSP?
        jz      @@sh0
        ;
        ;Current table not in PSP.
        ;
        cmp     bx,20+1         ;20 is the lower limit.
        jnc     @@shs0
        ;
        ;Reduceing to 20 handles so move the table back into the PSP.
        ;
        push    fs
        pop     es
        mov     edi,offset PSP_HandleList
        mov     ecx,20
        mov     al,-1
        rep     stosb           ;initialise the table first.
        mov     edi,offset PSP_HandleList
        lds     si,fs:d[PSP_HandlePtr]  ;point to current list.
        movzx   esi,si
        mov     ecx,20
        rep     movsb           ;copy 1st 20 entries.
        jmp     @@shs1
        ;
@@shs0: ;Still more than 20 handles so just re-size the memory.
        ;
        push    bx
        movzx   ecx,bx          ;1 byte per entry.
        mov     bx,fs:w[PSP_HandlePtr+2]
        sys     ResMem32                ;re-size the memory.
        pop     bx
        jc      @@sh0           ;not sure if this can happen.
        ;
@@shs1: ;Now update the the DOS side of things and the PSP.
        ;
        mov     ax,bx
        sub     ax,fs:w[PSP_Handles]    ;find out how many less than before.
        mov     fs:w[PSP_Handles],bx    ;set new number of handles.
        mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        push    ds
        pop     es
        sub     TotalHandles,ax ;update total count needed.
        mov     ax,TotalHandles
        assume ds:nothing
        or      ax,1
        mov     edi,offset Int21Buffer
        mov     es:Real_EAX[edi],6700h
        mov     es:Real_EBX[edi],eax
        mov     bl,21h
        sys     IntXX           ;set new value with DOS.
        jmp     @@sh0
        ;
@@shb0: ;Want more handles.
        ;
        mov     ax,bx
        sub     ax,fs:w[PSP_Handles]    ;find out how many more.
        mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        push    ds
        pop     es
        add     ax,TotalHandles ;get total count needed.
        assume ds:nothing
        or      ax,1
        mov     edi,offset Int21Buffer
        mov     es:Real_EAX[edi],6700h
        mov     es:Real_EBX[edi],eax
        mov     ecx,ebx
        mov     bl,21h
        sys     IntXX
        mov     ebx,ecx
        mov     eax,es:Real_EAX[edi]
        test    es:Real_Flags[edi],1
        jnz     @@sh0           ;no can do!
        ;
        ;We managed to set the new number with DOS, now try and get the
        ;memory needed to take care of things in protected mode.
        ;
        mov     ax,fs
        cmp     ax,fs:w[PSP_HandlePtr+2]        ;table still in PSP?
        jnz     @@shb1
        ;
        ;Current table is in the PSP still so we want a fresh block
        ;of memory and a new selector.
        ;
        movzx   ecx,bx          ;1 byte per entry.
        sys     GetMem32                ;allocate the memory.
        jc      @@shb2
        push    es
        mov     es,bx           ;point to new memory.
        xor     edi,edi
        mov     al,-1
        push    ecx
        movzx   ecx,cx
        rep     stosb           ;initialise table to nothing.
        xor     edi,edi
        push    ds
        lds     si,fs:d[PSP_HandlePtr]
        movzx   esi,si
        mov     cx,fs:w[PSP_Handles]
        movzx   ecx,cx
        rep     movsb           ;copy existing entries.
        pop     ds
        pop     ecx
        mov     fs:w[PSP_HandlePtr],0
        mov     fs:w[PSP_HandlePtr+2],es
        pop     es
        mov     ax,cx
        sub     ax,fs:w[PSP_Handles]    ;find out how many more.
        mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        add     TotalHandles,ax
        assume ds:nothing
        mov     fs:w[PSP_Handles],cx    ;set new number.
        xor     ax,ax
        clc
        jmp     @@sh0
        ;
@@shb1: ;Current table is NOT in the PSP so just do a re-size on the
        ;memory.
        ;
        movzx   ecx,bx          ;1 byte per handle.
        mov     bx,fs:w[PSP_HandlePtr+2]
        sys     ResMem32                ;try and get adjusted memory.
        jc      @@shb2
        sub     cx,fs:w[PSP_Handles]    ;get number differance.
        mov     di,fs:w[PSP_Handles]    ;get origional value.
        mov     al,-1
        push    ecx
        push    es
        movzx   edi,di
        movzx   ecx,cx
        mov     es,bx
        rep     stosb           ;initialise new entries.
        pop     es
        pop     ecx
        sub     ax,fs:w[PSP_Handles]    ;find out how many more.
        mov     ds,cs:Int21hDSeg
        assume ds:_cwMain
        add     TotalHandles,ax
        assume ds:nothing

⌨️ 快捷键说明

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