Assembly Source series of Drivesex

Source: Internet
Author: User
Tags count

This is the past DOS era of the compilation of source code, although has passed, but for the study of the assembly is still helpful, assembly language is just a basic programmer language, most people can grasp, not necessarily in-depth research.

; 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 DUP (0,1,0,1)
; Default to don't 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 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.