home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------------
- ; ISDRIVE.ASM
- ;
- ; by Leonard Zerman
- ;
- ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
- ;----------------------------------------------------------------------------
-
- PUBLIC isdrive
- EXTRN __PARINFO:FAR
- EXTRN __PARC:FAR
- EXTRN __RETL:FAR
-
- ;----------------------------------------------------------------------------
- vect_num1 equ 24h ; the int to redirect
- dos_int equ 21h ;
- toupper equ 0DFh ; force to upper case
- ;----------------------------------------------------------------------------
- isdrive_text segment byte public 'CODE'
- assume cs:isdrive_text
- isdrive proc far ;
- ;----------------------------------------------------------------------------
- start: jmp begin ;
- ;
- old_v_1 dd ? ; storage for old int vector
- errorflag db 0 ;
- parm_passed db 0 ;
- sector_buffer db 512 dup (0) ;
- ;----------------------------------------------------------------------------
- crit_handler: mov cs:errorflag,1 ;
- xor ax,ax ;
- iret ;
- ;----------------------------------------------------------------------------
- begin: push bp ;
- mov bp,sp ;
- xor ax,ax ;
- mov cs:errorflag, al ;
- mov cs:parm_passed, al ;
- push ax ;
- call __PARINFO ; check for 1 parm
- add sp,2 ;
- cmp ax,1 ;
- je check4parm ;
- jmp getvect ;
- check4parm: mov ax,1 ;
- push ax
- call __PARINFO ; check for character
- add sp,2 ;
- cmp ax,1 ;
- je set_parm ;
- mov cs:errorflag,1 ;
- jmp exit ;
- set_parm: mov cs:parm_passed,1 ;
- getvect: push ds ;
- mov ah,35h ; get vector address
- mov al,vect_num1 ;
- int dos_int ;
- mov word ptr old_v_1,bx ; save old int address
- mov word ptr old_v_1[2],es ;
- ;----------------------------------------------------------------------------
- mov ah,25h ; set new pointer
- mov al,vect_num1 ;
- mov dx,cs ;
- mov ds,dx ;
- mov dx,offset crit_handler ; set pointer IP (CS & DS same)
- int dos_int ;
- pop ds ;
- ;----------------------------------------------------------------------------
- mov al, cs:parm_passed ;
- or al, al ;
- jz set_default ;
- push es ;
- push bx ;
- mov ax,1 ;
- push ax ;
- call __PARC ;
- add sp,2 ;
- mov es,dx ;
- mov bx,ax ;
- mov dl,byte ptr es:[bx] ; Load drive letter
- pop bx ;
- pop es ;
- and dl,toupper ;
- sub dl,'A' ;
- inc dl ;
- cmp dl, 2 ; drive B:
- jle bios_method ; jmp A: or B:
- ; je bios_method ;
- jmp get_info ;
- set_default: xor dl,dl ;
- get_info: push ds ;
- push bx ;
- mov ah,36h ;
- int dos_int ;
- cmp ax, 0FFFFh ;
- jne resetvec ;
- mov cs:errorflag, 1 ;
- jmp resetvec ;
- ;----------------------------------------------------------------------------
- bios_method: push ds ;
- push bx ;
- mov ah, 02h ; read floppy
- xor ch, ch ; track 0
- mov cl, 1 ; sector 1
- mov al, cl ; 1 sector
- xor dh, dh ; head 0, dl contains drive
- dec dl ; drive a = 0, b = 1
- mov bx, offset cs:sector_buffer
- push es ;
- push cs ;
- pop es ;
- int 13h ; rom interrupt
- pop es ;
- jnc resetvec ; no error
- mov cs:errorflag, 1 ; error occured
- xor ax, ax ; reset disk
- int 13h ;
- ;----------------------------------------------------------------------------
- resetvec: mov ah,25h ;
- mov al,vect_num1 ;
- mov dx, word ptr old_v_1 ;
- mov ds, word ptr old_v_1[2];
- int dos_int ;
- ;----------------------------------------------------------------------------
- pop bx ;
- pop ds ;
- exit: xor ah,ah ;
- mov al,cs:errorflag ;
- xor ax,1 ;
- push ax ;
- call __RETL ;
- add sp,2 ;
- pop bp ;
- retf ;
- isdrive endp ;
- isdrive_text ends ;
- end
- ;----------------------------------------------------------------------------
-