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

📄 dos.asm

📁 [随书类]Dos6.0源代码
💻 ASM
📖 第 1 页 / 共 3 页
字号:
            stosb
GVNoVol:
            pop     ds
cEnd

if 0
;*--------------------------------------------------------------------------*
;*                                                                          *
;*  GetFileAttributes() -                                                   *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc GetFileAttributes, <FAR, PUBLIC>

ParmD lpszPath

cBegin
            push    ds                  ; Preserve DS
            lds     dx,lpszPath         ; DS:DI = lpszPath
            mov     ax,4300h            ; Get File Attributes
            int     21h
            jc      GFAErr
            mov     ax,cx               ; AX = attribute
            jmps    GFAExit             ; Return attribute
GFAErr:     mov     ah,80h              ; Return negative error code
GFAExit:
            pop     ds                  ; Restore DS
cEnd
endif

;*--------------------------------------------------------------------------*
;*                                                                          *
;*  DosMemory()                                                             *
;*                                                                          *
;*  RETURNS     ax = Max DOS memory dx = Max XMS                            *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc DosMemory, <FAR, PUBLIC>, <si>
cBegin
        mov     dx,-1       ; just incase it fails
        mov     ah,08h      ; Get XMS Memory Free
        call    XmsCall     ; call XMS driver, Total memory in DX
        int     12h         ; Total base memory in AX
cEnd


;*--------------------------------------------------------------------------*
;*                                                                          *
;*  ExtendedMemory()                                                        *
;*                                                                          *
;*  find out how much mem is free above 1M                                  *
;*                                                                          *
;*  RETURNS     ax = Extended memory free                                   *
;*                                                                          *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc ExtendedMemory, <FAR, PUBLIC>, <si>
cBegin
        mov     ah, 88h         ; now ask int 15 how much he knows about
        int     15h
cEnd



;*--------------------------------------------------------------------------*
;*                                                                          *
;*  DosVersion()                                                            *
;*                                                                          *
;*  RETURNS     ax = DOS version                                            *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc DosVersion, <FAR, PUBLIC, NODATA>, <si>
cBegin
        mov     ax,3000h
        int     21h
cEnd

;*--------------------------------------------------------------------------*
;*                                                                          *
;*  Reboot()                                                                *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc Reboot, <FAR, PUBLIC, NODATA>, <>
cBegin
        ;
        ;   disable memory test
        ;
        mov     ax,40h
        mov     ds,ax
        mov     word ptr ds:[72h],1234h
        ;
        ;   jmp FFFF:0000
        ;
        mov     ax,0FFFFh
        push    ax
        xor     ax,ax
        push    ax
        retf
cEnd nogen

;
;   DosGetEnv
;
;   returns a FAR pointer to the current environment block
;
cProc DosGetEnv,<FAR,PUBLIC>,<si,di>
cBegin
        mov ah,62H
        int 21h                 ; get PSP seg in BX
        mov es,bx
        mov dx,es:[002CH]       ; get environment seg
        mov ax,0                ; DS:AX --> env block
cEnd

;*--------------------------------------------------------------------------*
;*                                                                          *
;*  XmsVersion()                                                            *
;*                                                                          *
;*  RETURNS     AX = (LOWORD) XMS spec version				    *
;*              DX = (HIWORD) driver internal version			    *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc XmsVersion, <FAR, PUBLIC>
        LocalD  xms
cBegin
        mov     ah,0
        call    XmsCall
        mov     dx,bx
cEnd


; BOOL XmsInstalled(void);

cProc XmsInstalled, <FAR, PUBLIC>
cBegin
        mov     ax,4300h
	int	2Fh
	cmp	al,80h
	jne	no_xms
	mov	ax,1
	jmp	xms_done
no_xms:
        xor	ax,ax
xms_done:
cEnd


;*--------------------------------------------------------------------------*
;*                                                                          *
;*  XmsCall()                                                               *
;*                                                                          *
;*--------------------------------------------------------------------------*

cProc XmsCall, <NEAR>
        LocalD  xms
cBegin
        mov     cx,ax
        mov     ax,4300h    ; Hello XMS?
        int     2fh
        cmp     al,80h
        mov	ax,0	    ; don't set the flags
        jnz     xc_exit
        mov     ax,4310h    ; Get XMS function pointer
        int     2fh
        mov     ax,cx       ; Get XMS function number back
        mov     xms.sel,es
        mov     xms.off,bx
        call    [xms]
xc_exit:
cEnd

; constants used by _get_ext

CMOS_PORT       equ     70H
CMOS_DATA       equ     71H
CMOS_REG_D2     equ     1AH
CMOS_EXT_STF    equ     1718H



;***************************************************************************
; Get extended memory amount.
;---------------------------------------------------------------------------

cProc  get_ext, <FAR, PUBLIC>
cBegin

       MOV        AX, CMOS_EXT_STF
       CALL       CMOS_READ
       XCHG       AL, AH
       CALL       CMOS_READ
  
cEnd   get_ext



;***************************************************************************
; very similar to IBM AT Technical Reference BIOS listing
; determine total extended memory by looking at the CMOS RAM.
;---------------------------------------------------------------------------

CMOS_POPF       PROC NEAR
       IRET
CMOS_POPF       ENDP

CMOS_READ       PROC NEAR
       PUSHF
       ROL      AL, 1
       STC
       RCR      AL, 1
       CLI
       OUT      CMOS_PORT, AL
       NOP

       IN       AL, CMOS_DATA
       PUSH     AX
       MOV      AL, CMOS_REG_D2
       RCR      AL, 1
       OUT      CMOS_PORT, AL
       POP      AX
       PUSH     CS
       CALL     CMOS_POPF
       RET

CMOS_READ       ENDP

;* BOOL PASCAL fnGetRamDriveVersion(char *szVerString);
;*
;* Function will look for and return the presence of ramdrive. If a ramdrive
;* is found it's version string will be returned in the char buffer provided
;* as a formal argument.
;*
;* ENTRY: szVerString - pointer to buffer of sufficent size to hold the
;*                      ramdrive version string. (8 chars).
;*
;* EXIT: Bool as to the presence of a ramdrive.
;*
;*
cProc fnGetRamDriveVersion, <FAR, PUBLIC>, <SI, DI, BX, DX>
   ParmD       szVerString
   LocalV      FixedDisks,   52d
   LocalV      ReadBuf,      512d
   LocalW      Cnt
cBegin

        lea   ax,FixedDisks
        cCall GetFixedDisks,<ax>
        or    ax,ax
        jz    No_Ramdrive
        mov   Cnt,ax                ; Number of disks to check.
        mov   ax,ss                 ; DS = SS for this code.
        mov   ds,ax
        lea   si,FixedDisks

Check_Next_Drv:
        mov   ax,[si]
        mov   cx,1
        lea   bx,ReadBuf
        xor   dx,dx
        push  si
        push  bp
        int   25h                   ; This call will trash SI and BP @!#
        inc   sp                    ; Fix up stack, this call leaves flags.
        inc   sp
        pop   bp
        pop   si
        jc    Next_Drive
        cmp   [bx+2],5290h
        jne   Next_Drive
        cmp   [bx+4],5644h
        je    RamDrive_Found

Next_Drive:
        dec   Cnt
        inc   si
        inc   si
        or    Cnt,0
        jnz   Check_Next_Drv

No_Ramdrive:
        xor   ax,ax
        lds   di,szVerString
        mov   byte ptr ds:[si],0
        jmp   short RD_Done

RamDrive_Found:
        lea   si,ReadBuf
        add   si,3                  ; Increment pointer past near jump.
        les   di,szVerString
        mov   cx,8
        cld
        rep   movsb
        mov   byte ptr es:[di],0    ; Null terminate string.
        mov   ax,1

RD_Done:

cEnd

;****************************************************************************
;
; unsigned fnGetSmartDrvVersion(void);
;
; This function will check to see if smartdrv is installed. If it is found
; that SD is installed we will return it's version number as an unsigned
; int.
;
; ENTRY: None.
;
; EXIT : Returns carry set if SD is not present. If carry clear, AX will
;        contain the Smartdrv version number.
;
; Thanks AAR.
;
;****************************************************************************

cProc fnGetSmartDrvVersion, <FAR, PUBLIC>, <SI, DI, BX, DX>
cBegin

        mov  dx,offset DGROUP:SMRTDRVName ; DS:DX pointer to smartdrv name
        mov  ax,3D02h                     ; Q:func is smartdrv installed ?
        int  21h                          ;   Y: continue.
        jc   short NoSmartShrink          ;   N: No memory steal possible.
        mov  bx,ax                        ; move SD handle to BX for next call

        mov  ax,4400h                     ; IOCTL get device information.
        int  21h                      
        jc   short NoSmartShrinkCls       ; Carry indicates call unsuccesful
        test dx,0080h                     ; Test if clock device.
        jz   short NoSmartShrinkCls       ; if not, we can't steal memory.
        test dx,4000h                     ; Are IOCTL's 02h and 03h supported
        jz   short NoSmartShrinkCls       ; if not we cannot steal memory.
        mov  dx,offset DGROUP:SMRTDRVInfo ; Now, make call to get SD info.
        mov  cx,SIZE SD_IOCTL_Read
        mov  ax,4402h                     ; Read control data from SD.
        int  21h
        jc   short NoSmartShrinkCls       ; Carry indicates call unsuccesful
        cmp  ax,cx                        ; If ax != cx we did not get the
        jne  short NoSmartShrinkCls       ; number of bytes we requested !
        mov  dx,offset DGROUP:SMRTDRVInfo ; DX may be trashed after last call.
        mov  si,dx                        ; si = index into SD_IR struc.
        mov  al,[si.SD_IR_Minor_Ver]      ; Save SD version in ax.
        mov  ah,[si.SD_IR_Major_Ver]
        push ax                           ; Save AX.
        mov  ax,3E00h                     ; Close device, handle in BX.
        int  21h                          ; Call DOS
        pop  ax                           ; restore AX.
        clc
        jmp  short ok_to_steal            ; Ax contains Amt avail to steal.

NoSmartShrinkCls:
        mov  ax,3E00h                     ; Close device, handle in BX.
        int  21h                          ; Call DOS

NoSmartShrink:
        xor  ax,ax                        ; return AX = 0.
        stc                               ; Set carry to indicate no success.

ok_to_steal:

cEnd

endif

sEnd CodeSeg

end

⌨️ 快捷键说明

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