home *** CD-ROM | disk | FTP | other *** search
- TITLE VOLUME 7-19-88 [7-19-88]
-
- ;from SIMTEL20's PD:<MSDOS.DSKUTL>VOLUME.COM
- ;disassembled with ASMGEN and thoroughly tweaked.
-
- ; v1.1, Jul 88
- ; - Now returns ERRORLEVEL, terminating via service 4CH.
- ; - If no command line parms, gives usage help msg.
- ; - one working buffer overwrites usage text to save bytes.
- ;
- ;David Kirschbaum, Toad Hall
-
- LF EQU 0AH
- CR EQU 0DH
- ;
- CodeSeg SEGMENT
- ASSUME DS:CodeSeg, SS:CodeSeg ,CS:CodeSeg ,ES:CodeSeg
-
- ORG 100H
-
- Volume proc near
- MOV AH,30H ;get DOS version
- INT 21H
- or al,al ;1.0?
- JNZ Skip1 ;nope, ok
-
- MOV DX,OFFSET dosmsg ;'DOS 2.0 or above'
- inc al ;fake ERRORLEVEL 1
- jmp short MsgExit ;display msg, terminate
-
- Skip1: CLD ;insure fwd
- CMP BYTE PTR DS:80H,0 ;anything on cmd line?
- jne Do_CmdLine ;yep, go process it
-
- mov dx,offset usagemsg ;show usage
- xor ax,ax ;return ERRORLEVEL=0
- jmp short MsgExit ;display msg, terminate
-
- Do_CmdLine:
- ;Build an FCB area, properly initialized, by copying the good one
- ;(starting at drive) down over our usage text.
- mov si,offset drive ;gonna initialize some working space
- mov di,offset drive_24B ;overwrite usage text
- mov cx,BUFLEN ;a constant
- rep movsb ;initialize it (over old text)
-
- MOV SI,81H ;point to PSP cmd line 1st char
- MOV CX,0AH ;up to 10 chars
- ScanCmd:
- LODSB ;snarf PSP cmd line char
- CMP AL,20H ;' '
- LOOPZ ScanCmd ;gobble leading spaces
-
- DEC SI ;back up to first REAL cmd line char
- ;(oughtta be drive name)
- CMP BYTE PTR [SI+1],3AH ;':' drive name separator?
- JNZ NoDrive ; nope, use current drive
-
- MOV AL,[SI] ;get actual drive char
- CALL UpperCase ;insure uppercase
- SUB AL,40H ;deasciify
- MOV drive,AL ;save it
- inc si ;TH bump past 'A:'
- inc si ;TH (faster than add si,2)
- NoDrive:
- PUSH SI ;save cmd line ptr
- CALL FindFile ;try to find the file
- POP SI
- CMP BYTE PTR [SI],CR ;done with cmd line? (just drive?)
- JZ Endit ;yep, terminate, AL=ERRORLEVEL=0
-
- MOV DI,OFFSET buff ;gotta scan our working buffer
- MOV CX,0BH ;11 chars
- ScanBuff_146:
- LODSB ;snarf buff char
- CMP AL,CR ;CR means end of cmd
- JZ ScanDone ;done
- CALL UpperCase ;insure uppercase
- STOSB ;stuff back in buff
- LOOP ScanBuff_146 ;do them all
- ScanDone:
- JCXZ NoPad ;did all 11 chars
- MOV AL,20H ;' ' ;pad with spaces
- REPZ STOSB
- NoPad: MOV AL,drive ;get drive val back
- MOV drive_24B,AL ;stuff it here
- MOV AH,16H ;create file
- MOV DX,OFFSET dta_244 ;this one
- INT 21H
- push ax ;save results
-
- MOV DX,OFFSET dta_244
- MOV AH,10H ;close file
- INT 21H
-
- pop ax ;restore results
- CMP AL,0FFH ;failed?
- jne Endit ; nope, went ok
-
- MOV DX,OFFSET failmsg ;'can't create vol name'
-
- MsgExit:
- ;expects msg offset in DX
- push ax ;save any error value in AL
- mov ah,9 ;display string
- int 21H
- mov dx,offset crlf ;terminating CR/LF
- int 21H ;display it
- pop ax ;restore any error in AL
-
- Endit:
- mov ah,4CH ;TH terminate
- int 21H
- Volume endp
-
-
- FindFile proc near
- MOV DX,OFFSET dta_244 ;our DTA
- MOV AH,1AH ;set DTA
- INT 21H
- MOV DX,OFFSET namebuff ;file name to find
- MOV AH,11H ;find first matching file
- INT 21H
- CMP AL,0FFH ;find it?
- JZ NotFound ; nope, doesn't exist
- MOV DX,OFFSET dta_244 ;file DTA
- MOV AH,13H ;delete file
- INT 21H
- NotFound:
- xor ax,ax ;TH clear any AL error
- RET
- FindFile endp
-
-
- UpperCase proc near
- CMP AL,'z'
- JA NoUpper ;above
- CMP AL,'a'
- JB NoUpper ;below
- AND AL,5FH ;uppercase it
- NoUpper:
- RET
- UpperCase endp
-
- dosmsg db 'Requires MS-DOS V2.00 or higher',7,'$'
- failmsg db "Can't create volume name$",7,'$'
- crlf db CR,LF,'$'
-
- namebuff DB 0FFH,5 DUP(0),8
-
- drive DB 0
- db 0BH DUP(3FH)
- DB 16H DUP(0)
- BUFLEN = $-drive ;remember how long this structure is
-
- dta_244 DB 0FFH,5 DUP(0),8
-
- drive_24B label byte ;actually using text space below
- buff = drive_24B+1 ;a byte later
-
- usagemsg db 'VOLUME - rename a drive',CR,LF
- db 'Usage: VOLUME [drive:][volname]',CR,LF
- db 'where [drive:] is a legal system drive',CR,LF
- db '(A, B, whatever, default: current drive)',CR,LF
- db 'and [volname] is a string of characters (no leading spaces)'
- db CR,LF
- db "No [volname] entry will clear target drive's volume name.$"
-
- CodeSeg ENDS
- END Volume