home *** CD-ROM | disk | FTP | other *** search
- TITLE TRUNCATE absolute printer driver image into a DRV file
-
- ;
- ; Equates
- ;
- CR EQU 0DH ; Special chars
- LF EQU 0AH
- ;
- BDOS EQU 0005H ; BDOS entry point
- DFCB EQU 005CH ; Default FCB
- DRVORG EQU 8680H ; Load point for printer driver
- DRVREC EQU (DRVORG-300H) SHR 7 ; Record corresponding to load point
-
- ;
- ; Start truncation program
- ;
- ASEG
- ORG 100H ; Start of TPA
- JMP T1
- ;
- DS 128
- T1: LXI SP,$ ; Top of stack
- ;
- LXI H,DFCB+16+1 ; No output FCB?
- MOV A,M
- CPI ' '
- JZ THELP
- ;
- LXI D,OTFCB ; Copy output FCB name
- DCX H
- MVI B,12
- CALL COPY
- ;
- LXI D,DFCB+1 ; No input FCB?
- LDAX D
- CPI ' '
- JZ THELP
- ;
- DCX D ; Can't open input file?
- XRA A
- STA DFCB+12
- MVI C,15
- CALL BDOS
- INR A
- JZ THELP
- ;
- LXI D,OTFCB ; Create new output file
- PUSH D
- MVI C,19
- CALL BDOS
- POP D
- MVI C,22
- CALL BDOS
- INR A
- JZ TFULL
- ;
- LXI H,DRVREC ; Starting record within image
- SHLD DFCB+33
- XRA A
- STA DFCB+35
- ;
- STA OTFCB+32 ; Start of output file
- ;
- T2: MVI B,0 ; Read bufferful from input file
- LXI D,OTBFR
- T3: PUSH B
- PUSH D
- MVI C,26
- CALL BDOS
- LXI D,DFCB
- MVI C,33
- CALL BDOS
- POP D
- POP B
- ORA A
- JNZ T4
- ;
- LHLD DFCB+33 ; Next record
- INX H
- SHLD DFCB+33
- LXI H,128
- DAD D
- XCHG
- INR B
- MOV A,B
- CPI OTSIZE
- JNZ T3
- ;
- T4: INR B ; Done?
- DCR B
- JZ T6
- ;
- LXI D,OTBFR ; Write from buffer
- T5: PUSH B
- PUSH D
- MVI C,26
- CALL BDOS
- LXI D,OTFCB
- MVI C,21
- CALL BDOS
- POP D
- POP B
- ORA A
- JNZ TFULL
- ;
- LXI H,128 ; Next record
- DAD D
- XCHG
- DCR B
- JNZ T5
- JMP T2
- ;
- T6: LXI D,DFCB ; Close files
- MVI C,16
- CALL BDOS
- LXI D,OTFCB
- MVI C,16
- CALL BDOS
- ;
- LXI D,TDONMS ; All done
- JMP THEL1
- ;
- TFULL: LXI D,TFULMS ; Disk full
- JMP THEL1
- ;
- THELP: LXI D,THELMS ; Display help message
- THEL1: MVI C,9
- CALL BDOS
- ;
- TDONE: MVI C,0 ; Done, exit to CP/M
- MOV E,C
- CALL BDOS
- ;
- THELMS: DB CR,LF
- DB 'TRUNCATE DRIVER.TMP DRIVER.DRV',CR,LF,LF
- DB 'Where, DRIVER.TMP is the absolute driver image',CR,LF
- DB ' DRIVER.DRV is the resulting DRV file',CR,LF
- DB '$'
- ;
- TFULMS: DB 'Disk full$'
- TDONMS: DB 'DRV file created$'
-
- ;
- ; Subroutines
- ;
- COPY: ; Copy B bytes from HL to DE
- MOV A,M
- STAX D
- INX H
- INX D
- DCR B
- JNZ COPY
- RET
- ;
- ; Variable data
- ;
- OTFCB: DB 0,' ' ; Output FCB
- DW 0,0,0,0,0,0,0,0,0,0,0,0
- ;
- OTBFR: ; Output buffer follows
- OTSIZE EQU 1024/128 ; Assume 1k available
-
- END