; VOL version 2.0 ; ; History: ; 06-12-86 Re-written from SLR Z80 to 8080 ASM. ; Included more editing of the input line. ; Allowed for format of filename to be used with MCAT. ; ; VOL-2 is a CP/M utility that will allow you to create a volume ; label on your disks. This volume label may be used to identify ; the contents of the disk. It also allows you to label your disks ; for use with file catalog programs. ; ; Syntax: [d:][ser][volume label] ; [*] ; [?] ; ; This program was taken from VOL.MAC, by Mike Levy, which was written ; in Z80 assembly language (Originally in 'C', but it was too slow), ; and compiled with the SLR Z80 assembler. Because I don't have the ; SLR Z80 assembler, this version is written in 8080 ASM code. ; ; B.Duerr (GEnie address) ; FALSE EQU 0 TRUE EQU NOT FALSE ORG 100H ; ; Start of program -- Set up stack, display signon message, parse the ; command line for specified volume information ; VOL: JMP START ; Bypass constants MAXDRV: DB 2 ; Maximum number of drives in computer DFTUSR: DB 0 ; User area for Volume Label Record ; START: LXI H,0 DAD SP ; Get CCP stack SHLD STACK ; Save it for exit LXI SP,STACK ; Setup local stack LXI D,SIGNON ; Display program name, version, and date CALL MESSAGE MVI C,RTNCD ; Get current drive CALL BDOS STA CDISK ; Save current drive INR A ; FCB drive is one relative STA FCB ; Save drive in FCB as default drive MVI E,0FFH MVI C,SETUSR ; Get current user CALL BDOS STA CUSER ; Save current user ; ; Initialize counters so the program may be entered with "GO" ; XRA A STA ALLFLG ; Show all drives flag STA NEWVOL ; Write new volume flag ; LDA DFTUSR ; Set user area to the default value MOV E,A MVI C,SETUSR ; SETUSR BDOS function CALL BDOS ; LDA CTAIL ; Parse the command tail ORA A JZ CURDRV ; If no command tail show this drive's volume ; CPI 4 ; If command tail > 4 then write new volume JC NODES STA NEWVOL ; Set the write new volume flag ; ; Scan the command tail for the first non-blank character ; NODES: LXI H,CTAIL+1 ; Get the desired the drive NODES1: INX H MOV A,M ORA A ; End of string? JZ CURDRV CPI ' ' ; Blank? JZ NODES1 CPI '?' ; Does the guy just want some help? JZ HELP ; Yes ; CPI '*' ; Show volumes of all drives? JNZ PARSE ; No STA ALLFLG ; Set flag MVI A,1 ; Set drive to start at "A" STA FCB INX H JMP CURDRV ; Go process this volume ; PARSE: MOV C,A ; Save the character INX H ; Point to next character MOV A,M ; Get it in CPI ':' ; Is it a colon DCX H ; Get back to start of string JNZ CURDRV ; No drive specified MOV A,C ; Get back the saved drive spec SUI 'A'-1 ; Adjust FCB drive address STA FCB INX H ; Point past drive spec INX H ; CURDRV: XRA A STA FCB+32 ; Address of FCB tale LDA NEWVOL ORA A ; Are we writing a new Volume Label Record? JZ READF ; No, go read the file ; ; Write the Volume Label Record, after check delete blank characters. ; WRITF: MOV A,M ; Get a character in A ORA A ; End of line? JZ QUIT ; Yes, quit CPI ' ' ; Is it blank? JNZ WRITF0 ; No, go process it INX H ; Point to next character JMP WRITF ; Loop till done ; WRITF0: LXI D,CTAIL ; Address of output buffer MVI B,128 ; Maximum of 128 characters WRITF1: MOV A,M ; Get a character in memory ORA A ; End of string JZ WRITF2 ; Yes, go pad record STAX D ; Move to buffer INX D ; Point to next character in buffer INX H ; Point to next character in string JMP WRITF1 ; Loop till done ; WRITF2: XCHG ; Get output buffer address in WRITF3: MVI M,EOF ; Pad the file with hex 1A INX H ; Point to next character DCR B ; One less character to go JNZ WRITF3 ; Loop till done ; MVI A,' ' ; Set default extension to spaces STA FCBEXT STA FCBEXT+1 STA FCBEXT+2 ; LDA CTAIL+3 CPI ' ' ; Is the 4th character of vol a space JNZ WRITF4 ; No, first 3 characters can't be serial LDA CTAIL ; Move first 3 characters to FCB ext STA FCBEXT LDA CTAIL+1 STA FCBEXT+1 LDA CTAIL+2 STA FCBEXT+2 ; WRITF4: LXI D,FCB ; Address of output FCB MVI C,DELETE ; BDOS DELETE function CALL BDOS ; LXI D,FCB MVI C,MAKE ; BDOS MAKE function CALL BDOS ; INR A ; Did the file open? JZ NONEWM ; LXI D,CTAIL ; Address of buffer MVI C,SETDMA ; BDOS SETDMA function CALL BDOS ; LXI D,FCB MVI C,WRITE ; BDOS WRITE function CALL BDOS ORA A ; Did the file get written? JNZ NONEWM ; LXI D,FCB MVI C,CLOSE ; BDOS CLOSE function CALL BDOS ; LXI D,YESNEW ; Tell him volume label record created CALL MESSAGE ; JMP QUIT ; ; Read the Volume Label Record and display to the Console ; READF: LDA FCB ; Show which drive ADI 'A'-1 ; Convert to ASCII STA DRIVE ; LXI D,VOLHDR ; Start of message CALL MESSAGE ; MVI A,'?' ; Make the FCB ext "???" LXI H,FCBEXT MOV M,A INX H MOV M,A INX H MOV M,A ; LXI D,FCB MVI C,OPEN ; BDOS OPEN function CALL BDOS INR A ; Is file opened ok? JZ NOVOL ; No, display message and go to next drive ; LXI D,CTAIL ; Set the Command Tail as input buffer MVI C,SETDMA ; BDOS SETDMA function CALL BDOS ; LXI D,FCB ; Input FCB MVI C,READ ; BDOS READ function CALL BDOS ORA A ; Is file read ok? JNZ NOVOL ; No, display message and go to next drive ; LXI D,FCB ; Input FCB MVI C,CLOSE ; BDOS CLOSE function CALL BDOS ; LXI H,CTAIL ; Get start of the buffer MVI B,128 ; Maximum of 128 characters MVI A,EOF ; Look for the first end of file character READF1: CMP M JZ READF2 ; Found end of message INX H ; Point to next character DCR B ; One less character to go JNZ READF1 ; Loop till done READF2: MVI M,'$' ; Put a end of message character for print LXI D,CTAIL ; Start of message CALL MESSAGE ; Print the volume label ; NXTVOL: LDA ALLFLG ORA A ; Is program to check all drives JZ QUIT ; No, quit ; LDA MAXDRV ; Maximum drives on system MOV C,A ; Save it LDA FCB CMP C ; Has program gone through all drives JZ QUIT ; Yes, quit INR A ; Increment to next drive STA FCB ; Move to FCB JMP CURDRV ; And check for Volume Label Record on drive ; NOVOL: LXI D,NOFILE ; Tell him the volume label record not found CALL MESSAGE JMP NXTVOL ; Go see if any more drives ; NONEWM: LXI D,NONEW ; Tell him can't make a volume label record CALL MESSAGE JMP QUIT ; Quit the job ; HELP: LXI D,HLPMSG ; Display menu of functions CALL MESSAGE ; ; Restore disk and user areas to original values and return to CP/M ; QUIT: LDA CDISK ; Get default drive same as entry MOV E,A MVI C,SELDRV ; SELDRV BDOS function CALL BDOS LDA CUSER ; Get user the same as entry MOV E,A MVI C,SETUSR ; SETUSR BDOS function CALL BDOS LHLD STACK ; Stack from CCP SPHL RET ; Return to CP/M ; MESSAGE:MVI C,PRINT ; BDOS PRINT FUNCTION JMP BDOS ; Go to BDOS and return to main program ; ; Equates ; CR EQU 0DH ; Carriage return LF EQU 0AH ; Line feed TAB EQU 09H ; Tab character EOF EQU 1AH ; End of file indicator CTAIL EQU 80H ; CCP command tail ; BDOS EQU 0005H CONIN EQU 1 ; Console input function CONOUT EQU 2 ; Console output function PRINT EQU 9 ; Print string at console function CONSTAT EQU 11 ; Get console status function RTNVER EQU 12 ; Return version number function SELDRV EQU 14 ; Select drive OPEN EQU 15 ; Open a file function CLOSE EQU 16 ; Close a file function SRCHF EQU 17 ; Search for first function SRCHN EQU 18 ; Search for next function DELETE EQU 19 ; Delete a file function READ EQU 20 ; Read a file function WRITE EQU 21 ; Write a file function MAKE EQU 22 ; Make a file function RENAME EQU 23 ; Rename a file function SETIOB EQU 24 ; Set I/O byte RTNCD EQU 25 ; Return Current Disk SETDMA EQU 26 ; Set buffer address function SETUSR EQU 32 ; Set/get user code function READR EQU 33 ; Read random record ; ; Data Areas ; VOLHDR: DB CR,LF DRIVE: DB ' : $' NOFILE: DB 'No Volume$' YESNEW: DB 'Volume created$' NONEW: DB 'Disk Full$' SIGNON: DB 'VOL Version 2.0, 06/12/86',13,10,'$' HLPMSG: DB 'Allows you to create, modify, or display a volume label.' DB CR,LF,'SYNTAX: VOL [[drive:] [new volume description]]$' ; FCB: DB 0 ; Drive specifier DB '-VOLUME ' ; File name FCBEXT: DB '???' ; File type, hidden DS 23 ; All the other stuff ; NEWVOL: DS 1 ; New volume flag ALLFLG: DS 1 ; Show all drives flag CDISK: DS 1 CUSER: DS 1 DS 32 STACK: DS 2 END VOL