home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
catlog
/
dsklabl1.lbr
/
DSKLABL1.AQM
/
DSKLABL1.ASM
Wrap
Assembly Source File
|
1987-02-14
|
16KB
|
878 lines
; The following software is copyrighted 10/20/83 by:
; Dennis McFerran
; 1038 Polk Lane
; San Jose, CA 95117
; Tel-408-296-6021
; Comments and suggestions welcome.
;
;
;Program name: DSKLABL
;Version : 1
;Purpose : Prepare a printed "Avery" type label
; to identify the various files on a
; disk.
;Equipment : Written for the Osborne 01, either
; Single or Double Density and the Epson
; Printer
;
;Output : The program produces a label with a
; heading that shows:
; a) The date produced
; b) Whether the disk is single or double
; density
; c) The amount of Free Space on the disk
; d) The "Name" of the disk (i.e. -UTILITY.U01)
; e) The "Page" number of the label relative
; to that particular disk
;
;Instructions:
; 1. Place this program on a disk in
; Drive A. It makes some sense to
; include it on the same disk that you
; use for cataloging your files (NCAT
; or whatever). If you don't catalog
; I suggest that you check out the
; possiblities in our library.
;
; 2. Put the continuous form labels in
; your printer.
;
; 3. Mount the disk to be labeled in
; drive B.
;
; 4. Type dsklabl1 b: <CR>
;
; 5. The first time in each labelling session
; the program will ask you for the date. It
; is stored so that it will be remembered
; from disk to disk unless depredd the RESET
; button.
;
; 6. The disk will whir for a second and then,
; assuming you have turned on your print,
; will produce a label(s) that you may affix
; to the disk.
;
; 7. Repeat step 4 for each disk that you want
; to label.
;
;Remarks: This is the first version of a nearly complete
; rewrite of my old DIRLABLE program and solves many problems
; that were inherent in that code.
; This program now (I hope) calculates the Free Space on the
; disk properly, allows the user to easily change the number
; of columns and lines of information to fit any size of
; label that you want to use, identifies the "name" of the
; disk on each "Page" of labels that it creates for the disk.
;
;
;===The following will determine the number of columns
; and lines that will appear on your label. The
; current values of 4 and 7 will fit on a standard
; 3.5" by 15/16" label.
LINEMAX EQU 4 ;For 4 across labeling
LINES EQU 7 ;For 6 lines of listing per label
;
;**********EPSON MX-100 PRINTER CODES***************
;===These codes must be changed for other printers *
; *
ESCAPE EQU 27 ; *
SPACING EQU 65 ;LINE SPACING *
CONDON EQU 15 ;CONDENSED PRINTING ON *
CONDOFF EQU 18 ;CONDENSED PRINTING OFF *
UNIDIR EQU 'U' ;UNIDIRECTIONAL PRINT *
FORLEN EQU 67 ;SETS FORM LENGTH *
FORMFEED EQU 12 ;FORM FEED *
CR EQU 13 ;CARRIAGE RETURN *
LF EQU 10 ;LINE FEED *
;***************************************************
;
;
;
ORG 100h
;***************************************************
;STARTUP OPERATIONS
STARTUP LXI H,0 ;SAVE THE OLD STACK
DAD SP ;H=STACK
SHLD STACK ;SAVE IT
LXI SP,STACK ;GET NEW STACK
;RESET SYSTEM
reset MVI C,13
CALL BDOS
;SAVE FILE WRITE REQUEST CHAR
LDA FCB+17
STA FILESW
LXI H,FCB+1
;MAKE FCB ALL '?'
MVI B,11 ;FN+FT COUNT
QLOOP MVI M,'?' ;STORE '?' IN FCB
INX H
DCR B
JNZ QLOOP
;***************************************************
HEADER:
call getspace
call setdate
call getdisk
call initptr
call findfiles
call sorter
call printit
jmp 0000
SETDATE:
lxi h,datebuff
mov a,m
cpi 1h ;is month 1-12
jm getdate
cpi 13h
jnc getdate
inx h
mov a,m
cpi 1h ;is day 1-31
jm getdate
cpi 32h
jnc getdate
inx h
mov a,m
cpi 80h ;is year 80-89
jm getdate
cpi 90h
jnc getdate
;if so date is ok as is
MONTH
lxi h,0010h
mov a,m
cpi 10h
jc lessten
mvi a,'1'
sta datstor
mov a,m
sui 10h
lessten adi 30h
sta datstor+1
DAY
inx h
mov a,m
cpi 30h
jc lessthrty
mvi a,'3'
sta datstor+3
mov a,m
sui 30h
jmp getyear
lessthrty
mov a,m
cpi 20h
jc lesstwnty
mvi a,'2'
sta datstor+3
mov a,m
sui 20h
jmp getyear
lesstwnty
mov a,m
cpi 10h
jc getyear
mvi a,'1'
sta datstor+3
mov a,m
sui 10h
getyear
adi 30h
sta datstor+4
inx h
mov a,m
sui 80h
adi 30h
sta datstor+7
ret
GETDATE:
MVI A,'$'
STA TEMPBUFF+10
MVI A,8
STA TEMPBUFF
LXI D,DATEREQ
MVI C,PRINT
CALL BDOS
MVI C,RDCON
LXI D,TEMPBUFF
CALL BDOS
lxi d,datebuff
lxi h,tempbuff
call convert
call convert
call convert
jmp SETDATE
convert inx h
inx h
mov a,m
sui 30h
mov b,a
add a
daa
add a
daa
add b
daa
add a
daa
mov c,a
inx h
mov a,m
sui 30h
add c
daa
stax d
inx d
ret
GETDISK:
MVI E,15
MVI C,32
CALL BDOS
LXI d,fcb
MVI a,'-'
STA fcb+1
MVI C,17
CALL FINDFILE
JP Foundit
MVI E,00
MVI C,32
CALL BDOS
LXI d,fcb
MVI C,17
CALL FINDFILE
JM Noname
JMP Foundit
;===error routine
diskreq db 1ah,'Input disk name (max 7 filename,3 extension)',cr,lf
db '(ie UTILITY.001) ===> '
nameform db 1bh,29h,'-------.---',1bh,28h,'$'
consbuff db 11,00,' '
noname lxi d,diskreq
mvi c,print
call bdos
mvi b,11
mvi c,02
mvi e,08
backmor push d
push b
call bdos
pop b
dcr b
pop d
jnz backmor
lxi d,consbuff
mvi c,10
call bdos
mvi c,32
mvi e,15
call bdos
lxi d,fcb+1
lxi h,consbuff+2
mvi a,'-'
stax d
inx d
mvi b,7
call movmor
mvi b,3
inx h
call movmor
mvi c,22
lxi d,fcb
call bdos
mvi c,32
mvi e,00
call bdos
restart
lhld 01
mvi l,00
mov a,h
sui 16h
mov h,a
shld ccp
lxi d,refile
lxi b,10
lhld ccp
mvi l,07
call again
lhld ccp
mvi l,88h
mvi a,08h
mov m,a
lhld ccp
mvi l,89h
mov a,h
mov m,a
lhld ccp
pchl
again ldax d
mov m,a
inx h
inx d
dcx b
mov a,b
ora c
jnz again
ret
ccp ds 2
refile db 10,'DDLABEL B:',0,0,0,0,0,0,0
movmor mov a,m
cpi 'A'
jc okasis
cpi 'a'-1
jc okasis
sui 20h
okasis stax d
inx h
inx d
dcr b
jnz movmor
ret
FINDFILE
CALL BDOS
ORA A
RM
ANI 3 ;make mod 4
ADD A ;mult
ADD A ; by
ADD A ; 32
ADD A ; for
ADD A ; offset
LXI H,81h
ADD L ;Point to entry
MOV L,A ;h-l now addresses filename
mvi a,0
adi 1h
RET
Foundit push h
MVI E,00
MVI C,32
CALL BDOS
POP h
lxi d,DISKSTOR
MVI b,8
CALL Morstor
mvi a,'.'
stax d
inx d
mvi b,3
jmp Morstor ;jump and return
MORSTOR MOV a,m
cpi ' '
jz skipsp
stax d
inx d
skipsp inx h
dcr b
jnz morstor
Ret
GETSPACE:
lda 005ch
sta l389
push psw
;call ddorsd
pop psw
mvi c,19h
call 0005
sta l388
lda l389
ora a
jz l21f
dcr a
sta l388
l21f lda l388
mvi c,0eh
mov e,a
call 0005
mvi c,1fh
call 0005
shld l38a
MOV A,M ;IF ITS 28 ITS DD
;IF ITS 14 ITS SD
CPI 20H
jc single
DOUBLE LXI H,EXTVAL
MVI M,1
lxi h,DENSITY
Mvi m,'D'
inx h
Mvi m,'b'
inx h
Mvi m,'l'
single
lhld l38a
lxi d,0005
dad d
mov e,m
inx h
mov d,m
xchg
inx h
shld l38c
lhld l38a
inx h
inx h
mov a,m
sui 02
sta l380
lxi h,0200h
l277 dad h
dcr a
lhld l38c
push h
lda l388
mov e,a
mvi c,0eh ;select disk
call 0005
mvi c,1bh
call 0005
pop d
dcx h
l2a9 mvi c,30h
l2ae inx h
mov a,m
mvi b,08h
l2b2 rlc
jc past
push h
lhld l381
inx h
shld l381
pop h
past dcx d
push psw
mov a,d
ora e
jz l2cc
pop psw
dcr c
jz l2a9
dcr b
jz l2ae
jmp l2b2
l2cc pop psw
mvi c,1dh
call 0005
lda l388
lxi d,0001
ora a
mov c,a
l2e0 jz l2ed
mov a,e
rlc
mov e,a
mov a,d
rlc
mov d,a
dcr c
jmp l2e0
l2ed mov a,e
ana l
mov l,a
mov a,d
ana h
ora l
jz l2fb
mvi a,4fh
l2fb lda l388
adi 41h
lda l380
l31b lhld l381
dcr a
jz l323
dad h
jmp l31b
l323
lda extval
cpi 1
jz dbld
dad h
dbld call l183
call l13f
db '$'
mvi a,'k'
lhld storaddr
mov m,a
ret
l183 push b
push d
push h
lxi b,0fff6h
lxi d,0ffffh
l18c dad b
inx d
jc l18c
lxi b,000ah
dad b
xchg
mov a,h
ora l
cnz l183
mov a,e
adi 30h
push h
lhld storaddr
mov m,a
inx h
shld storaddr
pop h
pop h
pop d
pop b
ret
l13f xthl
l140 mov a,m
inx h
cpi 24h
jz l14d
call l14f
jmp l140
l14d xthl
ret
l14f push h
push d
push b
push psw
mvi c,02
ani 7fh
mov e,a
pop psw
pop b
pop d
pop h
ret
EJECT:
mvi e,12
mvi c,wrchr
call bdos
PRINTHEAD:
lda pagestor
inr a
sta pagestor
lxi h,datstor
call wrcon
ret
;Initialize printer
INITPTR LXI H,TTL ;printer initialization
Call wrcon
Jmp Printhead
;FIND FILES; SORT; and PRINT
FINDFILES:
mvi a,'?'
lxi h,005dh
mov m,a
MVI C,FSRCHF ;GET 'SEARCH FIRST' FNC
LXI D,FCB
CALL BDOS ;READ FIRST
INR A ;WERE THERE ANY?
STA TEMP ;SAVE
JZ EXIT1 ;GOT SOME - PRT TITLE, CONT
CALL SOME
MVI E,00
MVI C,32
CALL BDOS
RET
;READ MORE DIRECTORY ENTRIES
MOREDIR MVI C,FSRCHN ;SEARCH NEXT
LXI D,FCB
CALL BDOS ;READ DIR ENTRY
INR A ;CHECK FOR END (0FFH)
RZ ;GOTFCB1 ;NO MORE - SORT & PRINT
;POINT TO DIRECTORY ENTRY
SOME DCR A ;UNDO PREV 'INR A'
ANI 3 ;MAKE MODULUS 4
ADD A ;MULTIPLY...
ADD A ;..BY 32 BECAUSE
ADD A ;..EACH DIRECTORY
ADD A ;..ENTRY IS 32
ADD A ;..BYTES LONG
LXI H,81H ;POINT TO BUFFER
;(SKIP TO FN/FT)
ADD L ;POINT TO ENTRY
MOV L,A ;SAVE (CAN'T CARRY TO H)
;MOVE ENTRY TO TABLE
XCHG ;ENTRY TO DE
LHLD NEXTT ;NEXT TABLE ENTRY TO HL
MVI B,31 ;ENTRY LENGTH
TMOVE LDAX D ;GET ENTRY CHAR
MOV M,A ;STORE IN TABLE
INX D
INX H
DCR B ;MORE?
JNZ TMOVE
SHLD NEXTT ;SAVE UPDATED TABLE ADDR
LDA COUNT ;GET PREV COUNT
INR A
STA COUNT
JMP MOREDIR
;SORT AND PRINT
sorter LDA COUNT ;INIT THE ORDER TABLE
LXI H,ORDER
LXI D,TABLE
LXI B,31 ;ENTRY LENGTH
BLDORD MOV M,E ;SAVE LO ORD ADDR
INX H
MOV M,D ;SAVE HI ORD ADDR
INX H
XCHG ;TABLE ADDR TO HL
DAD B ;POINT TO NEXT ENTRY
XCHG
DCR A ;MORE?
JNZ BLDORD ;..YES
LDA COUNT ;GET COUNT
STA FILCOUNT;SAVE AS # TO PRINT
STA SCOUNT ;SAVE AS # TO SORT
DCR A ;ONLY 1 ENTRY?
JZ Printit ;.YES, SO SKIP SORT
SORT XRA A ;GET A ZERO
STA SWITCH ;SHOW NONE SWITCHED
LDA SCOUNT ;GET COUNT
DCR A ;USE 1 LESS
STA TEMP ;SAVE # TO COMPARE
STA SCOUNT ;SAVE HIGHEST ENTRY
JZ Printit ;EXIT IF NO MORE
LXI H,ORDER ;POINT TO ORDER TABLE
SORTLP CALL COMPR ;COMPARE 2 ENTRIES
CM SWAP ;SWAP IF NOT IN ORDER
INX H ;BUMP ORDER
INX H ;..TABLE POINTER
LDA TEMP ;GET COUNT
DCR A
STA TEMP
JNZ SORTLP ;CONTINUE
;ONE PASS OF SORT DONE
LDA SWITCH ;ANY SWAPS DONE?
ORA A
JNZ SORT
;SORT IS ALL DONE - PRINT ENTRIES
RET
printit LXI H,ORDER
SHLD NEXTT
MVI A,labelmax ;entries on one label
STA LabCount
MVI A,linemax ;entries on one line
STA PrCount
;PRINT AN ENTRY
ENTRY MVI C,CONST ;CK STATUS OF KB
CALL BDOS ;ANY KEY PRESSED?
DCR A
JZ ABORT ;YES, ABORT
LHLD NEXTT ;GET ORDER TABLE POINTER
MOV E,M ;GET LO ADDR
INX H
MOV D,M ;GET HI ADDR
INX H
SHLD NEXTT ;SAVE UPDATED TABLE POINTER
XCHG ;TABLE ENTRY TO HL
MVI B,8 ;FILE NAME LENGTH
CALL TYPEIT ;TYPE FILENAME
MVI A,'.'
CALL TYPE
MVI B,3 ;GET THE FILETYPE
CALL TYPEIT
lda filcount
dcr a
sta filcount
jz exit1
LDA PRCOUNT
DCR A
STA PRCOUNT
CPI 0
JNZ NOTEND
MVI A,linemax
STA PRCOUNT
call crlf
jmp newline
notend lxi h,fence
call wrcon
newline LDA LabCount
dcr a
STA LabCount
JNZ ENTRY
MVI a,labelmax
STA LABCOUNT
CALL eject
JMP ENTRY
CRLF MVI E,cr ;PRINT
MVI C,wrchr ;C/R
CALL BDOS
MVI E,lf ;LF
MVI C,wrchr
JMP BDOS
TEMP DS 1 ;SAVE DIR ENTRY
;ABORT - READ CHAR ENTERED
ABORT MVI C,RDCHR
CALLB CALL BDOS ;DELETE THE CHAR
;FALL INTO EXIT
EXIT1
MVI E,00
MVI C,32
CALL BDOS
LXI H,RESPRINT
CALL WRCON
LHLD STACK ;GET OLD STACK
SPHL ;MOVE TO STACK
RET ;..AND RETURN
;COMPARE ROUTINE FOR SORT
COMPR PUSH H ;SAVE TABLE ADDR
MOV E,M ;LOAD LO
INX H
MOV D,M ;LOAD HI
INX H
MOV C,M
INX H
MOV B,M
;BC, DE NOW POINT TO ENTRIES TO BE COMPARED
XCHG
CMPLP LDAX B
CMP M
INX H
INX B
JZ CMPLP
POP H
RET ;COND CODE TELLS ALL
;SWAP ENTRIES IN THE ORDER TABLE
SWAP MVI A,1
STA SWITCH ;SHOW A SWAP WAS MADE
MOV C,M
INX H
PUSH H ;SAVE TABLE ADDR+1
MOV B,M
INX H
MOV E,M
MOV M,C
INX H
MOV D,M
MOV M,B
POP H
MOV M,D
DCX H ;BACK POINTER TO CORRECT LOC'N
MOV M,E
RET
;TYPE CHAR IN A
TYPE PUSH B
PUSH D
PUSH H
MOV E,A
MVI C,WRCHR
CALL BDOS
POP H
POP D
POP B
RET
WRCON MVI A,24H
CMP M
RZ
MOV A,M
PUSH H
CALL TYPE
POP H
INX H
JMP WRCON
TYPEIT MOV A,M
CALL TYPE
INX H
DCR B
JNZ TYPEIT
RET
;*******************************************************
ds 30 ;Stack area
STACK ds 2 ;Save old stack here
FILESW ds 1 ;'F' if writing file
EXTVAL DB 2 ;DENSITY SETTINGS
;**************************************************
l388 db 00
l389 db 00
l38a db 00,00
l38c db 00,00
l38e db 00,00
l380 db 00
l381 db 00,00
storaddr dw spacstor
DATSTOR db ' / /8 '
DENSITY db 'SngDen Free Space='
SPACSTOR db 00,00,00
db ' '
DISKSTOR db ' Page '
PAGESTOR db '0',cr,lf,'$'
DATEREQ DB 'Please enter today''s date as mm/dd/yy---->$'
FCB EQU 005CH ;file control block
BDOS EQU 0005H ;BDOS CALL LOCATION
DATEBUFF EQU 0010H
PRINT EQU 9 ;PRINT CONSOLE BUFF
RDCON EQU 10 ;READ CONS BUFFER
WRCHR EQU 5
RDCHR EQU 1 ;READ CHAR FROM CONSOLE *
CONST EQU 11 ;CHECK CONS STAT *
FSRCHF EQU 17 ;Find first directory entry
FSRCHN EQU 18 ;Find next directory entry
LABELMAX EQU LINEMAX*LINES
TEMPBUFF DS 10
RESPRINT DB FORMFEED,CONDOFF,ESCAPE,SPACING,12
DB ESCAPE,FORLEN,66 ;EPSON CODES
DB ESCAPE,UNIDIR,0,'$' ;TO RESTORE PRINTER TO NORMAL
TTL DB ESCAPE,FORLEN,0,1 ;SET PAGE LENGTH AT 1".
DB ESCAPE,SPACING,8 ;SET LINE SIZE TO 8/72"
DB ESCAPE,UNIDIR,1 ;SET UNIDIRECTIONAL PRINT.
DB CONDON,'$' ;SET CONDENSED PRINT.
LABCOUNT db 0
SETPRNTR DB ESCAPE,FORLEN,0,1 ;SET PAGE LENGTH AT 1".
DB ESCAPE,UNIDIR,1 ;SET UNIDIRECTIONAL PRINT.
DB CONDON,'$' ;SET CONDENSED PRINT.
NEXTT DW TABLE ;NEXT TABLE ENTRY
EXTCOUNT DB 02
COUNT DB 0 ;ENTRY COUNT
COUNT1 db 0
SCOUNT DB 0 ;# TO SORT
PRCOUNT DB 0 ;COUNTER FOR ITEMS ON LINE
FILCOUNT DB 0
FENCE DB ' | $'
SWITCH DB 0 ;SWAP SWITCH FOR SORT
ORDER DS 128 ;ORDER TABLE
TABLE EQU $ ;READ ENTRIES IN HERE
END 100H