汇编源码系列之drivesex

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究.......

; DRIVESEX.ASM - Drive existence detection   July 6th, 1994
; Code by    : Lee Hamel (hamell@cs.pdx.edu)
; Partial credit: Paul Schlyter
;
; Goes through drives A-Z and determines if they:
; 1) Exist
; 2) Are removable or fixed
; 3) Are local, remote, or shared
; 4) Are a floppy, hard, RAM, subst, or CD-ROM drive
;
; Callable from C as: void Drives_Exist(void);
.model small
.286
DRIVEEXIST   EQU   1
REMOVEDRV    EQU   0
FIXEDDRV    EQU   1
LOCALDRV    EQU   0
REMOTEDRV    EQU   1
SHAREDRV    EQU   2
FLOPPY     EQU   0
HARD      EQU   1
RAM       EQU   2
SUBST      EQU   3
CDROM      EQU   4
.data
PUBLIC _drives
    _drives     db   26 dup(0,1,0,1)
    ; default to not exist, fixed, local, hard drive
.code
            PUBLIC _Drives_Exist
_Drives_Exist      PROC  NEAR
        pusha
        push  es
        mov   ah,19h
        int   21h       ; get start drive
        push  ax       ; save start drive
        mov   ax,40h
        mov   es,ax
        mov   bh,es:[10h]   ; 40:10h is # of floppies-1
        shr   bh,6
        inc   bh       ; # of actual floppy drives
        mov   bl,1
        mov   di,offset _drives
nextchkfloppy: mov   ax,4409h    ; check if drive exists
        int   21h
        jc   nextsetfloppy
        test  dh,10000000b  ; check if SUBST drive
        jz   chkfloppy
        dec   bh       ; dec actual drive count
        mov   byte ptr [di+3],SUBST
setfloppyexist: mov   byte ptr [di],DRIVEEXIST
        jmp   nextsetfloppy
chkfloppy:   dec   bh       ; dec actual drive count
        js   nextsetfloppy
        mov   byte ptr [di+1],REMOVEDRV
        mov   byte ptr [di+3],FLOPPY
        jmp   setfloppyexist
nextsetfloppy: add   di,4
        inc   bl
        cmp   bl,2      ; if B then jump back
        je   nextchkfloppy
        mov   ch,24      ; loop 24 times (drives C - Z)
        mov   cl,3      ; start at C:
drivechkloop:  mov   ax,4409h    ; check if drive exists
        mov   bl,cl      ; set drive letter
        int   21h       ; 0 = default, 1 = A:, etc.
        jc   nextsetdrv
        mov   byte ptr [di],DRIVEEXIST
        mov   ax,4408h    ; check if removable
        int   21h
        mov   byte ptr [di+1],al   ; set REMOVABLE or FIXED
        mov   bx,dx
        mov   dl,dh
        shr   dl,7
        and   dh,00010000b
        shr   dh,4
        mov   byte ptr [di+2],dh   ; set REMOTE or LOCAL
        or   dl,dl          ; if not SUBST, then jump
        jz   chkremote
        mov   byte ptr [di+3],SUBST
        jmp   nextsetdrv
chkremote:   cmp   dh,REMOTEDRV  ; if REMOTE, then check for CD ROM
        je   chkcdrom
        test  bh,00000010b  ; sharable?
        jz   drivenoshare
        mov   byte ptr [di+2],SHAREDRV
drivenoshare:  test  bl,00000010b  ; RAM drive?
        jnz   nextsetdrv
        mov   byte ptr [di+3],RAM
        jmp   nextsetdrv
chkcdrom:    push  cx
        mov   ax,1500h
        xor   bx,bx
        int   2fh
        pop   cx
        or   bx,bx      ; MSCDEX driver found?
        jz   nextsetdrv   ; if not, jump to next drive setup
        mov   ax,150bh
        dec   cl       ; 0=A:, etc.
        int   2fh
        inc   cl
        or   ax,ax
        jz   nextsetdrv   ; drive supported by MSCDEX?
        mov   byte ptr [di+3],CDROM
nextsetdrv:   add   di,4
        inc   cl
        dec   ch
        jnz   drivechkloop
        pop   dx
        mov   ah,0eh
        int   21h       ; reset start drive
        pop   es
        popa
        ret
_Drives_Exist      ENDP
            END

时间: 2024-11-01 03:26:59

汇编源码系列之drivesex的相关文章

汇编源码系列之clear

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name clear page 55,132 title 'CLEAR --- control PC display';; CLEAR Utility to clear display; and set character attributes;; Ray Duncan, Uncopyright (u) August 1983; This

汇编源码系列之clock

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... CGROUP GROUP VECTOR,CODESEGVECTOR SEGMENT AT 0H DB 6CH DUP(?) ;FILLERTIME_LO DW ? ;DOS TIMETIME_HI DW ? ;DOS TIMEVEC_IP DW ;CLOCK UPDATE VECTOR IPVEC_CS DW ;CLOCK UPDATE

汇编源码系列之charop

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... title MSDOS 2.00 Function Library for Lattice Csubttl -;;;;FUNCTION: Sets and returns switch char-;; acter and device availability.;;;;;;CALL:;;;; ret= _charop(al,dl);; i

汇编源码系列之clean

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name clean page 55,132 title 'CLEAN --- Filter text file';; CLEAN --- a utility to filter text files.; This program removes all control codes except; for line feeds, carr

汇编源码系列之cleanf

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... name cleanf page 55,132 title 'CLEANF - Filter text file';; CLEANF - a DOS 2.0 filter for word processing document files.;; CLEAN.ASM Originally written by Ray Duncan; Co

汇编源码系列之burnout

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... COMMENT * Demo (and semi-useful) program to read/set burnout device parameters. Usage: burnout [ticks] [C+-] [V+-] [H+-] Parameters can be separated by almost anything. W

汇编源码系列之calc

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... PAGE ,132 TITLE CALCCGROUP GROUP CODESEGCODESEG SEGMENT PARA PUBLIC 'CODE' ASSUME CS:CGROUP,DS:CGROUP,ES:CGROUP PUBLIC CALC ORG 100HCALC PROC FAR JMP START;--------------

汇编源码系列之char

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... ctable segment para public 'DATA db 9 dup(' ') db 9,10,' ',12,13 db 13 dup(' ') db 27 db 4 dup(' ') db ' !"#$%&',39,'()*+,-./0123456789:;<=>?@' db 'ABCDEFGHIJKL

汇编源码系列之brk

这个都是过去DOS时代的汇编源码,虽然已经过去了,但是对于学习汇编还是有帮助的,汇编语言只是程序员一门基础语言,大多人掌握即可,不一定要深入研究....... PGROUP Group PROGDGROUP Group DATADATA Segment Public 'DATA'public brkflagbrkflag DW 0DATA endsPROG Segment Para Public 'PROG'public TrapBreaassume cs:PGROUP,DS:DGROUPTra