DataMuseum.dk

Presents historical artifacts from the history of:

CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦2d6751d2d⟧ TextFile

    Length: 56192 (0xdb80)
    Types: TextFile
    Names: »EENTRY.MAC«

Derivation

└─⟦77f87173f⟧ Bits:30005981/disk3.imd Turn Key Data Entry System/Datenerfassungspaket - Vers. 1.90
    └─⟦this⟧ »EENTRY.MAC« 

TextFile

;*************************************************
;*                                               *
;*	MODULE : EENTRY.MAC        (RC-700)      *
;*	DATE   : 01.02.82                        *
;*	BY     : ASE GmbH , 6472 Altenstadt      *
;*	VERSION: 1.90                            *
;*                                               *
;*************************************************
;
; THIS IS THE KEYSTROKE-PROCESSING MODUL WHICH HANDLES ALL
; KEYSTROKES AND FUNCTION-KEYS BASED ON THE FIELD-DESCRIPTIONS
; IT IS USED IN ALL MODES EXCEPT 'FORMAT' AND 'FORMAT-UPDATE'.
;
	INCLUDE B:EKBEQU.MAC	;include all the keyboard equates
	INCLUDE B:EPUB/EXT.MAC	;include all the public's and externals
;
;
;the following mainly checks for a legal field number and
;builds up the field oriented pointers to the 3 main buffers:
;format-buffer, user-buffer, crt-buffer
;
ENTRY:	ld	a,(CLRFLG)	;test the
	cp	0ffh		;clear key flag
	jp	z,CLRKY1	;its set.
	ld	a,00h		;
	ld	bc,R0FLG	;
	ld	hl,25		;
	call	INBUFF		;clear all the register flags
	ld	a,0ffh		;
	ld	(STRFLG),a	;set start of field flag
	ld	hl,(BFNO)	;get binary field number
	ld	bc,0h		;
	and	a		;
	sbc	hl,bc		;
	jp	nz,ENTRY8	;
	ld	a,(DEMODE)	;
	cp	05h		;format-data mode?
	jp	nz,FLDZRO	;ret to user if not.
ENTRY8:	ld	hl,(BFNO)	;
	ld	de,(VFCTR)	;
	and	a		;
	ex	de,hl		;
	sbc	hl,de		;compare with max.no of fields
	jp	m,ILLFNO	;illegal field number
	ex	de,hl		;
	ld	a,(DEMODE)	;
	cp	02h		;update-mode?
	jp	z,UPDMV		;yes.
	cp	05h		;format-data mode?
	jp	z,UPDM15	;yes.
ENTRY6:	dec	hl		;align with fpt-entry zero
	add	hl,hl		;x2
	add	hl,hl		;x4
	ld	de,FPTTAB	;derive buffer
	add	hl,de		;addresses
	ld	c,(hl)		;
	inc	hl		;
	ld	b,(hl)		;
	ld	(SOFFBA),bc	;from
	inc	hl		;the
	ld	c,(hl)		;
	inc	hl		;field pointer table
	ld	b,(hl)		;
	ld	hl,0ffffh	;
	and	a		;
	sbc	hl,bc		;
	jp	z,ENDFLD	;end of format reached!
	ld	(SOFUBA),bc	;
	ld	de,(FBFADD)	;calculate
	ld	hl,(SOFFBA)	;crt - start
	and	a		;
	sbc	hl,de		;format buffer address
	ld	de,(CBFADD)	;
	add	hl,de		;
	ld	(SOFCBA),hl	;
;
;the following will wether a record is to be displayed on the crt
;during update-mode before allowing entry.
;
	ld	a,(DEMODE)	;
	cp	02h		;
	jp	z,UPDMV9	;test for updatemode-move.
;
	cp	05h		;
	jp	z,UPDMV9	;go on format-data mode.
	ld	a,(CAVFLG)	;
	cp	0ffh		;clear all var.flds flg set?
	ret	z		;ret if it is.
;
;the following will check for an FSB in the format
;this check will be bypassed if fieldstart is equal buffer-start.
;
ENTRY7:	ld	hl,(SOFFBA)	;
	ld	bc,(FBFADD)	;
	and	a		;
	sbc	hl,bc		;fieldstart = start of formatbuffer?
	jp	z,ENTRY3	;yes,bypass FSB-check.
	ld	hl,(SOFFBA)	;
	dec	hl		;
	ld	c,(hl)		;get FSB (if it is one)
	ld	a,0fh		;
	and	c		;mask out upper 4 bits
	cp	02h		;display-only field?
	jp	z,TSTFLD	;yes.
	cp	04h		;no-display/no-modify field?
	jp	z,TSTFLD	;yes.
	cp	03h		;
	jp	z,SETF03	;update-only field.
	cp	06h		;duplicate-format field?
	jp	nz,ENTRY4	;bypass if not.
	ld	a,0ffh		;
	ld	(DFFLG),a	;set duplicate-format flag
ENTRY4:	ld	a,0h		;
	ld	(F03FLG),a	;clear the flag
;
;the following will test the bit-mask for the current field
;if bit set cursor movement will be allowed over the full 
;field. if not the bit in the mask will be set.
;
ENTRY3:	call	TSBMSK		;test the field-mask bit
	cp	0ffh		;
	jp	z,ENTRY1	;go if bit set.
	ld	a,0ffh		;
	ld	(RESFLG),a	;
	ld	hl,0h		;
	ld	(BCPCTR),hl	;
	call	STBMSK		;
	jp	ENTRY2		;
ENTRY1:	ld	a,0h		;
	ld	(RESFLG),a	;
	ld	(MTCFLG),a	;
	ld	hl,(BFNO)	;
	ld	bc,(RESSV1)	;
	 and	a		;
	sbc	hl,bc		;
	jp	nz,ENTRY2	;actual and saved fno dont match.
	ld	hl,(RESSV2)	;
	ld	(BCPCTR),hl	;
	ld	a,0ffh		;
	ld	(RESFLG),a	;
	ld	(MTCFLG),a	;
;
;the following presets and clears vaious flags
;
ENTRY2:	ld	a,0ffh		;
	ld	(ENTFLG),a	;set entry-mode flag
	ld	hl,0		;clear the
	ld	(FILCTR),hl	;field length counter
	ld	(MXFLNG),hl	;
	ld	a,0		;
	ld	(FBFLG),a	;clear the fwd-flag
	ld	(FFLG),a	;clear the fwd-flag
	ld	(CADFLG),a	;
	ld	(FNFLG),a	;clear function-key flag
	ld	(VRTCTR),a	;clear verify retry ctr
	ld	(MFFLG),a	;clear must fill flag
	ld	(EFRCHD),a	;clear end-of-field-reached flag
	ld	a,(DFFLG)	;
	cp	0ffh		;
	jp	z,DFFLD		;go if duplicate format flag set.
;
;
;the following (thru to ENTRY5) will fill the field on crt with
;periods after it has been verify/field corrected in verify mode
;to allow succeding verifying of the corrected field
;
	ld	a,(VCRPSS)	;verify/field correction pass flag set?
	cp	0ffh		;
	jp	nz,ENTRY5	;
	call	SVEBFF		;save the buffers
	ld	a,0ffh		;
	ld	(INTFLG),a	;set intflag
ENTRY9:	ld	hl,(SOFCBA)	;
	ld	a,2eh		;
	ld	(hl),a		;display period 
	call	NXTFDB		;
	call	GENFSB		;
	cp	0ffh		;
	jp	z,ENTR10	;end of field
	cp	20h		;
	jp	z,ENTR10	;end of field
	jp	ENTRY9		;
ENTR10:	call	RSTBFF		;restore the buffers
	ld	a,00h		;
	ld	(INTFLG),a	;
;
;THE FOLLOWING WILL SET THE CURSOR TO START OF FIELD
;
ENTRY5:	call	INCCRS		;
;
;the following will read and test the field - start/continuation byte.
;
NXTLPE:	call	GENFSB		;
	cp	0ffh		;FSB ?
	jp	z,EFT   	;yes , means end of field.
	cp	20h		;space?
	jp	z,EFT   	;yes ,end of field
	cp	55h		;00-1fh ?
	jp	z,ILLFRM	;format error.
	cp	00h		;21-2f ?
	jp	z,CNTFDB	;could be field cont.character.
	cp	01		;could be a register (alpha range)
	jp	z,REGCHK	;
	cp	02		;Field start byte or register ?
	jp	z,TSTFDB	;
	jp	ILLFRM		;bad format !
SETMSG:	ld	a,85h		;
	call	DSPMSG		;set entry-ready message
;
;the following will read acharacter from the keyboard, unless
;the current field is a duplication-field.
;
GETCHR:	ld	a,0h		;
	ld	(CADFLG),a	;
	ld	a,(DUPFLG)	;
	cp	0ffh		;dup-flag set?
	jp	z,DUPFLD	;yes.
	call	CHRRD		;get character from keyboard
;
;the following will analyse the class of character just received
;from the keyboard and branch to the respective routines.
;
GETCH1:	call	CHKBTE		;check range of character
	cp	02h		;normal alpha ?
	jp	z,ALPCHR	;yes
	cp	01h		;normal numeric ?
	jp	z,NUMCHR	;yes
	cp	0ffh		;function key ?
	jp	z,FNKEY		;yes
	CP	55H		;CTRL KEY FUNCTION ?
	JP	Z,FNKEY		;YES.
	cp	20h		;space ?
	jp	z,ALPCHR	;yes
	cp	00h		;special characters ?
	jp	z,ALPCHR	;yes
	jp	KEYERR		;anything else is an error.
;
;the following will increment the buffer pointers and branch
;for the processing of the next character.
;
NXTCHR:	call	NXTFDB		;step to next position.
	JP	NXTLPE		;LOOP FOR NEXT CHARACTER
;
;
;whenever the application programm addresses field zero (not existant)
;the following will set the cursor to the last position on the
;crt,set field-number to 1 and return to the user-interface.
;
FLDZRO:	ld	hl,1921		;
	ld	(SOFCBA),hl	;
	call	INCCRS		;
	ld	hl,1h		;
	ld	(BFNO),hl	;set field no. to 1.
	jp	ENTCPL		;
;
;
;the following will inc the field length ctr and dec the field backward
;position counter (if not zero)
;
ASCE14:	ld	a,(SKPFLG)	;
	cp	0ffh		;skip flag set?
	jp	z,ASCE15	;yes,bypass incr.the FILCTR
	ld	a,(EFRCHD)	;
	cp	0ffh		;end of format flag set?
	jp	nz,ASCE25	;bypass if end-of-field has been reachd
	ld	bc,(FILCTR)	;
	ld	hl,(MXFLNG)	;
	and	a		;
	sbc	hl,bc		;
	jp	z,ASCE15	;bypass incrementing the Field length.
ASCE25:	ld	bc,(FILCTR)	;inc the
	inc	bc		;field length counter
	ld	(FILCTR),bc	;
ASCE15:	ld	hl,(BCPCTR)	;
	ld	de,0h		;
	and	a		;
	sbc	hl,de		;
	ret	z		;
	dec	hl		;dec bcpctr if not zero.
	ld	(BCPCTR),hl	;
	ret			;
;
;
;depending on the mode in use , the following will update the 
;statistical counters and write the entered character to the 
;screen and user-buffer.
;
ASCENT:	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	z,ASCEN3	;yes.
	cp	00h		;entry mode?
	jp	nz,ASCE10	;go, if not.
	ld	hl,(NKECTR)	;
	inc	hl		;inc
	ld	(NKECTR),hl	;the # of keys entered
ASCE10:	ld	hl,(SOFUBA)	;
	ld	(hl),c		;store character in user buffer
ASCEN5:	ld	hl,(SOFCBA)	;
	ld	a,(F03FLG)	;FSB03-flag set?
	cp	0ffh		;
	jp	z,ASCEN2	;yes.
	call	CHRCNV		;convert char and store to crt
	ld	a,(EFTFLG)	;
	cp	0ffh		;
	jp	z,NXTCHR	;
	call	ASCE14		;
	jp	NXTCHR		;
;
ASCEN2:	ld	a,2eh		;
	ld	(hl),a		;display period in place of character.
	ld	a,(EFTFLG)	;
	cp	0ffh		;
	jp	z,NXTCHR	;
	call	ASCE14		;
	jp	NXTCHR		;
;
ASCEN3:	ld	a,00h		;
	ld	(MINFLG),a	;clear minus-flag
	ld	(POSFLG),a	;clear pos-flag
	ld	a,(F03FLG)	;
	cp	0ffh		;no-display flg set?
	jp	z,EOFLD		;force end of field on verify mode.
	ld	hl,(SOFUBA)	;get char.from userbuffer.
	ld	a,(hl)		;to a-reg.
	cp	c		;compare with keyboard character.
	jp	nz,ASCEN4	;go on no-match.
ASCE16:	ld	a,00h		;
	ld	(VRTCTR),a	;clear the verify-retry ctr.
	ld	hl,(NKVCTR)	;
	inc	hl		;
	ld	(NKVCTR),hl	;inc the # of keys verified.
	jp	ASCEN5		;
;
;comes here on verify mismatch.
;checks for 4th retry.if it isnt will display the full field and
;display the error message.
;
ASCEN4:	ld	a,c		;
	ld	(SGNCHR),a	;save keyboard character
	ld	(KBCHR),a	;here too.
	call	RACHK		;
	cp	0ffh		;right adjust field?
	jp	nz,ASCE13	;
	ld	hl,(SOFUBA)	;
	ld	a,(hl)		;get character from user-buffer
	ld	hl,SGNCHR	;load address
	ld	c,a		;save user buffer char. to c-reg
	call	SGNSET		;get zoned equivalent character
	ld	a,(SGNCHR)	;to a-reg
	cp	c		;match with user buffer character?
	jp	nz,ASCE13	;go if not.
	ld	a,0ffh		;
	ld	(MINFLG),a	;set minus flag
	ld	a,(KBCHR)	;
	ld	c,a		;
	jp	ASCE16		;
ASCE13:	ld	a,(SKPFLG)	;
	cp	0ffh		;
	jp	nz,ASCE22	;
	ld	a,00h		;
	ld	(SKPFLG),a	;
	jp	ASCE23		;
ASCE22:	ld	a,(VRTCTR)	;
	cp	03h		;4th retry on same character?
	jp	z,ASCEN6	;yes.
	inc	a		;
	ld	(VRTCTR),a	;inc the retry ctr
ASCE23:	ld	a,(MINFLG)	;
	cp	0ffh		;
	jp	nz,ASCE17	;
	ld	a,11		;
	call	DSPMSG		;set 'sign-error ' msg
	ld	a,0ffh		;
	ld	(CFLAG),a	;set call flag
	call	KEYER3		;handle error msg procedur
	jp	SETMSG		;and get next keyboard entry
ASCE17:	call	SVEBFF		;save the buffer-pointers.
	ld	a,01h		;
	call	DSPMSG		;set verify-error message
ASCEN8:	ld	a,0ffh		;
	ld	(INTFLG),a	;
	ld	hl,(SOFUBA)	;
	ld	de,(SOFCBA)	;
	ld	a,(hl)		;move char. from user-buffer
	ld	(de),a		;to screen.
	call	NXTFDB		;
	call	GENFSB		;
	cp	0ffh		;
	jp	z,ASCEN9	;end of field.
	cp	20h		;
	jp	z,ASCEN9	;end of field.
	jp	ASCEN8		;
;
;this calls the keyerror routine followed by resetting the
;the field's display .
;
ASCEN9:	ld	a,0ffh		;
	ld	(CFLAG),a	;
	call	KEYER3		;handle the verify-error
	call	RSTBFF		;restore the buffer pointers
ASCE12:	ld	a,0ffh		;
	ld	(INTFLG),a	;set int-flag
	ld	de,(SOFCBA)	;fill up
	ld	a,2eh		;with period.
	ld	(de),a		;
	call	NXTFDB		;
	call	GENFSB		;
	cp	0ffh		;end of field?
	jp	z,ASCE11	;yes.
	cp	20h		;end of field?
	jp	z,ASCE11	;yes.
	jp	ASCE12		;
;
ASCE11:	call	RSTBFF		;restore the buffers
	ld	a,00h		;
	ld	(INTFLG),a	;
	jp	SETMSG		;and ret to the loop.
;
;comes here after the 3rd verify retry.
;
ASCEN6:	ld	a,(MINFLG)	;
	cp	0ffh		;
	jp	z,ASCE18	;handle minus to positive sign correct.
	ld	a,(POSFLG)	;
	cp	0ffh		;
	jp	z,ASCE19	;handle positive to minus sign correct.
	ld	hl,(SOFUBA)	;
	ld	a,(hl)		;get char. from user buffer
	ld	hl,SGNCHR	;
	ld	(hl),a		;
	call	SGNCHK		;check if character zoned.
	ld	a,(KBCHR)	;
	ld	c,a		;keyboard character to c-reg
	ld	a,(ZNSGN)	;
	cp	0ffh		;user buffer char.zoned?
	jp	nz,ASCE21	;go if not.
	ld	hl,KBCHR	;
	call	SGNSET		;xlate kb-char to zoned
	ld	c,(hl)		;
	ld	a,0ffh		;
	ld	(MINFLG),a	;set minus-flag
ASCE21:	ld	hl,(SOFUBA)	;
	ld	(hl),c		;write char. to user-buffer.
	ld	hl,(SOFCBA)	;
	call	CHRCNV		;xlate and store to the crt
	ld	a,0ffh		;
	ld	(VCRFLG),a	;set the verify correction flag
	ld	hl,(VCRCTR)	;
	inc	hl		;
	ld	(VCRCTR),hl	;inc the verify-corr.ctr
	ld	a,00h		;
	ld	(VRTCTR),a	;reste the verify-retry ctr.
	call	ASCE14		;
	jp	NXTCHR		;and join the loop again.
;
;comes here to correct a zoned field to a positive field during
;verify mode.(only on right adjust fields)
;
ASCE18:	ld	hl,(SOFUBA)	;
	call	SGNCHK		;xløate zoned to non-zoned
	ld	a,(hl)		;
	ld	hl,(SOFCBA)	;
	ld	(hl),a		;also correct crt
	ld	a,00h		;
	ld	(MINFLG),a	;clear minus flag
	jp	ASCE20		;
;
;comes here to correct a positive field to a zoned field as above.
;
ASCE19:	ld	hl,(SOFUBA)	;
	call	SGNSET		;xlate positive to zoned
	ld	a,(hl)		;
	ld	hl,(SOFCBA)	;
	ld	(hl),a		;correct also crt
	ld	a,00h		;
	ld	(POSFLG),a	;
;
ASCE20:	ld	a,0ffh		;
	ld	(VCRFLG),a	;set verify correction flag
	ld	hl,(VCRCTR)	;
	inc	hl		;
	ld	(VCRCTR),hl	;inc the verify corr. ctr.
	jp	EOFPRC		;
;
SGNCHR:	db	00h		;
VCRFLG:	db	00h		;verify correction flag
KBCHR:	db	00h		;
;
;the following are used to save and restore the 3 buffer pointers
;for the userbuffer,formatbuffer,crtbuffer.
;
SVEBFF:	ld	(SVEBF0),hl	;save hl-reg
	ld	hl,(SOFUBA)	;
	ld	(SVEBF1),hl	;
	ld	hl,(SOFCBA)	;
	ld	(SVEBF2),hl	;
	ld	hl,(SOFFBA)	;
	ld	(SVEBF3),hl	;
	ld	hl,(SVEBF0)	;restore hl-reg
	ret			;
;
RSTBFF:	ld	(SVEBF0),hl	;
	ld	hl,(SVEBF1)	;
	ld	(SOFUBA),hl	;
	ld	hl,(SVEBF2)	;
	ld	(SOFCBA),hl	;
	ld	hl,(SVEBF3)	;
	ld	(SOFFBA),hl	;
	ld	hl,(SVEBF0)	;
	ret			;
;
SVEBF0:	dw	0000h		;
SVEBF1:	dw	0000h		;
SVEBF2:	dw	0000h		;
SVEBF3:	dw	0000h		;
;
;
;the following routine will be used whenever the end-of-format
;character was found.
;
ENDFLD:	ld	a,0ffh		;
	ld	(EFOFLG),a	;
	ld	a,(DEMODE)	;
	cp	02h		;
	jp	z,ENDFL1	;
	ld	a,(CAVFLG)	;
	cp	0ffh		;
	ret	z		;
ENDFL2:	ld	a,0h		;clear flags and ctr's
	ld	(FFLG),a	;
	ld	(FBFLG),a	;
	ld	(CLRFLG),a	;
	ld	(CBWFLG),a	;
	ld	(F03FLG),a	;
	ld	(FTMFLG),a	;
	ld	a,0ffh		;
	ld	(UPDFLG),a	;
	ld	hl,0h		;
	ld	(BCPCTR),hl	;
	ld	(FILCTR),hl	;
	jp	ENDFRM		;return to user interf. on end of form.
;
ENDFL1:	ld	a,(UPDFLG)	;
	cp	0ffh		;
	ret	z		;
	jp	ENDFL2		;
;
;the following stops the user from leaving the field without
;without using a function key on all right-adjust fields.
;on all other fields the field will be exited.
;
EFT:	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	nz,EOFLD	;go if not
	ld	a,(MINFLG)	;
	cp	0ffh		;minus-flag set?(Zoned)
	jp	nz,EOFLD	;go if not
	call	RACHK		;check for right adjust fields
	cp	00h		;
	jp	z,EOFLD		;go if it isnt.
	ld	a,(EFRCHD)	;
	cp	0ffh		;
	jp	z,EFT1		;
	ld	hl,(FILCTR)	;
	ld	(MXFLNG),hl	;
EFT1:	ld	a,0ffh		;
	ld	(EFRCHD),a	;set end-of-field-reached flag
	ld	a,(CADFLG)	;
	cp	0ffh		;
	jp	z,EOFLD		;
	ld	a,(CBWFLG)	;
	cp	0ffh		;
	jp	z,EOFLD		;
	ld	a,0ffh		;
	ld	(EFTFLG),a	;
	jp	CBWD4		;go character backward.
;
EFTFLG:	db	00h		;
EFRCHD:	db	00h		;end of field reached flag
MXFLNG:	dw	00h		;max.-field-length counted up.
;
;the following handles the end of field .
;
EOFLD:	ld	a,(CADFLG)	;
	cp	0ffh		;
	jp	z,FLADV		;
	ld	a,0ffh		;
	ld	(EFLFLG),a	;
	ld	a,(CBWFLG)	;
	cp	0ffh		;char.backw.flag set?
	jp	z,CBWD2		;yes.
	ld	a,0ffh		;
	ld	(FFLG),a	;
	ld	a,0h		;
	ld	(FBFLG),a	;
	ld	(DUPFLG),a	;
	ld	(INTFLG),a	;
	ld	(EFTFLG),a	;
	ld	(CFLAG),a	;
	call	FLDCHK		;
	ld	a,0h		;
	ld	(EFLFLG),a	;
	ld	a,(FLDERR)	;
	cp	0ffh		;
	jp	nz,REGPRC	;
	ld	a,0		;
	ld	(FLDERR),a	;
	ld	(EFTFLG),a	;
	jp	KEYERR		;
;
EFLFLG:	db	0h		;
;
;
;the following handles the key-errors by setting a message and
;requesting a reset-key (ESC).
;
KEYERR:	ld	a,03h		;set the
KEYER7:	call	DSPMSG		;entry-error message.
KEYER3:	ld	c,07h		;beep the
	call	co		;user
	call	CHRRD		;
	cp	1bh		;escape character
	jp	z,KEYER1	;yes
	ld	a,0ffh		;
	jp	KEYER7		;wait for it
KEYER1:	ld	a,(FNCFLG)	;
	cp	0ffh		;function flag set?
	jp	z,KEYER6	;yes,its set.
	ld	a,(DEMODE)	;
	cp	00h		;entry mode?
	jp	z,KEYER4	;yes.
	cp	01h		;verify mode?
	jp	z,KEYER5	;yes.
KEYER6:	ld	a,00h		;
	ld	(DUPFLG),a	;clear the dup-flag
	ld	(FNCFLG),a	;clear the function-flag
	ld	(INTFLG),a	;clear the Int-flg (preventive measure)
	ld	a,(CFLAG)	;test
	cp	0ffh		;call flag
	jp	z,KEYER2	;its set
	jp	SETMSG		;restore the entry-message and continue
KEYER2:	ld	a,0h		;
	ld	(CFLAG),a	;
	ret			;
;
KEYER4:	ld	hl,(EERCTR)	;
	inc	hl		;
	ld	(EERCTR),hl	;inc the entry-error ctr.
	jp	KEYER6		;
;
KEYER5:	ld	hl,(VERCTR)	;
	inc	hl		;
	ld	(VERCTR),hl	;inc the verify-error ctr.
	jp	KEYER6		;
;
;
;
ENTFLG:	ds	1		;entry-mode flag
;
;the following will analyse the function-key received from
;the keyboard and branch off to the respective routine.
;
FNKEY:	ld	a,0ffh		;
	ld	(FNFLG),a	;set function key flag
	ld	a,c		;character to a
	cp	CHRADV		;character advance?
	jp	z,CADV		;yes
	cp	CHRBWD		;character backward?
	jp	z,CBWD		;yes.
	cp	CTRLQ		;quit?
	jp	z,USRABT	;yes
	cp	HOME		;home?
	jp	z,HME		;yes.
	cp	CLRKEY		;
	jp	z,CLRREC	;yes clear key.
	cp	FADV		;field advance?
	jp	z,FLADV		;yes.
	cp	FBWD		;field backward?
	jp	z,FLBWD		;yes
	cp	CARTN		;carriage return?
	jp	z,SKRRAC	;check for skip/right adjust
	cp	CTRLK		;modify format chain key?
	jp	z,FMTCHK	;yes.
	cp	CTRLD		;dup-field?
	jp	z,DUPFLD	;yes.
	cp	NUMDUP		;additional dup-key (pf1) ?
	jp	z,DUPFLD	;yes.
	cp	CTRLA		;override-dup function?
	jp	z,OVRDUP	;yes.
	cp	FLDCRR		;field correction?
	jp	z,FCORR		;yes.
	cp	CTRLFR		;record-advance?
	jp	z,RECFOB	;yes
	cp	CTRLBR		;record-backward?
	jp	z,RECFOB	;yes.
	cp	CTRLZ		;insert record ?
	jp	z,INSREC	;yes.
	cp	CTRLC		;send key?
	jp	z,SNDCHK	;yes.
	cp	DCD		;display check digit?
	jp	z,DSPCD		;yes.
	cp	RGDSP		;display register?
	jp	z,DSPREG	;yes.
	ld	a,0ffh		;
	ld	(FNCFLG),a	;set function flag.
	ld	a,00h		;
	ld	(FNFLG),a	;clear function key flag
	jp	KEYERR		;must be an illegal function
FNFLG:	db	00h		;function key flag
;
;
;the following handles the character-advance function key.
;
CADV:	ld	a,0ffh		;
	ld	(CADFLG),a	;
	ld	a,(DEMODE)	;
	cp	02h		;update mode?
	jp	nz,OTMODE	;no , other mode's
CHRAD1:	jp	CHRAD2		;
OTMODE:	ld	a,(RESFLG)	;
	cp	0h		;
	jp	z,CHRAD2	;
	ld	hl,0h		;
	ld	bc,(BCPCTR)	;
	and	a		;
	sbc	hl,bc		;backward pos.ctr zero?
	jp	z,KEYERR	;yes it is,dont allow advance.
CHRAD2:	ld	hl,00h		;
	ld	bc,(BCPCTR)	;
	and	a		;
	sbc	hl,bc		;
	jp	z,CHRAD3	;
	ld	bc,(BCPCTR)	;
	dec	bc		;
	ld	(BCPCTR),bc	;decr.backw.pos ctr
CHRAD3:	ld	bc,(FILCTR)	;
	inc	bc		;
	ld	(FILCTR),bc	;inc the field length counter
	jp	NXTCHR		;
;
CADFLG:	db	00h		;
;
;the following handles the character-backward function key.
;
CBWD:	ld	a,(EFLFLG)		;
	cp	0ffh			;
	jp	nz,CBWD7		;
	ld	hl,01h			;
	ld	bc,(FILCTR)	;
	and	a		;
	sbc	hl,bc		;go only if end-of-field-reached
	jp	nz,CBWD7	;bypass if not
	jp	CBWD1		;
CBWD7:	ld	bc,(FILCTR)		;
	ld	hl,0h			;
	and	a		;
	sbc	hl,bc		;field pos.ctr = zero ?
	jp	z,CBWD1		;field crossing needed
	dec	bc		;
	ld	(FILCTR),bc	;dec field pos. ctr.
	ld	a,00h		;
	ld	(EFLFLG),a	;
	ld	hl,00h		;
	and	a		;
	sbc	hl,bc		;
	jp	nz,CBWD6	;
	ld	a,0ffh		;
	ld	(STRFLG),a	;set the field start flag again.
CBWD6:	ld	bc,(BCPCTR)	;
	inc	bc		;inc the backward pos.ctr.
	ld	(BCPCTR),bc	;
CBWD4:	ld	bc,(SOFCBA)	;
	dec	bc		;dec the 
	dec	bc		;crt buffer by two
	ld	(SOFCBA),bc	;
	ld	bc,(SOFFBA)	;
	dec	bc		;dec the
	dec	bc		;format buffer address
	ld	(SOFFBA),bc	;by two.
	ld	bc,(SOFUBA)	;
	dec	bc		;dec the
	dec	bc		;user buffer address
	ld	(SOFUBA),bc	;by two.
	jp	NXTCHR		;
;
;this handles field-backward crossing on character backward.
;
CBWD1:	ld	hl,(BFNO)	;
	ld	bc,1h		;
	and	a		;
	sbc	hl,bc		;check for field 1/pos.1.
	jp	z,GETCHR	;ignore CBWD if it is.
	ld	a,0ffh		;
	ld	(CBWFLG),a	;set character backward flag
	ld	(INTFLG),a	;set int-flag to inhibit cursor movem.
	ld	a,00h		;
	ld	(EFLFLG),a	;clear the end of field flag
	jp	FLBWD		;exit via field backward.
;
;control comes back here after field-backward resulting from
;previous character-backward has been issued by the application
;program.
;
CBWD2:	ld	a,(EFLFLG)	;
	cp	0ffh		;end of field flag set?
	jp	z,CBWD3		;yes.
	ld	hl,(FILCTR)	;
	inc	hl		;
	ld	(FILCTR),hl	;inc the field pos. ctr.
	ld	a,(MTCFLG)	;
	cp	0ffh		;
	jp	z,CBWD5		;
	ld	a,0ffh		;
	ld	(INTFLG),a	;set int-flag again.
	jp	NXTCHR		;keep looping
;
CBWD5:	ld	bc,(BCPCTR)	;
	ld	hl,0h		;
	and	a		;
	sbc	hl,bc		;
	jp	z,CBWD3		;
	dec	bc		;
	ld	(BCPCTR),bc	;
	jp	CBWD2		;
;
CBWD3:	ld	a,0h		;reset
	ld	(CBWFLG),a	;the character backward flag
	ld	(INTFLG),a	;reset intflag
	ld	(STRFLG),a	;reset the start-of-field flag
	ld	(EFLFLG),a	;reset end of field flag
	ld	(EFRCHD),a	;reset end-of-field-reached flag
	ld	hl,(BCPCTR)	;
	inc	hl		;
	ld	(BCPCTR),hl	;inc the backw.pos.ctr.
	ld	hl,(FILCTR)	;
	dec	hl		;adjust the field length counter.
	ld	(FILCTR),hl	;
	ld	bc,00h		;
	and	a		;
	sbc	hl,bc		;
	jp	nz,CBWD4	;go if not one-pos.field.
	ld	hl,00h		;
	ld	(BCPCTR),hl	;
	ld	a,0ffh		;
	ld	(STRFLG),a	;
	jp	CBWD4		;join the backward code.
;
;the following allows clearing (spacing) of the record held
;in user-buffer during update-mode.
;
;
CLRREC:	ld	a,(DEMODE)	;
	cp	02h		;update mode?
	jp	z,CLRRE1	;
	ld	a,0ffh		;
	ld	(FNCFLG),a	;
	jp	KEYERR		;
CLRRE1:	ld	bc,(UBFADD)	;clear the
	ld	hl,(VFPCTR)	;user buffer
	ld	a,20h		;
	call	INBUFF		;
;
	ld	a,0h		;clear the
	ld	(ENTFLG),a	;entry-mode-flag
	ld	a,0ffh		;set the
	ld	(CLRFLG),a	;clear function flag
	jp	FMTINT		;
;
CLRKY1:	ld	a,0h		;
	ld	(CLRFLG),a	;clear the clear-flag
	jp	DELREC		;ret to user interface.
;
CLRFLG:	ds	1		;
;
;
;the following handles the field-advance function.
;
FLADV:	ld	a,0ffh		;
	ld	(FFLG),a	;
	ld	a,0h		;
	ld	(FBFLG),a	;
	call	FLDCHK		;
	ld	a,(FLDERR)	;
	cp	0ffh		;
	jp	nz,FLDADV	;
	ld	a,0h		;
	ld	(FLDERR),a	;
	ld	a,(CADFLG)	;
	cp	0ffh		;
	jp	nz,KEYERR	;
	ld	a,00h		;
	ld	(CADFLG),a	;
;	ld	a,(EFRCHD)	;
	ld	a,(EFLFLG)	;
	cp	0ffh		;
	jp	nz,KEYERR	;
	ld	a,0ffh		;
	ld	(EFTFLG),a	;set end of field flag
	jp	CBWD4		;
	jp	KEYERR		;
;
;
FFLG:	db	0h		;
;
;
;the following handles the field-backward function.
;
FLBWD:	ld	hl,(BFNO)	;
	ld	bc,1		;
	and	a		;
	sbc	hl,bc		;
	jp	z,GETCHR	;ignore it , already at fld 1
	ld	a,0ffh		;
	ld	(FBFLG),a	;
	ld	a,0h		;
	ld	(FFLG),a	;
	call	FLDCHK		;
	ld	a,(FLDERR)	;
	cp	0ffh		;
	jp	nz,FLDBWD	;
	ld	a,0h		;
	ld	(CBWFLG),a	;
	ld	(FLDERR),a	;
	jp	KEYERR		;
FLBWD1:	ld	a,0ffh		;
	ld	(FBFLG),a	;set fld-backw.flg
	ld	a,00h		;
	ld	(EFTFLG),a	;
	jp	FLDBWD		;
;
FBFLG:	db	00h		;
;
;the following allows positioning into the first variable
;field of the current format.
;
HME:	ld	a,0ffh		;
	ld	(HMEFLG),a	;
	call	FLDCHK		;
	ld	a,(FLDERR)	;
	cp	0ffh		;
	jp	nz,ENTHME	;
	ld	a,0h		;
	ld	(FLDERR),a	;
	jp	KEYERR		;
;
HMEFLG:	db	0h		;
;
;the following handles the change-format-chain-key function
;
FMTCHK:	ld	a,0h		;
	ld	(BTCNT),a	;
	ld	bc,(SOFCBA)	;
	ld	(SVFMT1),bc	;save current crt buffer pointer
	ld	bc,FPTTAB	;calc. format buffer
	ld	hl,(VFCTR)	;for last field (E)
	dec	hl		;
	add	hl,hl		;x2
	add	hl,hl		;x4
	add	hl,bc		;
	ld	c,(hl)		;
	inc	hl		;
	ld	b,(hl)		;
	inc	bc		;
	push	bc		;move it to
	pop	hl		;the hl reg
	ld	(SVFMT2),hl	;and save it
	ld	de,0ffbbh	;load display area in line 25
	ld	(SOFCBA),de	;
	ld	bc,3h		;
	ldir			;and move the FCK to line 25
	ld	a,0ffh		;set 
	ld	(MLNFLG),a	;message line flag
	call	INCCRS		;set cursor to line 25
FMTCH4:	ld	a,84h		;
	call	DSPMSG		;set form.chain.key message
FMTCH3:	call	CHRRD		;get keyboard character
	call	CHKBTE		;check the character
	cp	01h		;is it a numeric ? (30-39h)
	jp	nz,FMTCH1	;no .
	ld	hl,(SOFCBA)	;
	ld	(hl),c		;display the character
	inc	hl		;
	ld	(SOFCBA),hl	;inc the crt-buffer
	ld	a,(BTCNT)	;get byte-count
	cp	02h		;3rd byte?
	jp	z,FMTCH5	;yes.
	inc	a		;
	ld	(BTCNT),a	;inc the byte count
	ld	a,0ffh		;
	ld	(MLNFLG),a	;set the message line flag
	call	INCCRS		;inc the cursor
	jp	FMTCH3		;loop for next character
FMTCH1:	ld	a,c		;
	cp	0dh		;carriage return ?
	jp	z,FMTCH6	;prepare exit to user interface
	cp	1bh		;escape character ?
	jp	z,FMTCH2	;yes time to ret to entry-level
FMTCH7:	ld	a,0ffh		;
	ld	(CFLAG),a	;set call-flag.
	call	KEYERR		;do keystroke error
	jp	FMTCH4		;loop for next character
FMTCH2:	ld	bc,0ffbbh	;
	ld	hl,3h		;
	ld	a,20h		;
	call	INBUFF		;clear message area
	ld	a,0ffh		;
	ld	(MLNFLG),a	;
	ld	hl,(SVFMT1)	;
	ld	(SOFCBA),hl	;
	call	INCCRS		;
	jp	SETMSG		;restore the cursor
FMTCH5:	ld	a,0h		;
	ld	(BTCNT),a	;
	ld	hl,0ffbbh	;
	ld	(SOFCBA),hl	;
	ld	a,0ffh		;
	ld	(MLNFLG),a	;
	call	INCCRS		;
	jp	FMTCH3		;set cursor back to pos.1 os mesg.area
;
;
FMTCH6:	ld	hl,0ffbbh	;
FMTCH9:	ld	a,(hl)		;
	cp	30h		;
	jp	z,FMTCH8	;
	ld	a,0ffh		;
	ld	(ZROFLG),a	;
FMTC10:	inc	hl		;
	ld	a,l		;
	cp	0beh		;
	jp	nz,FMTCH9	;
	ld	a,(ZROFLG)	;
	cp	00h		;
	jp	z,FMTCH7	;error,FCK all zeroes.
	ld	a,00h		;
	ld	(ZROFLG),a	;
	ld	de,FRMCHN	;move
	ld	hl,0ffbbh	;updated
	ld	bc,3		;FCK to
	ldir			;to FRMCHN in the ccb
	jp	XFMT		;exit to user interface
;
FMTCH8:	ld	a,(ZROFLG)	;
	cp	0ffh		;
	jp	z,FMTC10	;
	ld	a,00h		;
	ld	(ZROFLG),a	;
	jp	FMTC10		;
;
BTCNT:	ds	1		;byte count for FCK Display (0-3)
SVFMT1:	ds	2		;crt bufferaddress savearea
SVFMT2:	ds	2		;msg area address save address
ZROFLG:	db	00h		;
;
;
TSTFLD:	ld	a,(AUTFLG)	;
	cp	0ffh		;authorized flag set?
	jp	z,ENTRY3	;yes.
	ld	a,(FBFLG)	;
	cp	0ffh		;
	jp	z,BFDIR		;back.field.
	ld	hl,(BFNO)	;
	inc	hl		;
	ld	(BFNO),hl	;
	jp	FLDADV		;
;
BFDIR:	ld	hl,(BFNO)	;
	ld	bc,1		;
	and	a		;
	sbc	hl,bc		;
	jp	z,BFDIR1	;fwd.fld if on fld 1
	ld	hl,(BFNO)	;
	dec	hl		;
	ld	(BFNO),hl	;
	jp	FLDBWD		;
BFDIR1:	ld	a,0h		;
	ld	(FBFLG),a	;
	ld	a,0ffh		;
	ld	(FFLG),a	;
	ld	hl,(BFNO)	;
	inc	hl		;
	ld	(BFNO),hl	;
	jp	FLDADV		;
;
;the following sets aflag on FSB03-fields.
;
SETF03:	ld	a,(AUTFLG)	;
	cp	0ffh		;authorized flag set?
	jp	z,ENTRY4	;yes,bypass.
	ld	a,0ffh		;
	ld	(F03FLG),a	;
	jp	ENTRY3		;
;
F03FLG:	db	0h		;
;
;
;
;the following are the routines that do the setting,testing and
;clearing of the field-bit-mask table . for each variable
;field there will be one bit in the bit-mask table.
;if the bit for a corresponding field is set , the cursor may
;be moved within the complete field as the must have been entered
;previously. if the bit is not set , which means the field has not
;been touched yet, the cursor may not be positioned beyond the
;current cursor-position.
;
;
;STBMSK can be called to set the bit.
;TSBMSK will test the bit and ret with FFh in a-reg if set,else
;       with 00h .
;CLBMSK will clear the complete bit-table to all zeroes.
;
STBMSK:	ld	de,0h		;
	ld	(BMCNT),de	;clear byte ctr.
	ld	(BITCNT),de	;clear bitcnt.
	ld	hl,(BFNO)	;
	dec	hl		;
	ld	bc,8		;
STBMS1:	and	a		;
	ld	(BITCNT),hl	;
	sbc	hl,bc		;divide into no.of bytes.
	jp	m,STBMS2	;go if no. of bytes found.
	ld	de,(BMCNT)	;
	inc	de		;
	ld	(BMCNT),de	;
	jp	STBMS1		;loop back
STBMS2:	ld	bc,BMTAB	;form
	ld	hl,(BMCNT)	;the
	add	hl,bc		;byte offset address
	ld	ix,(BITCNT)	;
	ld	a,(TSTFLG)	;
	cp	0ffh		;
	jp	nz,STBMS6	;test-bit flag not set.
	ld	a,0h		;
	ld	(TSTFLG),a	;reset the flag .
	ld	de,STBMS7	;
	jp	STBMS5		;
STBMS6:	ld	de,STBMS3	;
STBMS5:	push	ix		;
	add	ix,ix		;
	add	ix,ix		;
	pop	bc		;
	add	ix,bc		;ix-reg now multiplied by 5.
	add	ix,de		;
	ld	a,(hl)		;get the byte to a-reg. 
	jp	(ix)		;branch off to appropriate bit-funct.
;
STBMS3:	set	0,a		;set bit 0
	jp	STBMS4		;
	set	1,a		;set bit 1
	jp	STBMS4		;
	set	2,a		;
	jp	STBMS4		;
	set	3,a		;
	jp	STBMS4		;
	set	4,a		;
	jp	STBMS4		;
	set	5,a		;
	jp	STBMS4		;
	set	6,a		;
	jp	STBMS4		;
	set	7,a		;
	jp	STBMS4		;
;
STBMS4:	ld	(hl),a		;store the updated byte (bit)
	ret			;and return.
;
STBMS7:	bit	0,a		;
	jp	STBMS8		;
	bit	1,a		;
	jp	STBMS8		;
	bit	2,a		;
	jp	STBMS8		;
	bit	3,a		;
	jp	STBMS8		;
	bit	4,a		;
	jp	STBMS8		;
	bit	5,a		;
	jp	STBMS8		;
	bit	6,a		;
	jp	STBMS8		;
	bit	7,a		;
	jp	STBMS8		;
;
STBMS8:	ret			;ret to caller
;
;
;the following will test the bit for the fieldnumber given in (BFNO)
;
TSBMSK:	ld	a,0ffh		;
	ld	(TSTFLG),a	;
	call	STBMSK		;
	jp	z,TSBMS1	;
	ld	a,0ffh		;
	ret			;ret if bit was set.
TSBMS1:	ld	a,0h		;
	ret			;ret if bit was not set
;
;
;the following will clear the complete bit-mask to zero.
;
CLBMSK:	ld	bc,BMTAB	;
	ld	hl,16		;number 0f bytes.
	ld	a,00h		;
	call	INBUFF		;
	ret			;
;
;
BMCNT:	dw	0000h		;bit-mask byte counter
BITCNT:	dw	0000h		;bit-mask bit counter
TSTFLG:	db	00h		;testbit flag.
;
BMTAB:	ds	16		;bit-mask table ,currently 16 bytes.
;
;THE FOLLOWING WILL CHECK WETHER A GIVEN FIELD MAY BE USED FOR 
;MANUAL ENTRY AND THE CURSOR POSITIONED IN THIS FIELD.
;THIS IS USED TO EXTEND A FIELD-ADVANCE OR FIELD-BACKWARD
;OVER A AUTOMATIC OR RESTRICTED FIELD.
;
;
FLDCHK:	ld	a,0		;
	ld	(FLDERR),a	;
	ld	hl,(BFNO)	;
	ld	(RESSV4),hl	;save BFNO
FLDC13:	ld	a,(HMEFLG)	;
	cp	0ffh		;home-flag set?
	jp	z,FLDC11	;yes.
	ld	a,(FFLG)	;
	cp	0ffh		;forward field flag set?
	jp	z,FLDC12	;yes.
	dec	hl		;must be backward field.
FLDC10:	ld	(BFNO),hl	;keep BFNO updated
	dec	hl		;allign with field-entry zero.
	add	hl,hl		;x2
	add	hl,hl		;x4
	ld	de,FPTTAB	;load field ptr,table start address
	add	hl,de		;and get pointer address to hl
	ld	e,(hl)		;
	inc	hl		;
	ld	d,(hl)		;field start address in form.buff.in de
	ld	hl,(BFNO)	;
	ld	a,(FFLG)	;
	cp	0ffh		;
	jp	z,FLDCH9	;bypass on forward-field.
;
;the following checks for duplicate format fields , which have an
;fsb of x6.
;
	ld	hl,(FBFADD)	;
	and	a		;
	sbc	hl,de		;
	jp	z,FLDC20	;
	ld	hl,(BFNO)	;
	dec	de		;
	ld	a,(de)		;
	ld	c,0fh		;
	and	c		;
	cp	06h		;
	jp	z,FLDC13	;yes its a fsb x6
	inc	de		;
;
FLDC20:	ld	hl,(BFNO)	;
	ld	a,(FTMFLG)	;
	cp	0ffh		;first-time flag set?
	jp	z,FLDCH9	;yes,dont check for dup-fdb's
	ld	a,(de)		;get fdb.
	cp	'D'		;
	jp	z,FLDC13	;yes.
	cp	'U'		;
	jp	z,FLDC13	;yes.
	cp	'L'		;
	jp	z,FLDC13	;yes.
	cp	'M'		;
	jp	z,FLDC13	;yes.
	cp	'+'		;
	jp	z,FLDC13	;yes.
	cp	'('		;
	jp	z,FLDC13	;
FLDCH9:	ld	a,(FFLG)	;
	cp	0ffh		;
	jp	z,FLDCH7	;
	ld	a,(de)		;
	cp	'B'		;
	jp	z,FLDC13	;yes.
	cp	'Q'		;
	jp	z,FLDC13	;
	cp	'T'		;
	jp	z,FLDC13	;
	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	nz,FLDCH7	;no,go.
	ld	a,(de)		;
	cp	'V'		;
	jp	z,FLDC13	;
	cp	'W'		;
	jp	z,FLDC13	;
	cp	'X'		;
	jp	z,FLDC13	;
	cp	'Y'		;
	jp	z,FLDC13	;
	cp	'Z'		;
	jp	z,FLDC13	;
FLDCH7:	ld	a,(AUTFLG)	;
	cp	0ffh		;authorized-flag set?
	jp	z,FLDCH2	;yes bypass FSB-check
	dec	de		;get address to FSB
	ld	a,(de)		;possible FSB now in A
	ld	c,0fh		;
	and	c		;mask out upprer 4 bits
	cp	02h		;display only FSB?
	jp	z,FLDC13	;yes.
	cp	04h		;no-display/no-update FSB?
	jp	z,FLDC13	;yes.
FLDCH2:	ld	a,(DEMODE)	;
	cp	02h		;
	ret	z		;
	ld	a,(EFLFLG)	;
	cp	0ffh		;is the end-of-field flag set?
	ret	z		;yes,ret uncondit.
	call	TSBMSK		;
	cp	0ffh		;
	jp	z,FLDCH1	;go,if bit set
	ld	a,0ffh		;
	ld	(FLDERR),a	;
	ld	hl,(RESSV4)	;
	ld	(BFNO),hl	;restore original BFNO
	ret			;not allowed in this mode.
FLDCH1:	ld	a,(RESFLG)	;
	cp	0ffh		;
	ret	nz		;
	ld	hl,(RESSV4)	;
	ld	(RESSV1),hl	;
FLDCH3:	ld	bc,(FILCTR)	;
	ld	hl,0h		;
	and	a		;
	sbc	hl,bc		;
	jp	z,FLDCH4	;
	dec	bc		;
	ld	(FILCTR),bc	;
	ld	bc,(BCPCTR)	;
	inc	bc		;
	ld	(BCPCTR),bc	;
	jp	FLDCH3		;
FLDCH4:	ld	hl,(BCPCTR)	;
	ld	(RESSV2),hl	;save backward field pos.ctr.
	ld	a,0h		;
	ld	(RESFLG),a	;clear resume-flag
	ret			;
;
FLDC11:	ld	hl,1h		;
	ld	(BFNO),hl	;
	ld	a,0h		;
	ld	(HMEFLG),a	;
	ld	(FBFLG),a	;clear the flags
	ld	a,0ffh		;
	ld	(FFLG),a	;set the forward flag
	jp	FLDC10		;
;
;
FLDC12:	inc	hl		;
	jp	FLDC10		;
;
;
FLDERR:	db	0h		;
RESFLG:	db	0h		;
RESSV1:	dw	0000h		;
RESSV2:	dw	0000h		;
RESSV3:	dw	0000h		;
RESSV4:	dw	0000h		;
MTCFLG:	db	00h		;matched field flag
;
;the following will handle the moving of the userbuffer to the
;crt-buffer on update-mode.after the move control will be
;handed to the entry-routine.
;this routine is also used to move the user-buffer to the format-buffer
;during format-data mode.
;
UPDMV:	ld	a,(UPDFLG)	;
	cp	00h		;update-mode flag reset?
	jp	z,ENTRY6	;yes,bypass.
UPDM15:	ld	hl,(BFNO)	;
	ld	(UPDSVE),hl	;save bfno
	ld	a,0ffh		;
	ld	(INTFLG),a	;
	ld	(ENTFLG),a	;
	ld	(UPDFLG),a	;
	ld	hl,1h		;
	ld	(BFNO),hl	;set field to 1
UPDMV5:	ld	hl,(BFNO)	;
	call	ENTRY6		;load all buffer-addresses
	ld	hl,(SOFFBA)	;
	ld	de,(FBFADD)	;
	and	a		;
	sbc	hl,de		;
	ld	hl,(SOFFBA)	;
	jp	z,UPDM44	;bypass if fieldaddress=bufferstart
	dec	hl		;
	ld	a,(hl)		;
	ld	c,0fh		;
	and	c		;
	cp	06h		;
	jp	z,UPDM43	;
UPDM44:	ld	a,(EFOFLG)	;
	cp	0ffh		;
	jp	z,UPDM13	;end of format.
	ld	hl,(SOFFBA)	;
	ld	de,(FBFADD)	;
	and	a		;
	sbc	hl,de		;
	jp	z,UPDMV1	;start of field=start of buffer.
	ld	hl,(SOFFBA)	;
	dec	hl		;
	ld	c,(hl)		;
	ld	a,(DEMODE)	;
	cp	05h		;format-data mode?
	jp	nz,UPDM18	;go if not.
	ld	a,08h		;
	call	DSPMSG		;set 'printout message'
	ld	a,80h		;
	and	c		;test bit 8
	jp	z,UPDM18	;no , not set
	ld	a,20h		;
	ld	(hl),a		;space the field security byte
UPDM18:	ld	a,0fh		;
	and	c		;
	cp	03h		;no-display FSB?
	jp	z,UPDMV2	;yes.
	cp	04h		;no-display/no-update.
	jp	z,UPDMV2	;
	ld	a,00h		;
	ld	(F03FLG),a	;
UPDMV1:	ld	a,(F03FLG)	;
	cp	0ffh		;
	jp	z,UPDMV3	;no-display field
UPDM11:	ld	a,(CAVFLG)	;
	cp	0ffh		;is the 'clear all var.fields'flag set?
	jp	nz,UPDMV8	;jp if not.
	ld	a,2eh		;load aperiod.
	jp	UPDM10		;
UPDMV8:	ld	hl,(SOFUBA)	;
	ld	a,(hl)		;
UPDM10:	call	WRTCHR		;
UPDMV4:	call	NXTFDB		;
	call	GENFSB		;inc all buffers,get next fdb
	cp	0ffh		;
	jp	z,UPDMV6	;
	cp	20h		;
	jp	z,UPDMV6	;
	ld	a,(DEMODE)	;
	cp	05h		;
	jp	nz,UPDMV1	;bypass following code if not mode 05
	call	CONST		;
	cp	0ffh		;
	jp	nz,UPDMV1	;
	call	CHRRD		;read character if one is waiting
	cp	CTRLQ		;user abort?
	jp	z,USRABT	;yes.
	ld	a,09h		;
	call	DSPMSG		;set 'printout halted' message
UPDM30:	call	CONST		;
	cp	0ffh		;
	jp	nz,UPDM30	;wait for another character
	call	CHRRD		;
	cp	CTRLQ		;
	jp	z,USRABT	;user abort during print halted.
	ld	a,08h		;
	call	DSPMSG		;display 'printout' message again
	jp	UPDMV1		;
;
UPDMV6:	ld	hl,(BFNO)	;
	inc	hl		;
	ld	(BFNO),hl	;update bfno
	ld	a,00h		;
	ld	(F03FLG),a	;
	jp	UPDMV5		;
;
UPDMV3:	ld	a,(AUTFLG)	;
	cp	0ffh		;
	jp	z,UPDM11	;authorized flag set.
	ld	a,2eh		;
	call	WRTCHR		;
	jp	UPDMV4		;
;
UPDMV2:	ld	a,0ffh		;
	ld	(F03FLG),a	;set FSB-03 flag
	jp	UPDMV1		;
;
UPDM13:	ld	a,(DEMODE)	;
	cp	05h		;format-data mode?
	jp	nz,UPDM17	;no.
	ld	bc,(SOFFBA)	;
	ld	hl,4h		;
	ld	a,20h		;
	call	INBUFF		;space the 4-character end of format.
	ld	de,(FBFADD)	;
	ld	hl,00h		;
	ld	(VFPCTR),hl	;clear the variable pos ctr
UPDM19:	ld	hl,(SOFFBA)	;
	and	a		;
	sbc	hl,de		;
	jp	z,UPDM17	;all done
	ld	a,(de)		;get character from format buffer
	ld	c,a		;
	ld	a,80h		;test bit 7
	and	c		;
	jp	z,UPDM20	;go if not set
	ld	a,20h		;
	ld	(de),a		;space that character
UPDM20:	inc	de		;bump the buffer pointer
	ld	hl,(VFPCTR)	;
	inc	hl		;
	ld	(VFPCTR),hl	;
	jp	UPDM19		;keep looping
UPDM17:	ld	a,(CAVFLG)	;
	cp	0ffh		;
	jp	z,UPDM14	;
UPDMV7:	ld	a,00h		;
	ld	(UPDFLG),a	;
UPDM16:	ld	a,00h		;
	ld	(INTFLG),a	;
	ld	(ENTFLG),a	;
	ld	(F03FLG),a	;
	ld	(EFOFLG),a	;
	ld	(CAVFLG),a	;
	ld	hl,(UPDSVE)	;
	ld	(BFNO),hl	;
	ld	a,(DEMODE)	;
	cp	05h		;format data mode?
	jp	z,ENDFRM	;
	jp	ENTRY		;
;
UPDMV9:	ld	a,(UPDFLG)	;
	cp	0ffh		;
	ret	z		;
	jp	ENTRY7		;
;
UPDM14:	call	CLBMSK		;
	ld	hl,00h		;
	ld	(BCPCTR),hl	;
	ld	(FILCTR),hl	;
	ld	a,(DEMODE)	;
	cp	00h		;
	jp	nz,UPDM16	;
	ld	bc,(UBFADD)	;
	ld	hl,(VFPCTR)	;
	ld	a,20h		;
	call	INBUFF		;
	jp	UPDM16		;
;
UPDM43:	ld	hl,(BFNO)	;
	inc	hl		;
	ld	(BFNO),hl	;
	ld	a,00h		;
	ld	(F03FLG),a	;
	jp	UPDMV5		;
;
;the following is used by the previous routine (UPDMV) to write
;a character from the user buffer to the screen (update-mode)
;or to the format-buffer (format-data-mode).
;
WRTCHR:	ld	c,a		;save character
	ld	a,(DEMODE)	;
	cp	05h		;format update mode?
	jp	z,WRTCH1	;yes.
	ld	hl,(SOFCBA)	;
	call	CHRCNV		;
	ret			;
WRTCH1:	ld	hl,(SOFFBA)	;
	ld	a,80h		;
	and	c		;test bit 8
	jp	z,WRTCH2	;go if not set
	ld	a,20h		;
	ld	(hl),a		;space the field security byte
	ret			;
WRTCH2:	ld	(hl),c		;
	ret			;
;
UPDSVE:	dw	0000h		;
UPDFLG:	db	0ffh		;
CAVFLG:	db	00h		;clear all variable fields flag.
;
;
;the following will test the field start byte and set the 
;num/alpha flag.it also saves the field start byte.
;
TSTFDB:	ld	a,(STRFLG)	;
	cp	00h		;start flag reset?
	jp	z,TSTFD5	;yes,filter the character
TSTFD9:	ld	a,00h		;
	ld	(STRFLG),a	;reset the field start flag
	ld	a,c		;
	ld	(LFSTB),a	;save the field start byte
	ld	hl,0ff84h	;
	ld	(hl),a		;display the fdb on crt.
	cp	'+'		;is it autoinc field?
	jp	z,TSTFD2	;yes , go straight to set num-flag.
;
;the following is an addittion to the RRZ-KASSEL system
;and has been commented out.
;
;	cp	'<'		;range check1?
;	jp	z,TSTFD2	;
;	cp	'?'		;date field?
;	jp	z,TSTFD2	;
;	cp	'('		;date/dup field?
;	jp	z,TSTFD2	;
;	cp	'='		;range check2?
;	jp	z,TSTFD2	;
	ld	b,41h		;
	sub	b		;subtract offset
	ld	hl,FDBTAB	;get fdb/fcc table
	ld	c,a		;
	ld	b,0h		;
	add	hl,bc		;get adress into table
	ld	a,(hl)		;get fcc-code for current fsb
	cp	01h		;alpha type?
	jp	z,TSTFD1	;yes
	cp	02h		;num.-type?
	jp	z,TSTFD2	;yes.
	cp	03		;num-dup?
	jp	z,TSTFD2	;yes
	cp	04h		;alp-dup?
	jp	z,TSTFD1	;yes.
	jp	ILLFRM		;anything else is illegal(format error)
;
TSTFD1:	ld	a,0ffh		;
	ld	(ALPFLG),a	;set alpha flag.
	ld	a,00h		;
	ld	(NUMFLG),a	;reset num flag.
	jp	TSTFD3		;
;
TSTFD2:	ld	a,0ffh		;
	ld	(NUMFLG),a	;
	ld	a,00h		;
	ld	(ALPFLG),a	;
	jp	TSTFD3		;
;
TSTFD3:	ld	a,(CBWFLG)	;
	cp	0ffh		;
	jp	z,CBWD2		;
	ld	a,(LFSTB)	;
	cp	'B'		;uncond.branch field?
	jp	z,BRFLD 	;
	cp	'T'		;register readout with reg.clear?
	jp	z,TFLD		;yes go T-field.
	cp	'Q'		;register readout?
	jp	z,QFLD		;yes go Q-field.
	cp	'?'		;date-field
	jp	nz,TSTF16	;bypass if not.
	ld	a,0ffh		;
	ld	(DTEFLG),a	;set date-flag
	jp	TSTFD7		;
TSTF16:	cp	'('		;date/dup field?
	jp	nz,TSTF15	;
	ld	a,(FTMFLG)	;
	cp	0ffh		;
	jp	nz,DUPCHK	;
	ld	a,0ffh		;
	ld	(DTEFLG),a	;set date-flag
	jp	TSTFD7		;
TSTF15:	cp	'<'		;range check 1 field?
	jp	nz,TSTF11	;bypass if not.
	ld	a,0ffh		;
	ld	(RC1FLG),a	;set range-check 1 flag.
	jp	TSTFD7		;
TSTF11:	cp	'='		;range check 2 field?
	jp	nz,TSTF12	;bypass if not.
	ld	a,0ffh		;
	ld	(RC2FLG),a	;
	jp	TSTFD7		;
TSTF12:	call	RACHK		;test for right adjust field
	cp	0ffh		;
	jp	nz,TSTFD6	;no right adjust field
	ld	a,c		;
	ld	(RAFCHR),a	;save 'should be right adjust fill chr'
	ld	a,(DEMODE)	;
	cp	01h		;verify mode
	jp	z,RAVER		;yes.
TSTFD6:	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	nz,TSTFD7	;no.
	ld	a,(LFSTB)	;
	cp	'V'		;numeric bypass on verify?
	jp	z,BRFLD		;yes.
	cp	'W'		;alphanum bypass on verify?
	jp	z,BRFLD		;yes
	cp	'+'		;
	jp	z,BRFLD		;autoincrement field.
TSTFD7:	ld	a,(FTMFLG)	;
	cp	00h		;
	jp	z,TSTFD4	;first-time flag is reset..
	call	ASDOFF		;reset the autom.skip/dup message.
	ld	a,(DUPFLG)	;
	cp	0ffh		;dup-flag set?
	jp	z,DUPCHK	;yes
	jp	SETMSG		;
;
TSTFD4:	call	ASDON		;set the autom.skip/dup msg.
	ld	a,(LFSTB)	;get fdb again.
	cp	'D'		;D field?
	jp	z,DUPCHK	;yes.
	cp	'U'		;U field?
	jp	z,DUPCHK	;yes.
	cp	'L'		;L field?
	jp	z,DUPCHK	;
	cp	'M'		;M field?
	jp	z,DUPCHK	;yes.
	cp	'+'		;auto inc field?
	jp	z,AUTINC	;yes.
	cp	'S'		;num.skip?
	jp	z,NUMSKP	;yes.
	cp	'K'		;alpha skip?
	jp	z,ALPSKP	;yes.
	cp	'F'		;f-field?
	jp	z,NUMSKP	;yes.
	cp	'G'		;G-field?
	jp	z,NUMSKP	;yes.
	jp	SETMSG		;
;
TSTFD5:	ld	a,(EFTFLG)	;
	cp	0ffh		;
	jp	nz,TSTFD8	;
	ld	hl,(FILCTR)	;
	ld	de,01h		;
	and	a		;
	sbc	hl,de		;
	jp	z,TSTFD9	;go on 1-position field length
TSTFD8:	ld	a,(FNFLG)	;
	cp	00h		;function key flag set?
	jp	z,TSTF10	;go if not.
	ld	a,00h		;
	ld	(FNFLG),a	;clear the flag
	ld	hl,(FILCTR)	;
	ld	de,00h		;
	and	a		;
	sbc	hl,de		;filctr = 0 ?
	jp	z,TSTFD9	;go and allow start of field.
;	ld	a,(EFRCHD)	;
	ld	a,(EFLFLG)	;
	cp	0ffh		;
	jp	nz,TSTF10	;
	ld	de,01h		;
	ld	hl,(FILCTR)	;
	and	a		;
	sbc	hl,de		;
	jp	z,TSTFD9	;allow start of field
TSTF10:	ld	a,c		;
	cp	3bh		;semicolon?
	jp	z,CNTFDB	;yes
	cp	3ah		;colon?
	jp	z,CNTFDB	;yes.
	cp	'-'		;num fcc
	jp	z,CNTFDB	;
	cp	'.'		;alpha fcc?
	jp	z,CNTFDB	;
	jp	REGCHK		;no,must be a register
;
DTEFLG:	db	00h		;date flag
RC1FLG:	db	00h		;range check 1 flag
RC2FLG:	db	00h		;range check 2 flag
;
;the following handles the verifying of the right adjust-fill charact.
;and checks first for right adjust bypass fsb's during verify
;
RAVER:	ld	a,(LFSTB)	;
	cp	'X'		;
	jp	z,BRFLD		;
	cp	'Y'		;
	jp	z,BRFLD		;
	cp	'Z'		;
	jp	z,BRFLD		;
RAVER2:	ld	hl,(SOFUBA)	;
	ld	de,(SOFCBA)	;
	ld	a,(RAFCHR)	;get 'should-be' fill character
	ld	c,a		;to c-reg.
	ld	a,(hl)		;get 'is' character to a-reg
	cp	c		;do they match?
	jp	z,RAVER1	;yes.
;
;the following accepts blanks in a zero-fill field (type R) as
;legal fill characters during verify.
;
	ld	a,(LFSTB)	;
	cp	'R'		;right adjust/zero fill type?
	jp	nz,SETMSG	;no.
	ld	a,(hl)		;get 'is' character from user buffer
	cp	' '		;fill char. = blank?
	jp	nz,SETMSG	;go if it is not.
	ld	(RAFCHR),a	;set r/a fill character to blank
RAVER1:	ld	a,(RAFCHR)	;
	ld	(de),a		;display the fill character
	ld	hl,(FILCTR)	;
	inc	hl		;
	ld	(FILCTR),hl	;
	call	NXTFDB		;
	call	GENFSB		;
	cp	0ffh		;
	jp	z,NXTLPE	;end of field(only fill chars found)
	cp	20h		;
	jp	z,NXTLPE	;end of field (only fill-characters)
	ld	a,0ffh		;
	ld	(CFLAG),a	;
	call	REGCHK		;
	ld	a,00h		;
	ld	(CFLAG),a	;
	jp	RAVER2		;keep looping
;
RAFCHR:	db	00h		;save for right-adjust fill character
;
;the following will check the register code (*,1-9,A-O) and
;set the respective flags.
;
REGCHK:	ld	a,(STRFLG)	;
	cp	0ffh		;field start flag set?
	jp	z,REGC99	;yes,illegal format.
	ld	a,(NUMFLG)	;
	cp	00h		;num-flag reset?
	jp	z,REGC99	;yes,illegal format.
	ld	a,c		;
	cp	'*'		;mul-reg?
	jp	z,REGCH0	;yes.
	cp	'1'		;reg.1?
	jp	z,REGCH1	;yes
	cp	'2'		;comment as before
	jp	z,REGCH2	;
	cp	'3'		;
	jp	z,REGCH3	;
	cp	'4'		;
	jp	z,REGCH4	;
	cp	'5'		;
	jp	z,REGCH5	;
	cp	'6'		;
	jp	z,REGCH6	;
	cp	'7'		;
	jp	z,REGCH7	;
	cp	'8'		;
	jp	z,REGCH8	;
	cp	'9'		;
	jp	z,REGCH9	;
	cp	'A'	;'
	jp	z,REGC10	;
	cp	'B'	;'
	jp	z,REGC11	;
	cp	'C'	;'
	jp	z,REGC12	;
	cp	'D'	;'
	jp	z,REGC13	;
	cp	'E'	;'
	jp	z,REGC14	;
	cp	'F'	;'
	jp	z,REGC15	;
	cp	'G'	;'
	jp	z,REGC16	;
	cp	'H'	;'
	jp	z,REGC17	;
	cp	'I'	;'
	jp	z,REGC18	;
	cp	'J'	;'
	jp	z,REGC19	;
	cp	'K'	;'
	jp	z,REGC20	;
	cp	'L'	;'
	jp	z,REGC21	;
	cp	'M'	;'
	jp	z,REGC22	;
	cp	'N'	;'
	jp	z,REGC23	;
	cp	'O'	;'
	jp	z,REGC24	;
	ld	a,(CFLAG)	;
	cp	0ffh		;
	ret	z		;return if call flag set
	jp	ILLFRM		;anything else is illegal format.
REGCH0:	ld	a,0ffh		;
	ld	(R0FLG),a	;
	jp	REGCK1		;
REGCH1:	ld	a,0ffh		;
	ld	(R1FLG),a	;
	jp	REGCK1		;
REGCH2:	ld	a,0ffh		;
	ld	(R2FLG),a	;
	jp	REGCK1		;
REGCH3:	ld	a,0ffh		;
	ld	(R3FLG),a	;
	jp	REGCK1		;
REGCH4:	ld	a,0ffh		;
	ld	(R4FLG),a	;
	jp	REGCK1		;
REGCH5:	ld	a,0ffh		;
	ld	(R5FLG),a	;
	jp	REGCK1		;
REGCH6:	ld	a,0ffh		;
	ld	(R6FLG),a	;
	jp	REGCK1		;
REGCH7:	ld	a,0ffh		;
	ld	(R7FLG),a	;
	jp	REGCK1		;
REGCH8:	ld	a,0ffh		;
	ld	(R8FLG),a	;
	jp	REGCK1		;
REGCH9:	ld	a,0ffh		;
	ld	(R9FLG),a	;
	jp	REGCK1		;
REGC10:	ld	a,0ffh		;
	ld	(R10FLG),a	;
	jp	REGCK1		;
REGC11:	ld	A,0ffh		;
	ld	(R11FLG),a	;
	jp	REGCK1		;
REGC12:	ld	a,0ffh		;
	ld	(R12FLG),a	;
	jp	REGCK1		;
REGC13:	ld	a,0ffh		;
	ld	(R13FLG),a	;
	jp	REGCK1		;
REGC14:	ld	a,0ffh		;
	ld	(R14FLG),a	;
	jp	REGCK1		;
REGC15:	ld	a,0ffh		;
	ld	(R15FLG),a	;
	jp	REGCK1		;
REGC16:	ld	a,0ffh		;
	ld	(R16FLG),a	;
	jp	REGCK1		;
REGC17:	ld	a,0ffh		;
	ld	(R17FLG),a	;
	jp	REGCK1		;
REGC18:	ld	a,0ffh		;
	ld	(R18FLG),a	;
	jp	REGCK1		;
REGC19:	ld	a,0ffh		;
	ld	(R19FLG),a	;
	jp	REGCK1		;
REGC20:	ld	a,0ffh		;
	ld	(R20FLG),a	;
	jp	REGCK1		;
REGC21:	ld	a,0ffh		;
	ld	(R21FLG),a	;
	jp	REGCK1		;
REGC22:	ld	a,0ffh		;
	ld	(R22FLG),a	;
	jp	REGCK1		;
REGC23:	ld	a,0ffh		;
	ld	(R23FLG),a	;
	jp	REGCK1		;
REGC24:	ld	a,0ffh		;
	ld	(R24FLG),a	;
	jp	REGCK1		;
;
REGCK1:	ld	a,0ffh		;
	ld	(REGFLG),a	;
	ld	a,(CBWFLG)	;
	cp	0ffh		;char.bwd set?
	jp	z,CBWD2		;yes,return here.
	ld	a,(CFLAG)	;
	cp	0ffh		;
	ret	z		;return if call flag set.
	jp	SETMSG		;
;
REGC99:	ld	a,(CFLAG)	;
	cp	0ffh		;
	ret	z		;ret if call flag set
	jp	ILLFRM		;otherwise illegal format.
;
;
;the following checks the field start byte to field cont.byte
;relationship and set appropriate flags.
;
CNTFDB:	ld	a,c		;get fcc to a
	cp	'+'		;
	jp	z,TSTFDB	;filter out auto inc.start byte
	cp	'('		;
	jp	z,TSTFDB	;
	ld	a,(STRFLG)	;
	cp	0ffh		;
	jp	z,ILLFRM	;
	ld	a,c		;get fcc to a again
	cp	'*'		;
	jp	z,REGCHK	;
	cp	'-'		;
	jp	z,CNTFD5	;numeric fcc
	cp	'.'		;
	jp	z,CNTFD2	;alpha fcc.
	cp	':'		;
	jp	z,CNTFD3	;num. must-field
	cp	';'		;
	jp	z,CNTFD4	;alpha must-field
	cp	'?'		;
	jp	z,TSTFDB	;
	cp	'('		;
	jp	z,TSTFDB	;
	cp	'<'		;
	jp	z,TSTFDB	;
	cp	'='		;
	jp	z,TSTFDB	;
	jp	ILLFRM		;anything else is illegal format
CNTFD2:	ld	a,(ALPFLG)	;
	cp	00h		;alpha-flag reset?
	jp	z,ILLFRM	;illegal: alpha fcc but non-alpha fsc
	jp	CNTFD5		;
CNTFD3:	ld	a,0ffh		;
	ld	(MFFLG),a	;set must fill flag
	jp	CNTFD5		;
CNTFD4:	ld	a,0ffh		;
	ld	(MFFLG),a	;set must fill flag
	jp	CNTFD2		;
CNTFD5:	ld	a,(CBWFLG)	;
	cp	0ffh		;char.bwd.flag set?
	jp	z,CBWD2		;yes.
	ld	a,00h		;
	ld	(MFFLG),a	;reset the must fill flag
	jp	SETMSG		;
;
;
;the following will check the alpha-flag for every alpha-character
;
ALPCHR:	ld	a,(ALPFLG)	;
	cp	00h		;
	jp	z,ALPCH1	;
	jp	ASCENT		;
;
;
;the following allows blanks to be duped into a numeric field.
;it also allows the minus to be entered on numeric right adjust fields.
;
ALPCH1:	ld	a,(DUPFLG)	;
	cp	0ffh		;dup-flag set.
	jp	z,ASCENT	;
	ld	a,c		;
	cp	'-'		;minus?
	jp	nz,KEYERR	;no must be an error.
	ld	(ALPSV),a	;
	call	RACHK		;check for right adjust.
	cp	0ffh		;
	jp	nz,KEYERR	;error.
	ld	a,(DEMODE)	;
	cp	01h		;
	jp	z,ALPCH2	;
	ld	a,0ffh		;
	ld	(MINFLG),a	;set minus flag
	jp	EOFPRC		;process the right adjust
;
ALPCH2:	ld	a,(MINFLG)	;
	cp	0ffh		;
	jp	z,EOFPRC	;
	ld	a,0ffh		;
	ld	(POSFLG),a	;
	jp	ASCE13		;
;
MINFLG:	db	00h		;
POSFLG:	db	00h		;
ALPSV:	db	00h		;
;
;the following will check the num.-flag for every numeric character
;
NUMCHR:	ld	a,(NUMFLG)	;
	cp	00h		;
	jp	z,ALPCHR	;could be a numeric in an alpha field
	jp	ASCENT		;
;
;
MFFLG:	db	00h		;must fill flag
ALPFLG:	db	00h		;alpha-flag
NUMFLG:	db	00h		;numeric flag
STRFLG:	db	00h		;start of field flag
;
;the following allows manual entry into one autom. dup.-field 
;of the current record by setting the 'first-time-flag'.
;
OVRDUP:	ld	a,0ffh		;
	ld	(FTMFLG),a	;set the first time flag
	jp	SETMSG		;
;
;
;the following prevents automatic duplication during update mode
;
DUPCHK:	ld	a,(DEMODE)	;
	cp	02h		;
	jp	nz,DUPFLD	;allow duping on non-update mode
	ld	a,00h		;
	ld	(DUPFLG),a	;clear dupflag
	jp	SETMSG		;go to manual entry loop
;
;
;the following moves a character from the dup-buffer to the a-reg
;on all dup-fields or dup-functions. It kind of simulates a keyboard
;entry during such situations.
;
DUPFLD:	ld	a,(EFTFLG)	;
	cp	0ffh		;
	jp	z,EOFLD		;go if end of field
	call	CONST		;read console status
	cp	0ffh		;character waiting?
	jp	nz,DUPFL1	;go if not.
	call	CHRRD		;get keyboard character
	cp	CTRLA		;reset auto-dup function?
	jp	z,OVRDUP	;yes.
DUPFL1:	ld	a,(DEMODE)	;
	cp	00h		;entry mode?
	jp	nz,DUPFL9	;
	call	RACHK		;
	cp	00h 		;right adjust field?
	jp	z,DUPFL9	;no
	ld	hl,(FILCTR)	;
	ld	bc,00h		;
	and	a		;
	sbc	hl,bc		;
	jp	z,DUPFL9	;allow dup in right adj.fld.on filctr=0
	ld	a,(DUPFLG)	;
	cp	0ffh		;
	jp	z,DUPFL9	;
	ld	a,0ffh		;
	ld	(FNCFLG),a	;set function flag
	ld	a,02h		;
	call	DSPMSG		;
	jp	KEYER3		;
DUPFL9:	ld	a,0ffh		;
	ld	(DUPFLG),a	;
	ld	de,(UBFADD)	;
	ld	hl,(SOFUBA)	;
	and	a		;
	sbc	hl,de		;get user buffer offset to hl
	ld	de,DUPBFF	;
	add	hl,de		;start of field in dup-buffer now in hl
	ld	c,(hl)		;get character to c-reg
	ld	a,(hl)		;and to a-reg
	jp	GETCH1		;and join the entry-loop again.
;
;the following 2048-byte definition defines the dup-buffer
;
DUPBFF:	ds	2048		;
;
;
;the following will handle the record forward/backward function.
;
RECFOB:	ld	c,a		;save a
	ld	a,(DEMODE)	;
	cp	02h		;update-mode?
	jp	nz,RECFO1	;no,dont allow it.
	ld	a,c		;
	cp	CTRLFR		;record-advance?
	jp	z,RECADV	;exit to user interface.
RECFO1:	ld	a,c		;
	cp	CTRLBR		;record-backward?
	jp	z,RECFO2	;go and check mode.
	jp	SKIP1		;function illegal for current mode.
;
RECFO2:	ld	a,(DEMODE)	;
	cp	01		;verify mode?
	jp	z,SKIP1		;yes,dont allow backw.record.
	jp	RECBWD		;perform record backward.
;
;skip or right adjust check.
;
SKRRAC:	call	MFLCHK		;
	cp	0ffh		;must fill situation?
	jp	z,SKRRA1	;yes.
	call	RACHK		;
	cp	00h		;
	jp	z,SKIP		;
	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	nz,EOFPRC	;no.
	ld	a,(MINFLG)	;
	cp	0ffh		;
	jp	z,ASCE13	;handle sign error
	jp	EOFPRC		;
;
;the following handles the error on must fill situations
;
SKRRA1:	ld	a,10		;
	call	DSPMSG		;
	ld	a,0ffh		;
	ld	(FNCFLG),a	;
	ld	(CFLAG),a	;
	call	KEYER3		;
	ld	a,00h		;
	ld	(FNCFLG),a	;
	jp	SETMSG		;
;
;the following handles the skip-field function.
;the routine will fill the remainder of the field with blanks
;and exit the field.
;
SKIP:	ld	a,(EFTFLG)	;
	cp	0ffh		;
	jp	z,EOFLD		;
	ld	a,20h		;
	ld	(SKPCHR),a	;set skip character
SKIP99:	ld	a,0ffh		;
	ld	(INTFLG),a	;set INT flag
SKIP2:	ld	a,(SKPCHR)		;
	ld	hl,(SOFUBA)	;
	cp	0ffh		;
	jp	z,SKIP3		;must be uncond.branch skip
	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	z,SKIP5		;yes
	ld	a,(SKPCHR)	;
	ld	(hl),a		;space user buffer
	ld	hl,(FILCTR)	;
	inc	hl		;
	ld	(FILCTR),hl	;
SKIP4:	ld	hl,(SOFCBA)	;
	ld	(hl),a		;
	ld	a,0ffh		;
	ld	(SKPFLG),a	;
	call	ASCE14		;
	ld	a,00h		;
	ld	(SKPFLG),a	;
	call	NXTFDB		;
	call	GENFSB		;
	cp	0ffh		;end of field?
	jp	z,EOFLD		;
	cp	20h		;
	jp	z,EOFLD		;end of field?
	ld	a,0ffh		;
	ld	(CFLAG),a	;
	call	REGCHK		;
	ld	a,00h		;
	ld	(CFLAG),a	;
	jp	SKIP2		;go for next character.
;
SKIP1:	ld	a,0ffh		;
	ld	(FNCFLG),a	;
	jp	KEYERR		;
;
SKIP3:	ld	a,(hl)		;get character from user buffer
	jp	SKIP4		;
;
SKIP5:	ld	hl,(SOFUBA)	;get character from user buffer
	ld	a,(hl)		;to a-reg.
	ld	c,a		;
	ld	a,(SKPCHR)	;get skip-fill character
	cp	c		;
	jp	nz,SKIP6	;dont match.
	ld	a,(SKPCHR)	;
	jp	SKIP4		;no match.
SKIP6:	ld	a,00h		;
	ld	(INTFLG),a	;reset INTFLG
	call	INCCRS		;set the cursor
	ld	a,0ffh		;
	ld	(SKPFLG),a	;set skip-flag
	jp	ASCEN4		;handle verify error.
;
SKPCHR:	db	00h		;skip fill character
SKPFLG:	db	00h		;skip flag,prevents increm. the FILCTR
;
;the following handles the unconditional branch (B) which fills
;the field with all blanks on all modes.
;
BRFLD:	ld	a,0ffh		;
	ld	(SKPCHR),a	;set skip fill chr. to bypass .
	jp	SKIP99		;
;
;
;the following handles the insert record function
;
INSREC:	ld	a,(DEMODE)	;
	cp	02h		;
	jp	z,INSRCD	;
	ld	a,0ffh		;
	ld	(FNCFLG),a	;
	jp	KEYERR		;
;
;this will allow skipping of fields with zero-filling of the field.
;
NUMSKP:	ld	a,30h		;
	ld	(SKPCHR),a	;
	jp	SKIP99		;
;
;this allows skipping of field with blank-filling of field.
;
ALPSKP:	ld	a,20h		;
	ld	(SKPCHR),a	;
	jp	SKIP99		;
;
;
;the following sets/resets the autom.skip/dup (ASD) message.
;
ASDON:	ld	de,0ff80h	;
	ld	hl,ONMSG	;
	ld	bc,3h		;
	ldir			;
	ret			;
;
ONMSG:	db	'ASD'		;
;
ASDOFF:	ld	de,0ff80h	;
	ld	hl,OFFMSG	;
	ld	bc,3h		;
	ldir			;
	ret			;
;
OFFMSG:	db	'   '		;
;
;
;the following will check for a must-fill situation and return with
;the a-reg set to 0ffh if it is , and with a-reg equal zero if not.
;
MFLCHK:	ld	a,(EFTFLG)	;
	cp	0ffh		;
	jp	z,MFLCH6	;bypass check if end-of-format flag set
	call	SVEBFF		;save current buffers
MFLCH7:	ld	a,0ffh		;
	ld	(INTFLG),a	;set cursor inc inhibit flag
MFLCH3:	call	GENFSB		;
	cp	20h		;end of format?
	jp	z,MFLCH1	;yes
	cp	0ffh		;end of format?
	jp	z,MFLCH1	;yes
	ld	a,c		;
	cp	';'		;alpha must fill
	jp	z,MFLCH2	;yes.
	cp	':'		;numeric must fill?
	jp	z,MFLCH2	;yes.
	call	NXTFDB		;
	jp	MFLCH3		;keep looping
;
MFLCH2:	ld	a,0ffh		;
	ld	(MFFLG),a	;set must fill flag
;
MFLCH1:	call	RSTBFF		;
	ld	a,00h		;
	ld	(INTFLG),a	;
	ld	a,(MFFLG)	;
	cp	0ffh		;
	jp	z,MFLCH4	;must fill flag set.
;
MFLCH5:	ld	a,(LFSTB)	;
	cp	'H'		;
	jp	z,MFLCH2	;
	cp	'C'		;
	jp	z,MFLCH2	;
	cp	'F'		;
	jp	z,MFLCH2	;
	cp	'G'		;
	jp	z,MFLCH2	;
	cp	'L'		;
	jp	z,MFLCH2	;
	cp	'M'		;
	jp	z,MFLCH2	;
	cp	'O'		;single must fill field?
	jp	z,MFLCH8	;
	cp	'P'		;
	jp	z,MFLCH8	;
	ld	a,(DEMODE)	;
	cp	01h		;verify mode?
	jp	nz,MFLCH6	;go 'no-must-fill
	ld	a,(LFSTB)	;
	cp	'J'		;
	jp	z,MFLCH2	;
	cp	'R'		;
	jp	z,MFLCH2	;
	cp	'I'		;
	jp	z,MFLCH2	;
MFLCH6:	ld	a,00h		;
	ret			;return on no must fill situation
;
MFLCH4:	ld	a,0ffh		;
	ret			;ret on must fill situation
;
MFLCH8:	ld	hl,(FILCTR)	;
	ld	de,00h		;
	and	a		;
	sbc	hl,de		;at least one character entered?
	jp	z,MFLCH2	;go if not.
	jp	MFLCH6		;yes,must fill satisfied.
;
;the following checks for must-fill fields before allowing a SEND-key
;to go thru. on update mode the check will be bypassed.
;
SNDCHK:	ld	a,(DEMODE)	;
	cp	02h		;update mode?
	jp	z,ENTSND	;go straight thru
	cp	01h		;verify mode?
	jp	z,ENTSND	;go to send (RRZ-KASSEL VERSION)
	ld	(SNDSV2),a	;
	call	SVEBFF		;save all buffer pointers
	ld	hl,(BFNO)	;
	ld	(SNDSV1),hl	;save current field number
	call	MFLCHK		;check rest of current field
	cp	0ffh		;
	jp	z,SNDCH1	;must-fill in current field
	ld	a,(MFFLG)	;
	ld	(SNDSV4),a	;save current state of must fill flag
	ld	a,02h		;
	ld	(DEMODE),a	;fake update mode
	ld	a,0ffh		;
	ld	(UPDFLG),a	;set update flag 
	ld	a,(LFSTB)	;
	ld	(SNDSV3),a	;save current field start byte
SNDCH3:	ld	hl,(BFNO)	;
	inc	hl		;
	ld	(BFNO),hl	;inc the field number
	call	ENTRY6		;calculate buffer pointers for nxt fld.
	ld	a,(EFOFLG)	;
	cp	0ffh		;
	jp	z,SNDCH2	;all fields checked
	ld	hl,(SOFFBA)	;
	ld	a,(hl)		;
	ld	(LFSTB),a	;
	call	MFLCH7		;check next field
	cp	0ffh		;
	jp	z,SNDCH1	;go on must fill fields
	jp	SNDCH3		;go for next field
SNDCH1:	ld	a,10		;
	call	DSPMSG		;set 'must fill' msg
	ld	a,0ffh		;
	ld	(FNCFLG),a	;set function flag
	ld	(CFLAG),a	;set call flag
	call	KEYER3		;handle the must-fill error
	ld	a,00h		;
	ld	(FNCFLG),a	;reset function flag
	ld	a,(SNDSV4)	;
	ld	(MFFLG),a	;restore must fill flag
	call	SNDRST		;restore all buffer pointers and flags
	jp	SETMSG		;and return to the entry-loop
;
SNDCH2:	call	SNDRST		;restore all bufferpointers and flags
	jp	ENTSND		;and return to user interface
;
SNDRST:	call	RSTBFF		;restore the buffer pointers
	ld	hl,(SNDSV1)	;
	ld	(BFNO),hl	;restore field number
	ld	a,(SNDSV2)	;
	ld	(DEMODE),a	;restore demode
	ld	a,00h		;
	ld	a,(SNDSV3)	;restore
	ld	(LFSTB),a	;field start byte
	ld	(UPDFLG),a	;reset update flag
	ld	(EFOFLG),a	;reset end of format flag
	ret			;
;
SNDSV1:	dw	0000h		;
SNDSV2:	db	00h		;
SNDSV3:	db	00h		;
SNDSV4:	db	00h		;
;
;the following handles the duplication of format data on entry mode 
;only.
;
DFFLD:	ld	hl,(BFNO)	;
	inc	hl		;
	ld	(BFNO),hl	;update to next field number
	ld	a,00h		;
	ld	(DFFLG),a	;clear the duplicate format flag.
	ld	a,(DEMODE)	;
	cp	00h		;
	jp	nz,ENTCPL	;go end-of-field if not entry-mode.
DFFLD1:	call	GENFSB		;
	cp	0ffh		;closing FSB found?
	jp	z,ENTCPL	;yes,go to end the field.
	ld	de,(UBFADD)	;
	ld	hl,(SOFUBA)	;
	and	a		;
	sbc	hl,de		;get userbuffer offset to hl-reg.
	ld	de,DUPBFF	;
	add	hl,de		;get start in dup-buffer to hl-reg.
	ld	a,(hl)		;
	ld	hl,(SOFUBA)	;
	ld	(hl),a		;move char. from dup-bff to usrbff
	ld	hl,(FILCTR)	;
	inc	hl		;
	ld	(FILCTR),hl	;inc the fld. length ctr.
	call	NXTFDB		;
	jp	DFFLD1		;keep looping till end of field.
;
DFFLG:	db	00h		;duplicate format flag.
;
	end
«eof»