home *** CD-ROM | disk | FTP | other *** search
- ;************************************************************
- ; ENTER.ASM
- ;
- ;
- ; A program to store text in a file.
- ; Enter one and a half lines of text,
- ; terminated by a CR, per record.
- ; to exit, type two returns.
- ;
- ; This file is based heavily on a
- ; program taken from THE SOLE OF CP/M
- ; by David Brown, Studio City, CA
- ;
- ; TERMINAL SPECIFIC STUFF FOR FREEDOM 50
- ;
- ;
- ;
- ;
- ;
- openf equ 0fh ;open file
- makef equ 16h ;read string
- reads equ 0ah ;write sequential record
- writer equ 15h ;writes sequential record
- readr equ 14h ;read sequential record
- prints equ 9h ;print string
- closef equ 10h ;close file
- conout equ 2h ;console out
- bdos equ 5h ;operating system entry
- fcb equ 5ch ;file control block
- dma equ 80h ;dma buffer
- del equ 0ffh ;delete character
- lf equ 0ah ;linefeed
- cr equ 0dh ;carriage return
- ;
- ;
- org 100h
- ;
- ;try to open file (name must already be in fcb)
- mvi c,openf ;open file
- lxi d,fcb
- call bdos
- inr a ;if a was ff, now it's 0
- jnz alex ; not 0, so file exists
- ;
- ;file does not already exist, so we'll create it
- mvi c,makef
- lxi d,fcb
- call bdos
- ;
- ;fill the dma buffer with delete marks
- newrc lxi h,dma ;put dma address in hl
- mvi b,128d ;put count in b
- loop mvi m,del ;store delete in memory
- ;
- ;
- inx h ;increment hl pointer
- dcr b ;decrement count
- jnz loop
- ;
- ;print a linefeed
- mvi c,conout
- mvi e,lf
- call bdos
- ;
- ;read characters into buffer from keyboard
- mvi a,128d ;set count to 128 characters
- sta dma-2 ; (string buffer starts 2
- mvi c,reads ; bytes before dma
- lxi d,dma-2 ; buffer, to leave room for
- call bdos ; max-count and count)
- ;
- ;find out if buffer is empty-if so, exit
- lda dma-1 ;get number of char input
- ora a ;is it 0?
- jz finito ; yes
-
- ;
- ;insert cr and lf in buffer following text
- mov e,a ;character count in de
- mvi d,0 ;
- lxi h,dma ;dma address in hl
- dad d ;add count to addr, put in hl
- mvi m,cr ;store carriage return
- inx h ;increment pointer
- mvi m,lf ;store linefeed
-
- ;
- ;write record to disk
- mvi c,writer ;write it
- lxi d,fcb
- call bdos
- jmp necch ;go to necch; clear scrn and signon w/banner*
- ;
- ;close filel before exiting
- finito mvi c,closef
- lxi d,fcb
- call bdos
- jmp clearit ;goto clear screen before ret
- ;
- ;file already exits, so read till EOF
- ;
- ;
- alex mvi c,prints ;print message
- lxi d,almess
- call bdos
- read2 mvi c,readr ;read record
- lxi d,fcb
- call bdos
- è ora a ;end-O-file (a not 0) ?
- jz read2 ;no, so read next record
- jmp newrc ;yes, so write the bastard!
- ;
- ;
- ;necch
- necch mvi c,closef
- lxi d,fcb
- call bdos
- mvi c,prints ; prints message
- lxi d,almess
- call bdos
- jmp read2
-
- ;
- ;clearit
- clearit mvi c,prints ;prints message
- lxi d,clearsn
- call bdos
- ret ;drop back to cpm
-
- ;
- ;
- almess db 27,42 ;blow away screen
- db 27,119 ; set up for setting intensity per char
- db 27,93,56 ;row 1, col 25 -- to center, I hope
- db 27,71,52 ; set intensity to full blast
- db 'F r e e B a s e II'
- db 27,71,48 ; shut off intensity
- db cr,lf
- db cr,lf
- db 27,93,56 ;same as above -- to center
- db ' DATA ENTRY PROGRAM'
- db cr,lf,cr,lf
- db cr,lf
- db 27,93,56 ;row 1, col 25, too
- db cr,lf
- db 'Type whatever you like, in any order you wish -- '
- db 'up to a line '
- db cr,lf,'and a half -- or 127 characters.'
- db cr,lf
- db cr,lf
- db cr,lf
- db 27,91,41 ; 8th line, col 1
- db 27,113
- db '|__________________________________________________________'
- db '_____________________'
- db cr,lf
- db '--------------------------------------------->|'
- db cr,lf
- db 27,114
- db 7
- db ' End 2nd line Here ^'
- db cr,lf
- db cr,lf
- è db ' ============================================='
- db cr,lf,cr,lf
- db ' Press {RETURN} After Record is Entered'
- db cr,lf
- db ' Press {Return) Twice to Exit'
- db cr,lf,cr,lf
- db ' To Search for Information, Enter: '
- db cr,lf
- db ' A>SEARCH [D:] File.Type'
- db cr,lf
- db ' ============================================='
- db 27,91,39 ;return to scene of crime...
- db cr,lf,'$'
- ;
- clearsn db 27,42,'$'
- ;
- end