home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG039.ARC
/
BATCH.Z80
< prev
next >
Wrap
Text File
|
1979-12-31
|
6KB
|
264 lines
;
; ** BATCH version 2.1 **
; A program to generate a $$$.SUB submit file
; for immediate processing under CP/M 2.2.
;
; Written by Robert Blum
; Published in April '85 "Dr Dobbs Journal"
;
;--NOTES:
; 1) The $$$.SUB file is created on disk unit A
; since the D. R. utility XSUB will only operate
; on disk unit A. If BATCH is run from disk B,
; for example, the $$$.SUB file will be created
; on disk unit A and then processed from disk A.
; All files referenced in the submit file created
; by BATCH must be on the disk unit from which
; BATCH is being run includingg PIP and XSUB.
;
; 2) Use DDT to modify PIP as follows to solve the
; null line PIP exit problem: change 053D from
; 2A to 23, 054E from FE to D6, 0550 from 00 to
; 02, and 051 from C2 to F2. Exit DDT by entering
; G0, and then do a SAVE 32 PIP.COM. The modified
; version of PIP outputs # as an input request
; symbol and will exit on a null or single
; character input line.
;
; 3) Input line must not exceed input buffer length
; which is 132 characters.
;
; 4) Example of use of BATCH:
; >BATCH<RET>
; ->XSUB/PIP/B:=A:XDIR.COM/X/DIR A:/DIR B:<RET>
;
; ** PROGRAM DEFINITIONS **
CR EQU 0DH ;CARRIAGE RETURN
LF EQU 0AH ;LINE FEED
BDOS EQU 5 ;ADDR CP/M BDOS FUNCTION CALLS
;
ORG 100H ;PROG ORG
;
START: LD HL,0
ADD HL,SP ;GET CP/M STACK POINTER
LD (CPMSTK),HL ;SAVE IT
LD SP,STACK ;SETUP NEW STACK
LD DE,PROMPT ;PTR TO SIGNON MESSAGE
CALL PUTSTR ;SEND STRING
CALL SETDMA ;SET DKS BUF ADDR
CALL GETBUF ;GET INPUT
LD HL,INPBUF+1 ;PTR NUM INP CHRS
LD A,(HL) ;GET NUM INP CHRS
LD C,A ;SAVE CHAR CNT IN C
DEC A ;CK IF ANY CHRS IN BUFF
JP M,BCKCPM ;NO CHRS, BACK TO CP/M
JP Z,BCKCPM ;NO CHRS, BACK TO CP/M
LD A,0FFH ;GET FF=START OF INPUT
LD (HL),A ;SET CHR CNT=FF
LD A,C ;GET CHR CNT AGAIN
INC A ;ADD ONE FOR 01 END CHR
;--ADD A TO HL TO FORM END INP STRING--
CALL ADATHL
LD (HL),1 ;INDICATE END OF INPUT
;
;--SELECT DISK UNIT A--
CALL INIT
;
CALL DELETE ;DELETE OLD $$$.SUB
CALL MAKE ;MAKE NEW $$$.SUB
; SET CURRENT RECORD = 0
LD HL,SUBFCB+32 ;HL=PTR CUR POS IN FCB
XOR A
LD (HL),A
;--CONVERT BUFFER TO UPPER CASE CHRS--
;--SKIP ANY LEADING BLANK CHARS IN 1ST STRING--
CALL CNVBUF
LD HL,INPBUF+2 ;HL=PTR INPUT BUFF
;--COUNT CHRS IN INPUT STRING AND SET HL TO END--
COUNT: CALL CNTCHR
;--MAIN COMMAND SCANNING LOOP (RIGHT TO LEFT)--
SCNLOP: LD A,(HL) ;GET CHR
CP 0FFH ;CHECK IF CONE
JR Z,DONE ;QUIT, DONE
LD C,0 ;BACKUP TO PREVIOUS /
SCNLP2: DEC HL ;DEC CHR PTR
LD A,(HL) ;GET CHR
INC C ;INC COUNT
;--FF=BEGINNING (END) OF INPUT STRING--
CP 0FFH ;CHECK IF LAST COMMAND
JR Z,PUTCMN ;PUT LAST COMMAND IN SUB FILE
;--/=BEGINNING (END) OF ONE COMMAND STRING--
CP '/' ;CHECK FOR / BETWEEN COMMANDS
JR NZ,SCNLP2 ;LOOP TILL / OR FF
;--PUT COMMAND INTO SUBMIT FILE--
;--USE CP/M DEFAULT BUFFER AREA--
PUTCMN: PUSH HL ;SAVE POINTER
DEC C ;DEC FOR / CHR
INC HL ;SKIP OVER /
LD A,C
LD (80H),A ;PUT LENGTH IN BUFFER
LD DE,81H
CALL BLKMOV ;MOVE COMMAND TO BUFFER
EX DE,HL ;SET HL TO END OF COMMAND
;--ZERO REST OF BUFFER--
LD A,127
SUB A,C
LD B,A ;SET LOOP COUNT
LD C,0
ZROLOP: LD (HL),C
INC HL
DJNZ ZROLOP
;--WRITE ONE SECTOR--
CALL WRITE ;WRITE BUFF TO SUB FILE
POP HL ;GET POSITION POINTER AGAIN
INC A ;CHECK FOR WRITE ERROR
JR NZ,SCNLOP
;--DISK ERROR-
LD DE,NSPMSG
JP SERMSG
;
;--DONE, BACK TO CP/M--
;--DO A RESET TO START SUBMIT--
DONE: CALL CLOSE
JP 0
;
;--COUNT CHARS IN THE COMMAND--
; MOVE HL TO END OF COMMAND
CNTCHR: LD C,1 ;INIT CNT=1
CNTLOP: LD A,(HL)
CP CR ;END IF CR
RET Z
CP 1 ;END IF CHR=1
RET Z
INC C
INC HL
JR CNTLOP
;
;--ADD A TO HL--
ADATHL: ADD A,L
LD L,A
RET NC
INC H
RET
;
;--BLOCK MOVE--
; HL=SOURCE, DE=DESTINATION, C=NUMBER OF CHARS
BLKMOV: LD B,0
LDIR
RET
;
;--CONVERT BUFFER TO UPPER CASE--
CNVBUF: LD HL,INPBUF+2
LD D,H
LD E,L
;--SKIP LEADING BLANKS
SKPLOP: LD A,(HL)
CP ' '
JR NC,CNVLOP
INC HL
JR SKPLOP
CNVLOP: CALL GETCHR
LD (DE),A ;MOVE CHR
INC DE
INC HL
CP 1 ;END?
JR NZ,CNVLOP
RET
;
;--GET NEXT CHR AND CONV TO UPPER CASE--
GETCHR: LD A,(HL) ;GET CHR
CP 7BH ;ABOVE z?
RET NC
CP 61H ;BELOW a?
RET C
AND 5FH ;LOW TO UP
RET
;
;--GET BUFFERED LINE OF COMMANDS--
GETBUF: LD DE,INPBUF ;INP BUFF ADDR
LD C,10
CALL BDOS
RET
;
;--SET DISK BUFFER ADDRESS(DMA)--
SETDMA: LD DE,80H ;BUFF ADDR
LD C,26
CALL BDOS
RET
;
;--WRITE CONTENTS OF BUFF TO SUB FILE--
WRITE: LD DE,SUBFCB
LD C,21
CALL BDOS
RET
;
;--CLOSE $$$.SUB--
CLOSE: LD C,16
LD DE,SUBFCB
CALL BDOS
RET
;
;--MAKE NEW $$$.SUB FILE--
MAKE: LD DE,SUBFCB
LD C,22
CALL BDOS
INC A ;FF=NO SPACE
JP Z,NOSERR ;NO SPACE ERROR
RET
;
;--DELETE ANY OLD $$$.SUB FILE--
DELETE: LD DE,SUBFCB
LD C,19
CALL BDOS
RET
;
;--INIT AND SELECT DISK A--
INIT: LD C,13
CALL BDOS
RET
;
;--SEND STRING TO TERMINAL--
; --DE=POINTER TO STRING ADDRESS--
PUTSTR: LD C,9
CALL BDOS
RET
;
;--MESSAGES--
PROMPT: DEFB CR,LF,'BATCH v2.1 Submit File Generator'
DEFB CR,LF,'for use with XSUB under CP/M 2.2.'
DEFB CR,LF,'Enter Command String and then <RET>.'
DEFB CR,LF,'Separate each command with a / symbol.'
DEFB CR,LF,'/X may be used to exit modified version of PIP.'
DEFB CR,LF,'->$'
NSPMSG: DEFB CR,LF,'Disk Full--No More Space'
DEFB CR,LF,7,7,'$'
NDSMSG: DEFB CR,LF,'Directory Full--No More Space'
DEFB CR,LF,7,7,'$'
;
NOSERR: LD DE,NDSMSG
;--SEND ERROR MESSAGE AND BACK TO CP/M--
SERMSG: CALL PUTSTR
BCKCPM: LD HL,(CPMSTK)
LD SP,HL ;RESET STACK POINTER
RET ;BACK TO CP/M
;
;--FILE CONTROL BLOCK--
SUBFCB: DEFB 0 ;DRIVE CODE
DEFB '$$$ SUB' ;FILE NAME
DEFB 0,0,0,0
DEFS 17
;--CP/M STACK STORAGE--
CPMSTK: DEFW 0
;--INPUT BUFFER AREA--
INPBUF: DEFB 128 ;BUF LENGTH
BUFCNT: DEFB 0 ;CHRS IN BUF
DEFS 128
;--STACK AREA--
DEFS 20 ;SIZE OF STACK
STACK: EQU 0 ;BOTTOM OS STACK
END
UF LENGTH
BUFCNT: DEFB 0 ;CHRS IN BUF
DEFS 128
;--STACK A