Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 alpha 4/15/85; site loral.UUCP Path: utzoo!linus!decvax!ittatc!dcdwest!sdcsvax!sdcc3!sdcc6!loral!dml From: dml@loral.UUCP (Dave Lewis) Newsgroups: net.micro.6809 Subject: Public Domain utility program Message-ID: <947@loral.UUCP> Date: Fri, 18-Oct-85 13:58:22 EDT Article-I.D.: loral.947 Posted: Fri Oct 18 13:58:22 1985 Date-Received: Sun, 20-Oct-85 09:09:56 EDT Reply-To: dml@loral.UUCP (Dave Lewis) Distribution: net.micro.6809 Organization: Loral Instrumentation, San Diego Lines: 208 --> line eater choker <-- Here's a program that can save some time and finger wear. It runs fine on a Color Computer using OS-9 level 1 version 1.01.00 -- can't vouch for anything else but it should work on any system. It's great for making a new OS9Boot file or working on a combined device driver/device descriptor file. Assemble using the Microware OS-9 assembler. Give it at least 10K of symbol memory. ------ Assembly listing starts here------ ***************************************************************** * This sourcecode listing is released to public domain by * * Dave Lewis San Diego CA October 16, 1985 * * It may be copied and used for any purpose EXCEPT for sale. I'm * not getting paid for writing it -- don't try to get paid for * copying it. ***************************************************************** * Utility to break a multiple-module file (like OS9Boot) into its * component modules and store them as separate files in a * specified or default directory. * * Usage: Separate /Dn/DIRECTORY/filename /Dn/DIRECTORY * * Modules are stored in destination directory under their module * names. Ensure there are no existing files with the same name * as any of the modules. * NAM Separate TTL Module separator * IFP1 USE /D0/DEFS/OS9Defs USE /D0/DEFS/SCFDefs ENDC * REV EQU 1 TYPE EQU PRGRM+OBJCT ATTR EQU REENT+REV * MOD SIZE,NAME,TYPE,ATTR,EXEC,STORG NAME FCS 'Separate' FCB 1 Version number * INPATH RMB 1 Input file path number OUTPATH RMB 1 Output file path number FILEPTR RMB 2 Address of output filename EOBUFPTR RMB 2 Buffer end address EOMEMPTR RMB 2 Data memory end address MODSIZE RMB 2 Bytes still to be written MODPTR RMB 2 Disk file position pointer OPTHLST RMB 60 Output pathlist buffer DATABUF RMB 700 Module data buffer RMB 232 Reserve stack space RMB 20 Reserve parameter area STORG EQU . * EXEC STY EOMEMPTR End of allocated memory LEAY DATABUF+700 Find end of data buffer STY EOBUFPTR Store end address CLR MODPTR Zero out module offset point- CLR MODPTR+1 er; start at BOF LDA #READ. Access mode = read OS9 I$OPEN Open input file BCS SPEXIT Exit if error STA INPATH Store input path number * LEAY OPTHLST,U Get pathlist buffer address FINDPATH CMPX EOMEMPTR Test X for end of memory BHS NOPATH No pathlist, use working dir LDA ,X+ Get next character CMPA #'/ Test for pathname start BEQ FOUNDPATH BSR ALPHTEST Test for letter (UC or lc) BNE FINDPATH Not a letter; keep looking FOUNDPTH LEAX -1,X Set X back to character MOVEPATH LDA ,X+ Get next character CMPA #C$CR Test character for `CR' or BEQ MPEXIT blank; either indicates CMPA #C$SPAC the end of a pathlist. BEQ MPEXIT STA ,Y+ Add character to outpathlist CMPX EOMEMPTR Test for end of parameter BLO MOVEPATH memory; can't go past it MPEXIT LDA #'/ Prepare pathlist for addition STA ,Y+ of a filename * NOPATH STY FILEPTR Save pointer to next byte BSR GETMOD Do all modules of input file SPEXIT OS9 F$EXIT End; pass any errors out * ALPHTEST TFR A,B Don't change letter in A ANDB #$DF Change lowercase to uppercase CMPB #'A Test for less than an `A' BLO NOTALPH CMPB #'Z Test for greater than a `Z' BHI NOTALPH CLRB Return w/Z flag set if alpha NOTALPH RTS * GETMOD LDA INPATH Read from input file LEAX DATABUF,U Point to data buffer LDY #9 Read first 9 bytes (header) OS9 I$READ Does not change X register BCC GETMOD2 Continue if no error CMPB #E$EOF Test for end-of-file error BNE GMEXIT1 End of file just means you're CLRB done; other errors are real GMEXIT1 RTS * GETMOD2 LDD DATABUF Load first two bytes of file CMPD #M$ID12 and test for module ID BEQ GETMOD3 Continue if ID good COMB Set carry flag for error LDB #E$BMID Set error code RTS * GETMOD3 LDD DATABUF+2 Load module size STD MODSIZE Store as variable LDD DATABUF+4 Load module name offset PSHS U Save U LDU MODPTR Get module offset in file LEAU D,U Add name offset in module LDX #0 MS 16 bits of file position LDA INPATH Position file pointer on OS9 I$SEEK first byte of module name PULS U Restore U register BCC GETMOD4 Continue if no error GMEXIT2 RTS * GETMOD4 LEAX DATABUF,U LDY #32 Module name can't exceed LDA INPATH 32 characters OS9 I$READ Read module name BCS GMEXIT2 Exit if error LDY FILEPTR Point to destination MOVLOOP LDA ,X+ Move name to pathlist buffer STA ,Y+ TSTA Test for last character -- BPL MOVLOOP MSB will be set ANDA #$7F Clear MSB STA -1,Y Store corrected character LDA #C$CR Terminate line STA ,Y LEAX OPTHLST,U Point to pathlist LDB #$F Attributes: r w e pr LDA #WRITE. Access mode OS9 I$CREATE Create and open output file BCS GMEXIT2 Exit if error STA OUTPATH Store path number * PSHS U Save U LDU MODPTR Point to start of module LDX #0 MS 16 bits of file pointer LDA INPATH Path number OS9 I$SEEK Position file pointer PULS U Restore U BCS GMEXIT2 Exit if error LDD MODPTR Module offset in file ADDD MODSIZE Length of module STD MODPTR Point to next module in file * MODLOOP STD MODSIZE Store updated module size CMPD #700 Is it bigger than buffer? BLS LOADALL No, read it all LDD #700 Fill the buffer LOADALL TFR D,Y Y contains #bytes to read PSHS D Save #bytes to be read LEAX DATABUF,U Point to start of buffer LDA INPATH Get input path number OS9 I$READ Read data BCS GMEXIT3 Exit if read error CMPY ,S Were intended number of bytes BEQ GETMOD5 actually read? COMB If not, report it as a LDB #E$READ read error GMEXIT3 PULS Y,PC Pull and return * GETMOD5 LDA OUTPATH Get output path number OS9 I$WRITE Write same number of bytes BCS GMEXIT4 Exit if error CMPY ,S Were correct number of BEQ GETMOD6 bytes written? COMB If not, report a write LDB #E$WRITE error GMEXIT4 PULS Y,PC Pull and return * GETMOD6 LDD MODSIZE Get total size of module SUBD ,S++ Subtract bytes just processed BNE MODLOOP More of this module remains LDA OUTPATH Get output path number OS9 I$CLOSE Close output file LBCC GETMOD Process next module RTS If error, exit EMOD CRC bytes SIZE EQU * ---------------- Dave Lewis Loral Instrumentation San Diego !sdcc3 ---\ !sdcc6 ---->--- !loral!dml (uucp) !sdcsvax -/ "Always put your clothes and weapons where you can find them quickly in the dark" -- Lazarus Long.