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
/
ZSYS
/
SIMTEL20
/
SYSLIB
/
STEST.LBR
/
STEST007.Z80
< prev
next >
Wrap
Text File
|
2000-06-30
|
5KB
|
234 lines
;
; Program: STEST007
; Author: Richard Conn
; Date: 16 Jan 84
; Version: 1.0
; Previous Versions: None
;
;
; The purpose of STEST007 is to exercise and test the SFXIO routines.
; STEST007 creates a file, allows the user to type lines into it, and
; then closes it. It then reopens it and prints it back to the user.
;
;
; Constants
;
cr equ 0dh
lf equ 0ah
ctrlz equ 'Z'-'@'
;
; Library Routines Used
;
ext fx$get,fx$put,fxi$close,fxi$open,fxo$close,fxo$open
ext fname,bbline
ext version
ext pafdc ; print A as floating decimal chars
ext phlfdc ; print HL as floating decimal chars
ext safdc
ext shlfdc
ext print
ext cin,cout,caps,crlf
ext csout,sprint,sctlfl,sout
ext codend
ext fillb
;
; Beginning of Program -- Print banner
;
call print
db 'STEST007 using SYSLIB Version ',0
call version
ld a,h
call pafdc ; print major version number
ld a,'.'
call cout
ld a,l
call pafdc ; print minor version number
call print
db cr,lf,' -- Testing SFXIO and SCTLFL Output',cr,lf,0
;
; Get name of file
;
mainloop:
call print
db 'Name of File (RETURN to Exit)? ',0
ld a,0ffh ; capitalize line
call bbline ; get response from user
or a ; any chars?
ret z
call crlf
ld de,iocfcb ; pt to fcb of file
call fname ; extract file name
call codend ; get first byte of free space to use for
ex de,hl ; ... buffer in DE
ld hl,ioctl ; set user-provided I/O Control Values
ld (hl),16 ; 16 128-byte blocks (2K)
ld bc,6 ; skip 6 bytes
add hl,bc
ld (hl),e ; store I/O Buffer address
inc hl
ld (hl),d
ld de,ioctl ; pt to I/O Control Block
call fxo$open ; open file for output
jp nz,ml0 ; no error
call print
db 'Error -- Cannot Create File',0
ret
;
; Set for printer and console or just console output
;
ml0:
ld a,1 ; set just console
ld (sctlfl),a ; set SYSLIB flag
call print
db 'Do you want output to go to the printer as well (Y/N)? ',0
call cin ; get response
call caps ; capitalize
call cout ; echo
call crlf ; new line
cp 'Y' ; yes?
jp nz,ml1
ld a,81h ; set printer and console
ld (sctlfl),a
;
; Prompt for input
;
ml1:
call print
db 'Input Lines (End with just RETURN) --',cr,lf,0
ld hl,0 ; set line counter
ld (lcount),hl
;
; Get lines from User
;
ml2:
ld hl,(lcount) ; increment and print line number
inc hl
ld (lcount),hl
call phlfdc ; print with floating decimal
call print
db '. ',0
xor a ; no caps
call bbline ; get input from user
or a ; any input?
jp z,ml4
call crlf
;
; Copy Line into Output File
;
ld de,ioctl ; DE pts to I/O Control Block
ml3:
ld a,(hl) ; get byte
or a ; done?
jp z,ml3a
call fx$put ; put byte (I/O Control Block pted to by DE)
jp z,werr
inc hl ; pt to next
jp ml3
ml3a:
ld a,cr ; put <CRLF> to file
call fx$put
jp z,werr
ld a,lf
call fx$put
jp z,werr
jp ml2
;
; Error in writing to file
;
werr:
call print
db cr,lf,'Error -- FX$PUT can''t write to file',0
ret
;
; Close Output File
;
ml4:
ld de,ioctl ; pt to I/O Control Block
call fxo$close ; close file
jp nz,ml4a
call print
db cr,lf,'Error -- FXO$CLOSE can''t close output file',0
ret
;
; Open file and print to user
;
ml4a:
ld hl,0
ld (lcount),hl ; set line count
call sprint ; print to console and/or printer
db cr,lf,'---------------------',cr,lf,0
call sprint
db 'STEST007 using SYSLIB ',0
call version
ld a,h
call safdc
ld a,'.'
call sout
ld a,l
call safdc
call sprint
db cr,lf,0
ld de,ioctl ; open file
call fxi$open
jp nz,ml5
call print
db cr,lf,'Error -- FXI$OPEN can''t open input file',0
ret
;
; Read from file until end
;
ml5:
call sprint
db 'File output --',cr,lf,0
ml5a:
ld hl,(lcount) ; increment and print line count
inc hl
ld (lcount),hl
call shlfdc ; print as floating
call sprint
db '. ',0
ml5b:
call fx$get ; get next byte
jp z,ml6 ; past EOF?
cp ctrlz ; check for CTRLZ also
jp z,ml6 ; at EOF
call csout ; send char to console/printer with tab exp
cp lf ; new line?
jp z,ml5a
jp ml5b
;
; Done with read
;
ml6:
call fxi$close ; close file
jp nz,ml7
call print
db cr,lf,'Error -- FXI$CLOSE can''t close input file',0
ret
ml7:
call sprint
db cr,lf,cr,lf,'--> End of Output <--',cr,lf,cr,lf,0
jp mainloop
;
; Buffers
;
lcount:
ds 2 ; line count
;
; I/O Control Block
;
ioctl:
ds 8 ; 8 bytes for basic overhead
iocfcb:
ds 36 ; 36 bytes for FCB
end