home *** CD-ROM | disk | FTP | other *** search
- title 'CP/M Plus MAKE utility - reading from file'
-
- page 58
-
- public PARSMF ; parse make filename into FCB, <A> = error code
- public OPENMF ; open make file, <A> = error code
- public UNGETC ; store char in <A> back into file
- public GETC ; get one char from file into <A>
- public CLOSMF ; close make file, return EOF in <A>
-
- extrn PARFCB ; parse name at <HL> into FCB at <DE>
- extrn GUSER ; return actual user number in <A>
- extrn NEXT ; call BDOS via RSX chain
- extrn UBDOS ; call BDOS with user number at (DE)-1
-
-
- ; constant definitions
-
- FALSE equ 0 ; boolean constants
- TRUE equ not FALSE
- OPENF equ 15 ; open file (FCB at .DE)
- CLOSEF equ 16 ; close file (FCB at .DE)
- READSQ equ 20 ; read sequential from file (FCB at .DE)
- SETDMA equ 26 ; set DMA address := <DE>
- SETMUL equ 44 ; set multi-sector-count := <E>
- GSSCB equ 49 ; get/set System Control Block
- EOF equ 26 ; end of file mark (CTRL-Z)
- COMLINE equ 80h ; CCP command tail
-
-
- ; parse file name of make file
-
- cseg
- PARSMF: lxi h,COMLINE+1 ; address of ASCIIZ string
- lxi d,make$FCB ; address of destination FCB
- jmp PARFCB
-
-
- ; open make file
-
- cseg
- OPENMF: lda make$user ; is user number of make file set?
- ora a
- jnz open$passw
-
- call GUSER ; get actual user number in <A>
- inr a ; store user number(+1) into make FCB
- sta make$user
-
- open$passw: lxi d,make$passw ; set password for OPENF call
- mvi c,SETDMA
- call NEXT ; we mean BDOS, in fact
-
- lxi d,make$fcb ; address of make file fcb
- mvi c,OPENF ; open file
- jmp UBDOS ; with user number support
-
-
- ; one character from <A> back into make file
-
- cseg
- UNGETC: sta char$store ; save char
- mvi a,TRUE ; set flag
- sta char$flag
- ret
-
-
- ; read a character from make file into <A>
-
- cseg
- GETC$new: xra a ; begin with new record
- sta make$index
-
- GETC: lda char$flag ; waiting char from ungetc ?
- ora a
- jz GETC$next ; no : read one from record buffer
-
- mvi a,FALSE ; clear storage flag
- sta char$flag
- lda char$store ; take char from storage
- ret
-
- GETC$next: lda make$index ; index into record buffer
- ora a ; exhausted ?
- jm GETC$more
-
- mov e,a ; -> DE
- mvi d,0
- lxi h,make$DMA ; + start address of DMA buffer
- dad d ; HL points into make DMA buffer
-
- inr a ; update index
- sta make$index
-
- mov a,m ; char into <A>
- cpi EOF ; last char ?
- jz CLOSMF ; yes : close make file
- ret
-
-
- ; read next sector from make file
-
- cseg
- GETC$more: mvi c,SETDMA ; set DMA address to makefile buffer
- lxi d,make$DMA
- call NEXT
-
- mvi c,GSSCB ; get actual multi-sector-count
- lxi d,get$multio
- call NEXT
- push h ; save count in <L>
-
- mvi c,SETMUL ; reset multi-sector count
- mvi e,1
- call NEXT
-
- mvi c,READSQ ; read next sector of make file
- lxi d,make$FCB
- call UBDOS ; with user number support
-
- pop d ; <E> := old multi-sector-count
- push psw ; save error code of READSQ
- mvi c,SETMUL ; restore old multi-sector-count
- call NEXT
-
- pop psw
- ora a ; end of file or other error ?
- jz GETC$new ; no: read first char of next record
-
-
- ; close make file, returning EOF in <A>
-
- cseg
- CLOSMF: mvi c,CLOSEF ; close make file
- lxi d,make$FCB
- call UBDOS ; with user number support
-
- mvi a,EOF ; return EOF to caller
- ret
-
-
- ; data segment for file procedures
-
- dseg
- make$user: ds 1 ; user number(+1) of make file
- make$FCB: ds 36 ; FCB of make file
- make$passw: ds 8 ; password of make file
- make$index: db 128 ; index into make file record
- make$DMA: ds 128 ; dma buffer for make file
- char$flag: db FALSE ; set if character waiting in char$store
- char$store: ds 1 ; waiting char for GETC
- get$multio: db 4Ah ; offset of multi-sector-count
- db 0
- end
-