;******************************************** ; Program Written by: HARRIS LANDSBERG c1985 ; Name: LABEL.ASM in standard 8080 ASM code ; ; Designed as a MS-DOS diskette volume ident ; label editor simulator. ; ; Comment: Works in conjunction with VOL in ; order to label diskettes for identification ; similar to MS-DOS LABEL program. Create ; a hidden file call DISKETTE.VOL on disk. ; ; Run: LABEL [d:] ;******************************************** BDOS EQU 0005H ;System Call Location DMA EQU 0080H ;DMA Buffer Location FCB EQU 005CH ;File Control Block DMAL EQU 128 ;DMA Buffer Length GCD EQU 25 ;Get Current Disk READ EQU 20 ;Read Sequential Record SDMA EQU 26 ;Set DMA Address SFF EQU 17 ;Search For First OPEN EQU 15 ;Open File Function MFILE EQU 22 ;Make File Function CLOSE EQU 16 ;Close File Function DLT EQU 19 ;Delete File Function WSR EQU 21 ;Write Sequnetial Record CONIN EQU 1 ;Character Input COUT EQU 2 ;Character Output PSTR EQU 9 ;Print String Function RCON EQU 10 ;Read Console Buffer NOTF EQU 255 ;File Not Found TPA EQU 0100H ;Transient Program Area FEM EQU 26 ;File End Mark CR EQU 13 ;Carraige Return LF EQU 10 ;Line Feed Charcter ; LABEL ORG TPA ;Program Start ; MVI C,SDMA ;Set Buffer Location LXI D,DMA ;At DMA Address CALL BDOS MVI C,PSTR ;Output MSG to Console LXI D,MSG CALL BDOS LDA FCB ;For Which Drive? CPI 0 ;Default Drive CZ GETDR ;Get Current Drive ADI 40H ;Upgrade to A,B,C etc. MVI C,COUT ;Display to Console MOV E,A CALL BDOS LXI D,FCB+1 ;Start Move to position LXI H,FILE ;Start Move from posit. MVI B,11 ;Total 11 Characters FNAME MOV A,M ;From Mem to Accumulator STAX D ;Put into FCB INX D ;Increment Pointers INX H DCR B ;Decrement Counter JNZ FNAME ;Not Finished? MVI C,SFF ;Set Search Directory LXI D,FCB ;For First Call CALL BDOS CPI NOTF ;Not Found? JZ NOVOL ;Has no label MVI C,OPEN ;Open "VOL" File LXI D,FCB CALL BDOS MVI C,READ ;Read First Record LXI D,FCB CALL BDOS MVI C,PSTR ;Output Second string LXI D,YESV CALL BDOS LXI H,DMA ;Start of Record MVI B,11 ;Total 11 Characters DVOL PUSH H ;Save Registers PUSH B MVI C,COUT ;Output Character MOV E,M CALL BDOS POP B ;Restore Registers POP H INX H ;Increment Pointer DCR B ;Decrement Counter JNZ DVOL ;Not Finished? JMP ENDV ;Return to CP/M NOVOL MVI C,PSTR ;Output has no label LXI D,NOV CALL BDOS MVI A,0FFH ;Flag for No Volume STA FEXIST ;Store in Flag Location ENDV MVI C,PSTR ;Output Prompt Message LXI D,PROMPT CALL BDOS MVI C,RCON ;Read Console Buffer LXI D,VID ;Buffer Address CALL BDOS LDA VID+1 ;# of Chars to Accumulator CPI 0 ;ENTER only? JZ EONLY ;No Charcters! LDA FEXIST ;Load File Exist Flag CPI 0FFH ;Does it exist? CNZ DLTFILE ;Delete DISKETTE.VOL MVI A,0CFH ;Make a System File STA FCB+10 ;Change the "O" in VOL CALL CLEAN ;Clean FCB of leftover info. MVI C,MFILE ;Make a Directory Entry LXI D,FCB ;Filename in FCB CALL BDOS CALL RELOC ;Relocate Label to DMa MVI C,WSR ;Write Sequential Record LXI D,FCB ;Filename in FCB CALL BDOS MVI C,CLOSE ;Close the File LXI D,FCB ;Filename in FCB CALL BDOS FINI MVI C,COUT ;Line Feed Character MVI E,LF CALL BDOS RET ; ; Subroutines ; GETDR MVI C,GCD ;Get Current Disk CALL BDOS INR A ;Increment Accumulator RET EONLY LDA FEXIST ;Load File Exist Flag CPI 0FFH ;Does it exist? JZ FINI ;No previous Volume MVI C,COUT ;Skip Extra Line MVI E,LF CALL BDOS AGAIN MVI C,PSTR ;Prompt to Delete LXI D,PRMT2 CALL BDOS MVI C,CONIN ;Character Input CALL BDOS CALL CAPITAL ;Make Character a Capital CPI 'N' ;Don't Delete JZ FINI ;Finished CPI 'Y' ;Delete Volume JNZ AGAIN ;Invalid response CALL DLTFILE ;Delete the File JMP FINI CAPITAL CPI 'a' ;Small Character RM ;No! SUI 020H ;Change to Capital RET DLTFILE MVI C,DLT ;Delete Volume ID LXI D,FCB ;Filename in FCB CALL BDOS RET CLEAN LXI H,FCB+12 ;Right after Filename MVI A,0 ;Zero it out (hex) MVI B,23 ;Load Counter CLOOP MOV M,A ;Into Memory INX H ;Increment Pointer DCR B ;Decrement Counter JNZ CLOOP ;20 iterations? RET RELOC LXI H,VID+2 ;Put VID Address in HL LXI D,DMA ;Put DMA Address in DE MVI B,11 ;Load Counter RLOOP MOV A,M ;Transfer to Accum. STAX D ;Transfer to DMA INX H ;Increment Pointers INX D DCR B ;Decrement Counter JNZ RLOOP ;All Moved? MVI A,FEM ;File End Mark STA DMA+11 ;After 11 Characters RET FILE DB 'DISKETTEVOL' MSG DB LF,'Volume in drive $' NOV DB ' has no label$' YESV DB ' is $' PROMPT DB CR,LF,LF,'Volume label (11 ' DB 'Characters, ENTER for none)? $' PRMT2 DB CR,LF,'Delete current volume label (Y/N)? $' FEXIST DB 0 VID DB 255 ; END