<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Wed, 29 Jan 1986 05:08:27 GMT
From   : "Bruce K. Martin Jr." <u557593877ea%ucdavis.uucp@BRL.ARPA>
Subject: Re: Chaining programs with $$$.SUB file (LONG)

> I have received a bunch of mail on my suggestion for program chaining
  ...
> Ed Greenberg                      | {hplabs,glacier}!well!micropro!edg

  I posted the first request for info on this subject, and last night
I got a very crude version of this methode up and running.  Thanks to
Ed Greenberg for his help.  I hope this helps answer some questions.
Sorry for the length...I wrote it in 8080 assembler, but the commenting
is copious.
  Ah yes...feel free to use this code in any shape, manner or form.  I'm
not responsible for any consequences, but it works fine for me.
                                   bruce

 Bruce K. Martin Jr. [UUCP] ...{dual,lll-crg,ucbvax}!ucdavis!deneb!u557593877ea
 (916) 756-6518      [ARPA] ucdavis!deneb!u557593877ea@ucbvax.berkeley.edu

  As usual, all the above views are completely my own.  All proprietary
names and phrases are the property of their respective firms.  Is that all mom?

     "You have to be trusted by the people that you lie to..."
                                         Pink Floyd

;  This is a quick and dirty command executor and program chainer.
;
;  BY: Bruce K. Martin Jr.
;  ON: 1/27/86
;
;
        ORG     100H
;
        BDOS    EQU     05
        EOF     EQU     1AH
        LF      EQU     10
        CR      EQU     13
;
;
;  NOW SET UP CHAIN FILE
;
        CALL    SETDMA                          ;SET CP/M DMA POINTER
        CALL    SEARCH                          ;LOOK FOR FILE
        CPI     0FFH                            ;IS IT THERE?
        JZ      MAKEFILE                        ;IF NOT, GO CREATE IT
        CALL    DELETE                          ;YES - DELETE IT
;                                               ;IGNORE ERRORS
MAKEFILE:
        CALL    CREATE                          ;CREATE THE FILE
        CPI     0FFH                            ;ERRORS?
        JZ      CRERR
;
;
;       NOW READ ONE COMMAND AT A TIME AND SAVE IN AN INDIVIDUAL SECTOR
;
        LXI     H,COMSTR                        ;POINT TO COMMAND STRING
;
FILLOOP:
        LXI     D,DMA                           ;POINT TO BUFFER
        CALL    CLRDMA                          ;CLEAR DMA
        CALL    MOVE                            ;TRANSFER TO BUFFER
        INX     H                               ;POINT TO BEGINING OF NEXT
        SHLD    COMPTR                          ;COMMAND & STORE POINTER
;
        CALL    WRITE                           ;WRITE TO FILE
        CPI     0                               ;GOOD WRITE?
        JNZ     WRTERR                          ;IF NOT, GO PRINT ERROR
;
        LHLD    COMPTR                          ;GET COMMAND POINTER
        MOV     A,M                             ;GET FIRST BYTE
        ORA     A                               ;IS IT ZERO?
        JNZ     FILLOOP                         ;CONTINUE IF NOT ZERO.
;
        CALL    CLOSE                           ;CLOSE FILE
        JMP     EXIT                            ;DONE
;
;
CRERR:  LXI     H,CREMSG                        ;POINT TO CREATE ERR MESSAGE
        CALL    PRNMSG
        JMP     EXIT                            ;EXIT PROGRAM
CREMSG: DB      21,'FILE CREATION ERROR',LF,CR
;
WRTERR: LXI     H,WRTMSG                        ;POINT TO ERR MESSAGE
        CALL    PRNMSG
        CALL    CLOSE                           ;CLOSE FILE
        CALL    DELETE                          ;DELETE FILE
        JMP     EXIT
WRTMSG: DB      18,'FILE WRITE ERROR',LF,CR
;
EXIT:   LXI     H,EXTMSG
        CALL    PRNMSG
        JMP     00H
EXTMSG: DB      22,LF,CR,'PROGRAM TERMINATED',LF,CR
;
;       PRINT MESSAGE SUBROUTINE -- PRINTS A STRING AT THE ADDRESS [HL]
;       AND LENGTH [A]  {MAX STRING LENGTH 256}
;
PRNMSG: MOV     A,M                             ;GET STRING LENGTH
        INX     H                               ;POINT TO BEGINING
PRLOOP: LXI     B,02                            ;BDOS CONOUT
        MOV     E,M                             ;MOVE CHAR TO E
        PUSH    H                               ;JUST IN CASE!
        PUSH    A
        CALL    BDOS                            ;WRITE IT
        POP     A
        POP     H
        INX     H                               ;POINT TO NEXT LETTER
        DCR     A                               ;DECREMENT LETTER COUNT
        JNZ     PRLOOP                          ;CONTINUE IF NOT DONE
        RET                                     ;AND BYE
;
;       MOVE    THIS ROUTINE MOVES A STRING AT ADDRESS [HL] TO ADDRESS
;       [DE].  STRING IS TERMINATED WITH \0
;
MOVE:   MOV     A,M                             ;GET LETTER
        ORA     A                               ;IS IT ZERO?
        RZ
        XCHG
        MOV     M,A                             ;PUT LETTER
        XCHG
        INX     H
        INX     D
        JMP     MOVE                            ;LOOP
;
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;  NOW -- SUPPORT SUBROUTINES.  THESE ARE FILE ROUTINES
;       THAT ARE CALLED BY THE MAIN PROGRAM
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;       OPEN A FILE - FCB ALREADY CREATED.  0FFH IS RETURNED IN REG
;       A FOR A BAD OPEN.
;
OPEN:   LXI     D,FCB
        LXI     B,0FH
        CALL    BDOS
        RET
;
;       CREATE A FILE - NAME IN FCB.  RETURNS A NUMBER IN REG A
;       THAT IS BETWEEN 0 AND 7FH FOR A GOOD CREATE.  0FFH IS
;       RETURNED FOR AN ERROR CONDITION.
;
CREATE:
        LXI     D,FCB
        LXI     B,16H
        CALL    BDOS
        RET
;
;       CLOSE A FILE -- NOTHING RETURNED
;
CLOSE:  LXI     D,FCB
        LXI     B,10H
        CALL    BDOS
        RET
;
;       SET THE DMA ADDRESS.  NO ERROR CODES
;
SETDMA: LXI     D,DMA
        LXI     B,1AH
        CALL    BDOS
        RET
;
;       READ A RECORD FROM A FILE.  ERROR CODE RETURNED IN REG. A
;       CODE: 0 -- GOOD READ, 1 -- READ PAST EOF, ALL ELSE READ ERR.
;
READ:   LXI     D,FCB
        LXI     B,14H
        CALL    BDOS
        RET
;
;       WRITE A SECTOR TO A FILE.  CONDITION CODE IN REG. A
;       CODE: 0 -- GOOD WRITE, ALL ELSE WRITE ERROR.
;
WRITE:  LXI     D,FCB
        LXI     B,15H
        CALL    BDOS
        RET
;
;       CLEAR DMA TO ALL NULLS -- NOTHING RETURNED
;
CLRDMA: PUSH    H
        PUSH    A
        MVI     A,128
        LXI     H,DMA
CLRLP:  MVI     M,0
        INX     H
        DCR     A
        JNZ     CLRLP
        POP     A
        POP     H
        RET
;
;       SEARCH FOR A FILE SPECIFIED IN THE FCB
;       RETURNS IN REG. A 0FFH IF NOT FOUND
;
SEARCH: LXI     B,011H
        LXI     D,FCB                           ;FCB ADDRESS
        CALL    BDOS
        RET
;
;       DELETE  --  REMOVE A FILE SPECIFIED IN THE FCB
;       REG A RETURNS 0FFH FOR A UNFOUND FILEE
;
DELETE: LXI     B,013H                          ;DELETE FUNCTION
        LXI     D,FCB
        CALL    BDOS
        RET
;
;
;       STORAGE
;
;       COMSTR -- THE COMMAND STRINGS. EACH COMMAND IS TERMINATED WITH
;  A NULL, AND BEGINS WITH A CHARACTER COUNT.  THE LAST COMMAND IS
;  TERMINATED WITH TWO NULLS.
;
COMSTR: DB      3,'DIR',0
        DB      4,'STAT',0
        DB      0                               ;TERMINATOR
;
COMPTR: DW      COMSTR                          ;COMMAND POINTER
;
FCB:    DB      0,'$$$     SUB',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
        DB      0,0,0,0,0,0,0,0,0,0,0,0
;
DMA:    DS      128
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>