home *** CD-ROM | disk | FTP | other *** search
- ;----------------------------------------------------------------------
- ; Check the volume label on a disk
- ;----------------------------------------------------------------------
- ; Released to public domain 12-89 by Wayne Mingee
- ;
- ; FORMAT: chkvolid [d:] 'volid'
- ;
- ; volid must be enclosed in ' or "
- ; if no [d:] given use default drive
- ; if no 'volid' given then display volume label
- ;
- ; RETURNS ERRORLEVEL
- ; 1 = wrong vol id
- ; 2 = disk has no volume label
- ; 3-239 = disk status
- ; 240-255 = disk type
- ;------------------------------------------------------------------------------
- cseg segment para public 'code'
- assume cs:cseg, ds:cseg, es:cseg, ss:cseg
-
- dosfunc equ 21h
- terminate equ 4ch
-
- org 5ch
- data0 db ?
-
- org 80h
- cmdlen db ?
- cmdline db 128 dup (?)
-
- org 100h
- begin: jmp start
-
- filename db ??filename,' '
- db ??date
- db ' v1.1'
- sdr db 'd:*.*',0
- cmdsave db 64 dup (0)
- errcode db 2
- dskstat db 0
- ;----------------------------------------------------------------------
- Start proc near
- ;------------------------------------------------------------------------------
- cld
- ; go see if drive available
- call chkdrv
- ; if no disk errors continue else return code
- cmp dskstat, 0
- je norm
- cmp dskstat, 240
- ja norm
- mov al, dskstat
- jmp quit
- ; see drive given
- norm: lea dx, sdr+2
- mov cl, cmdlen
- xor ch, ch
- jcxz gotdr
- inc cx
- mov al, ' '
- lea di, cmdline
- repe scas cmdline ;skip the blanks
- je gotdr
- cmp byte ptr [di], ':'
- jne nodr ;no drive given
- mov ah, byte ptr [di-1]
- mov sdr, ah
- lea dx, sdr
- ; now look for volid
- inc di
- dec cx
- repe scas cmdline
- je gotdr
- nodr: push di
- pop si
- dec di
- cmp byte ptr[di], '"' ;volid must be in ''or ""
- je usesg
- cmp byte ptr[di], "'"
- jne gotdr
- ; search for trailing ' "
- usesg: mov al, byte ptr [di]
- add di, cx
- std
- repne scasb
- jne gotdr
- cld
- lea di, cmdsave
- rep movsb
- mov errcode, 1
-
- gotdr: ; get volume label
- mov ax, 4e00h
- mov cx, 8
- int DosFunc
- jc error
- ; ; get DTA address
- mov ax, 2f00h
- int DosFunc
- assume es:nothing
- jc error
- ; setup for compare
- push bx
- pop di
- add di, 1eh
- cmp errcode, 2
- je displayid
- lea si, cmdsave
- mov cx, 13
- ; when we find a period bump past it since cmnd line won't have one
- ; DOS will compress spaces before '.' so bump up 8 in cmd line
- compn: cmp byte ptr [di], '.'
- jne cont
- lea si, cmdsave+8
- jmp incdi
- ; capitalize and compare
- cont: lodsb
- cmp al, 'a'
- jl docomp
- cmp al, 'z'
- jg docomp
- and al, 5fh
- docomp: cmp al, byte ptr [di]
- jne error
- cmp al, 0 ;end of line - all good
- je stop
- incdi: inc di
- loop compn
-
- stop: mov errcode, 0
-
- error: mov al, errcode
- quit: mov ah, Terminate
- int DosFunc
- assume es:@curseg
-
- ; no cmd line volid display volume label
- displayid: mov cx, 12
- displaylp: mov ah, 6
- mov dl, byte ptr [di]
- cmp dl, '.'
- jne send
- mov dl, ' '
- cmp cx, 4
- jg skip
- inc di
- jne displaylp
- send: cmp dl, 0
- je tstd
- inc di
- skip: int DosFunc
- loop displaylp
- tstd: mov al, dskstat
- jmp quit
-
- start endp
- ; see if drive ready and disk formated
- chkdrv proc near
- mov dl, data0
- xor dh, dh
- dec dl
- jns jmp1
- mov ah, 19h
- int dosfunc
- mov dl, al
- jmp1:
- push dx
- int 11h
- test al, 01h
- jz jmp3
- mov cl, 6
- shr al, cl
- and al, 03h
- jnz jmp1a
- mov al, 01h
- jmp1a: cmp al, dl
- jb jmp3
- ; FD's only
- testfd:
- mov ah, 04h
- mov al, 01h
- mov ch, 00h
- mov cl, 01h
- int 13h ;verify disk sectors
- jnb jmp3
- add ah, 2
- cmp dskstat, 0
- mov dskstat, ah
- je testfd
- mov ah, 00h
- int 13h ;reset disk system
- pop dx
- jmp jmp2
- jmp3: ;HD's and ok FD's get type
- pop dx
- inc dl
- mov ah, 1ch
- xor dh, dh
- push ds
- int dosfunc
- mov al, byte ptr [bx]
- pop ds
- mov dskstat, al
- jmp2: ret
- chkdrv endp
-
- cseg ends
- end begin