home *** CD-ROM | disk | FTP | other *** search
- ;
- ; IFNOT.ASM Version 1.0 May 25, 1987
- ;
- ; Note: This program requires CP/M Plus (CP/M 3.0) and a Z80 CPU.
- ;
- ; USAGE: IFNOT {d:}<fn.ft>
- ;
- ; If a drive specification is not given, the default drive is
- ; assumed. If a filename is not given, "No Filename Specified"
- ; will be reported and a "failure" code will be sent to the BDOS.
- ; If the file is found and it is not zero length, "File Found"
- ; will be reported and a "failure" code will be sent to the BDOS.
- ; If the specified file is not found on the drive, or if the file
- ; is a zero length file, the situation will be reported and no
- ; return code will be sent to the BDOS.
- ;
- ; In a SUBMIT (.SUB) file or in a multiple command line a command
- ; that has a colon as the first character is ignored if the
- ; previous command returns a "failure"code; otherwise it is
- ; executed normally. Thus, if IFNOT finds the file on the specified
- ; drive, the following conditional command WILL NOT be executed.
- ; Remember:
- ;* ifnot filename [exists]!:command [will not be executed]
- ;
- ; Gene Pizzetta CompuServe: 72060,505
- ; 481 Revere Street QuantumLink: GeneP
- ; Revere, MA 02151 FOG #29: (617) 288-4667
- ; Voice: (617) 284-0891
- ;
- ; Assemble with MAC and load with HEXCOM. Z80.LIB required.
- ; Note: The line above marked with an * will generate an error
- ; message, but it causes no harm.
- ;
- Bdos equ 05h ; BDOS entry
- WBoot equ 00h ; warm boot
- TPA equ 0100h ; program load address
- Fail equ 0FF00h ; program failure code
- ;
- ; file control block
- ;
- Fcb equ 05Ch ; default file control block
- FcbDr equ Fcb ; drive
- FcbName equ Fcb+1 ; filename
- FcbType equ Fcb+9 ; filetype
- FcbEx equ Fcb+12 ; extent
- FcbRc equ Fcb+15 ; record count
- FcbCr equ Fcb+32 ; current record
- FcbR0 equ Fcb+33 ; random record, LSB
- FcbR1 equ Fcb+34 ; random record, middle byte
- FcbR2 equ Fcb+35 ; random record, MSB
- ;
- ; BDOS service functions
- ;
- PrtStr equ 9
- GetStr equ 10
- FOpen equ 15
- FClose equ 16
- FRead equ 20
- SetDma equ 26
- FSize equ 35
- FMulti equ 44
- BdosRet equ 108
- FParse equ 152
- ;
- LF equ 0Ah ; linefeed
- CR equ 0Dh ; carriage return
- ;
- MACLIB Z80
- ;
- org TPA
- jmp MAIN
- ;
- Msg1: db 'IFNOT 1.0 -- $'
- Msg2: db 'No Filename Specified -- $'
- Msg3: db 'Ignore Conditional$'
- Msg4: db 'Execute Conditional$'
- Msg5: db 'Zero Length File -- $'
- Msg6: db 'File Not Found -- $'
- Msg7: db 'File Found -- $'
- ;
- MAIN: lxi d,Msg1 ; print sign-on
- mvi c,PrtStr
- call Bdos
- lda FcbName ; check for filename
- cpi 'A'
- jrnc ISFILE ; (filename found)
- lxi d,Msg2 ; print 'no file'
- mvi c,PrtStr
- call Bdos
- jr ABORT ; ..and abort
- ;
- ISFILE: lxi d,Fcb ; point to FCB
- mvi c,FSize ; get file size
- call Bdos
- inr a ; does the file exist?
- jrz NOFILE
- lda FcbR0 ; check LSB
- cpi 0 ; greater than zero?
- jrnz FOUND ; (yes, a failure)
- lda FcbR1 ; check middle byte
- cpi 0
- jrnz FOUND
- lda FcbR2 ; check MSB
- cpi 0
- jrnz FOUND
- lxi d,Msg5 ; it must be a null file
- mvi c,PrtStr ; ..so print message
- call Bdos
- jr SUCC ; ..and report success
- ;
- NOFILE: lxi d,Msg6 ; print 'not found'
- mvi c,PrtStr
- call Bdos
- jr SUCC ; ..and report success
- ;
- FOUND: lxi d,Msg7 ; print 'file found'
- mvi c,PrtStr
- call BDOS
- jr ABORT ; ..and abort
- ;
- ABORT: lxi d,Fail ; send 'failure' code
- mvi c,BdosRet
- call Bdos
- lxi d,Msg3 ; ..and print failure message
- mvi c,PrtStr
- call Bdos
- jr EXIT
- ;
- SUCC: lxi d,Msg4 ; print success message
- mvi c,PrtStr
- call Bdos
- ;
- EXIT: jmp WBoot ; warm boot
- ;
- end