;****************************************************************
; D3115IDE.ASM - Modified Boot EPROM for Davidge DSB 4/6 SBC
;
; Added 10-second spin-up delay, testing for DRV_RDY.
; Alternate primary/secondary on each retry.  10 July 2025
;
; Added default boot from hard disk if user presses <Return>.
; ROM Monitor B)oot command now restarts the menu rather than
; jumping into the regular sequence.  30 June 2025
;
; Added simple boot menu to boot from hard disk, floppy disk, or
; drop to ROM Monitor.  If 5-second countdown expires, standard
; sequence of trying floppy then hard disk up to 10 times is run.
; 17 June 2025
;
; Fixed bugs in routines from 4000ROM.asm, de-duplicated common
; code in S)et and P)ort commands, separated console receive
; status from console input. 14 June 2025
; 
; Adapted to improved routines from 4000ROM.ASM 9 May 2025
; Adapted to support boot from IDE hard disk using GIDE
; interface.  7 May 2025
;
; Adapted to use the various (improved) definition libraries.
; 5 May 2025
; Portions typed in from printout.  3 May 2025
;
; Disassembly started 2 October 1994 w/additional comments
; John D. Baker
;
;---- Original header comment begins on the next line ----
;
;This Boot Strap program is intended to be used in the Boot ROM
; of the Davidge Corporation Single Board Computer.  It initializes
; the first two serial ports, their related baud rate generators,
; and the floppy disk DMA and the FDC interrupt generator.
;
; After the above initialization, a message is output to SIO channel
; A, asking for a floppy disk to be inserted into the A: drive.
; It then waits until the diskette is mounted before continuing.
; If there is timeout on the disk, and no disk appears to be present,
; control is passed to the Davidge Boot Rom Monitor.
;
; After the floppy disk is mounted, the drive is restored and the
; drive type (5.25" or 8") is determined.  Then, the drive is stepped
; in with a verify option to determine the density of the diskette.
; After a successful step-in is completed, a READ ADDRESS command
; is executed to obtain the sector size of the diskette.
;
; At this time, the drive is restored to track 00.  The first sector
; of the diskette is then read into locations 80h to 0ffh of memory.
; Finally, control is then passed to address 80h.
;
; To assist the loader program (resident on track 00 sector 1), the
; following parameters are passed:
;
;	(A) = Drive Select Bits
;		includes drive type and density
;	(D) = Sector Size
;	(E) = Suggested step rate indicator
;		1 (6 msec) if 8" drive detected
;		3 (30 msec) if 5.25" drive detected
; These parameters assist in developing a general purpose loader
; for the computer.
;
;$-PRINT
$*MACRO		;don't show macro expansion, only resulting bytes
;
false	equ	0
true	equ	not false
;
debug	equ	false	;patch around init., flop code when debugging

;
;We have no external reference for timing, so the boot menu
;countdown loops were determined empircally.  Set the MSB of the
;outer countdown loop according to the speed of the processor.

ctdnsec	equ	5	;n-second countdown
cpumhz	equ	4	;for DSB-4/6 can be either 4MHz or 6MHz
cpuscal	equ	cpumhz * 6 ;scale for approx 1s delay
cputmcn	equ	cpumhz * 1923 ;approx. ~50ms delay
;
	MACLIB	Z80
	MACLIB	PORTDEF
	MACLIB	FLOPDEF
	MACLIB	FLPDEF2	;more/better floppy ctrl/stat bit defs
	MACLIB	FDC179X	;more/better FDC command/status defs
	MACLIB	IDEDEF	;(G)IDE port/command definitions

;
ROMSIZE	EQU	2048	;2716 EPROM = 2K

	if not debug
ROM:	EQU	0
RAM:	EQU	ROM
	else
ROM:	EQU	100H
RAM:	EQU	ROM
	endif
DBUF:	EQU	RAM+80H	;SD floppy boot sector loads here
hdbuf:	equ	RAM+ROMSIZE ;HD boot sector at end of ROM
hstsz:	equ	512	;512 bytes in IDE sector
btsigofs equ	0170h	;offset to "CPM" in boot sector
;
romport:  equ	1ah	; rom control port for Rev B board
;
RUBOUT:	EQU	7FH
CONTU:	EQU	15H
CONTR:	EQU	12H
BACKSP	EQU	8H
PROMPT:	EQU	2DH
ctrlc:	equ	3
tab:	equ	9
lf:	equ	10
cr:	equ	13
xoff:	equ	19
space:	equ	20h
;

	ORG	RAM		;runs in RAM after copy from ROM
	jr	init
;
; init clears the above "jr init" to 0000, so use for a couple
; of Udata bytes.
hstdsk	equ	RAM	;unit (pri/sec) * 16 + "disk" (head) 0-15

;
;pad so code/data falls at end of section
	ds	30

;
; data and scratch-pad areas and short utility routines located below
; the (floppy) disk buffer (at 80h)

;
;Wait for IDE drive to be ready for commands or for previous
;command to be complete (not BSY) and no error condition.
;If never ready, returns A=FF,Z=0.  If error, A=IDE Error Reg., Z=0.
iWtRdy:
	lxi	d,0	;set up countdown
iWtRdy1:
	in	iRgStat	;get status
	rlc		;BSY bit to Cy
	jrnc	chkErr	;brif not BSY
	call	iWtCntDn ;if BSY, decrement count
	jrnz	iWtRdy1	;brif more tries
	jr	statRtn	;brif never ready
chkErr:
	rrc		;not BSY, restore ERR bit
	ani	1	;isolate ERR bit
	jrz	statInv	;brif no error
	in	iRgErr	;else rd ERR reg, clr err cond
	ret		;return A=ERR,Z=0
statInv:
	xri	1	;flip A:0 (1->0, 0->1)
statRtn:
	dcr	a	;A=FF/Z=0 on error, A=0/Z=1 no error
	ret
;
; wait for data available/ready for data (DRQ)
iWtDrq:
	call iWtRdy
	rnz		;if non-0, timed out or ERR
iWtDrq1:
	in	iRgStat	;get status
	ani	8	;isolate DRQ bit
	rrc ! rrc ! rrc	;shift A:3 to A:0
	jrnz	statRtn	;return if ready
	call	iWtCntDn ;else decrement count
	jrnz	iWtDrq1	;brif more tries
	jr	statRtn	;else return error
;
;
iWtCntDn:
	dcx	d	;else decrement DE
	mov	a,e	;check if zero
	ora	d
	ret		;return Z=1 if no more tries
;
COMTBL:	DB	'DSPGF'	; Table of valid command letters

	org	RAM+58h	;CTC INTVECs MUST be at 0058h
CTC0V:	dw	isr	;floppy boot sector puts DMAC vector here.
CTC1V:	dw	isr
CTC2V:	dw	isr
FDCVEC:
CTC3V:	DW	FDCISR
;
FDCISR:
	IN	DSTAT	;read FDC status
	STA	STATUS	;save it for wait loop to check
isr:	EI		;ints back on
	RETI		;return from Interrupt
;
;
; FDC DMA Initialization Command String
;
DMASTG:	DB	0C3H	;WR6: 6 DMAC reset commands
	DB	079H	;WR0: xfr B->A, ch A addr, ln follow
dmaad:	dw	idsv	;DMA read sec_ID into here
dmalen:	dw	idln-1	; read 6 bytes of ID
	DB	14H	;WR1: ch A=mem, increments
	DB	28H	;WR2: ch B=I/O, fixed
	DB	85H	;WR4: byte md, ch B addr follows
	DB	DDATA	;IO port for DMA CH. B (FDC DATA)
	DB	0CFH	;WR6: addr regs->addr cntrs, clr byte cntrs
	DB	82H	;WR5: stop@end, CE* only, RDY* act low.
	DB	87H	;WR6: start DMAC
DSTGLGT:	EQU	$-DMASTG
;
;
IDSV:	DW	0,0,0			;TRACK, SIDE/SSZ, SECTOR
idln:	equ	$-IDSV
SECT:	DB	1			;start/current sector
CUNIT:	DB	side0+DC1DEN+DC1DS0	;(w/motor on)
;
STATUS:	DB	0	;FDCISR writes status here
CMD:	DB	0	;save disk type here (Step rate...)
;
maxtry	db	tries	;# of attempts before aborting to monitor
;
; put 1-time initialization code/data in the default (floppy) disk
; buffer area.  It is never used again once the ROM code is moved
; to RAM and continues running there.
;
	ORG	DBUF
init:	LXI	H,ROM		;read ROM
	LXI	D,RAM		;write RAM
	LXI	B,ROMSIZE	;move 2K bytes of EPROM
	LDIR			;BC=0000 after this
;
	MVI	A,1	; turn off the boot rom
	out	romport
	sbcd	RAM	;zero out "jr init"
;
	if debug
	jr	init2	;and skip init code
	nop
	else
	IM2		; select interrupt mode 2
	MVI	A,CTC0V SHR 8
	STAI
	endif		;
;
	LXI	H,TABLE2	;bring up the IO ports
	LXI	SP,TABLE1	;point at port#/byte-count data
	MVI	D,ports		;device count in D
INIT1:	POP	B		;get a port/byte count
	OUTIR			;output the stream
	DCR	D		;decrement device count
	JRNZ	init1		;brif not done
;
	LXI	SP,RAM		;init SP
	if	debug
init2:
	lxi	h,msg		;point to message
	endif
	call	dismsg	;HL->msg after last init string, heh, heh!
	jr	load	;branch to load
;
TABLE1:
	DB	CTC0,3	; Serial A baud rate generator
	DB	CTC2,2	; Serial B baud rate generator
	DB	CTC3,2	; FDC mode 2 interrupt generator
	DB	SIOAC,6	; Main console serial port
	DB	SIOBC,6	; Printer serial port
ports	equ	($-table1)/2
TABLE2:
	DB	CTCMODE,SBAUD,CTC0V MOD 256  ; 9600 bd ;cntr, 12
	DB	7,34H	; 300 baud	;4MHz timer, reload 52
	DB	0D7H,1	; FDC IM2 generator
	DB	4,44H,3,0C1H,5,0EAH  ; SIO A 8 data, 1 stop, no par
	DB	4,44H,3,0C1H,5,0EAH  ; SIO B 8 data, 1 stop, no par
;
; Extracted ROM image and disassembly shows "3,0C1H" as above.
; Printout shows "3,0E1H" as below:
;
;  DB  4,44H,3,0E1H,5,0EAH  ; SIO A 8 data, 1 stop, no par, auto enab
;  DB  4,44H,3,0E1H,5,0EAH  ; SIO B 8 data, 1 stop, no par, auto enab
;
	if	debug
msg:
	endif
	db	cr,'Davidge Computer Systems, v',ver or '0','.'
	db	rev or '0',', 12/25/82',cr,0
;
;
	ORG	DBUF+80H	;100H normal, 200H debugging
;
;ptrs to ROM routines for boot sector convenience
pconst:	dw	const	;console input status
pconin:	dw	conin	;console in (w/toupper)
pconout: dw	conout	;console output
pdismsg: dw	dismsg	;display null-terminated string @(HL)
ptdly:	dw	tdly	;delay about 50ms
;
;
load:
	mvi	a,tries		;reset retry count
	sta	maxtry
;
	lxi	h,bootmenu	;point at menu string
	call	dismsg		;display it
	inx	h		;bump to countdown string
;
;n-second countdown
	mvi	c,ctdnsec
	mvi	m,ctdnsec+'0'	;init countdown string
menulp:
	push	h		;save pointer
	call	dismsg		;print
	pop	h		;restore pointer
	dcr	m		;decrement display digit
	mvi	b,cpuscal	;MSB delay loop in B
menu0:
	call	tdly		;delay approx. 50ms
;
	call	const		;did user press a key?
	jrnz	usrsel		;brif key pressed
	djnz	menu0		;else continue
	dcr	c		;count down
	jnz	menulp		;brif non-0
	call	dismsg		;print '0'
	jr	load0		;and jump to default
usrsel:
	mvi	m,' '		;clear seconds display
	call	dismsg
usrsl0:
	call	conin		;get user character
	cpi	'M'		;drop to Monitor?
	jrz	gomon
	cpi	'H'		;boot Hard disk?
	jrz	load1		;
	cpi	cr		;usr pressed <Return>?
	jrz	load1		;
	cpi	'F'		;boot Floppy disk?
	jrnz	usrsl0		;brif none of these
;	
load0:
	if debug
	jr	load1	;just branch to HD boot call
	nop ! nop	;pad to keep same code size
	else
	EI
	call	flopload
	endif
load1:
	call	ideload		; try the (G)IDE
;
; if we return, there was an error
	lxi	h,maxtry	;HL->maxtry
	lxi	d,hstdsk	;DE->hstdsk
	ldax	d		;get disk
	xri	10h		;flip the unit bit
	bit	0,m		;even or odd try?
	jrz	load2		;brif even
	inr	a		;else bump to next head
load2:
	stax	d		;save hstdsk
	dcr	m		;--tries
	jrnz	load0
gomon:
	jmp	dsmon		;no more retries, abort to monitor
;
flopload:
	mvi	a,side0+DC1DEN+DC1MIN+DC1DS0	;try a mini drive first
	MOV	B,A
	OUT	DCTRL1
	MVI	A,RESTOR+rs03ms	;RESTORE COMMAND (6 MS STEP RATE)
flop1:
	push	b	;save old FDC mode
	call	type1	;issue command
	pop	b	;get FDC mode back
	bit	3,a	;check bit 3 of status CRC ERROR?
	rnz		; abort if error
	bit	2,a	; see if trk00 reporting
	mvi	a,RESTOR+rs15ms	;prepare for slow restore
	jrz	flop1	;go do it if necessary
	in	dctrl2	;now, see if mini or 8"
	rar		;bit 0->carry (was TRK0 from 5.25"?)
	mvi	a,rs15ms  ;set mini step rate 
	jrnc	flop2	; brif old bit 0 clear (5.25" disk)
	mvi	b,side0+DC1DEN+DC1DS0	;set 8"
	mvi	a,rs06ms  ;set up A w/ 8" type byte (6ms step)
flop2:	sta	cmd	;save disk type for later
	ori	STEPI+vertrk	;make into a step in command
	mov	d,a	;save for a moment
	mov	a,b	;get the selbits
	out	dctrl1	;select the right drive type
	sta	cunit	;and save it for the boot sector to use
	mov	a,d	;reget the step in command
	call	type1	;and issue command to FDC
	ani	snotrdy+sseeker+scrcerr	;isolate the error bits
	jrz	flop3	;brif ok
	lda	cunit	;else FDC trouble, get old FDC mode
	xri	DC1DEN	; try other density ;flip b6 (now 1D)
	out	dctrl1	;set new FDC mode
	sta	cunit	;and save it for boot sector...
	mov	a,d	;get FDC STEP IN command back
	call	type1	;send command
	ani	snotrdy+sseeker+scrcerr
	rnz		;abort if needed
flop3:	MVI	A,readid+vertrk	; read address command
	lxi	h,idsv	;get address
	lxi	d,idln	;get # bytes
	call	fread	;set up DMA and issue FDC command
	ANI	snotrdy+dstrnf+scrcerr+SLOSTD	;isolate err bits
	RNZ		; abort if error
	lda	cunit	;reget the selbits
	ani	NOT DC1DEN	;clear bit 6 (set temporary SD)
	out	dctrl1	;set single density
	lda	cmd	;reget the step rate
	setb	3,a	;make into a restore
	call	type1	;go back to trk00
	mvi	a,1	;read t 0 s 1
	STA	SECT
	OUT	DSCTR
	lxi	h,dbuf	; set up the dma string for read sector
	lxi	d,128-1 ; byte count
	MVI	A,rdsec	;RD_SEC, cmpsid1, no cmpsid
	call	fread
	ANI	snotrdy+dstrnf+scrcerr+SLOSTD
	RNZ		; abort if error
	DI		;else boot sector loaded, no more INTS.
	lda	cmd	; get the step rate
	mov	e,a
	lda	idsv+3	; get the sector size
	mov	d,a
	lda	cunit	; get the select bits
	if	debug
	rst	7	;return to debugger
	nop ! nop	;pad to maintain code size
	else
	JMP	DBUF	; pass to the loader
	endif

;
;approximately 50ms delay
tdly:			;call tdly ;17 T-states
	lxi	d,cputmcn ;10 T-states
tdly1:
	dcx	d	;6 T-states
	mov	a,d	;4 T-states
	ora	e	;4 T-states
	jrnz	tdly1	;12/7-T-states (12 if taken, 7 if not)
	ret		;10 T-States
;
; Boot loader for GIDE hard disk interface
;
ideload:
	lda	maxtry	;get # of tries
	cpi	tries	;1st attempt?
	jrnz	ideld0	;brif not
;
	mov	c,a	;1st access, tries=10 sec spin-up wait
spndly:
	mvi	b,cpuscal
spndly0:
	in	iRgStat	;read status
	ani	40h	;test DRV_RDY bit
	jrnz	ideld0	;brif drive up to speed
	call	tdly
	djnz	spndly0	;
	dcr	c	;--seconds
	jrnz	spndly	;brif not done
ideld0:
	lda	hstdsk	;get disk
	ori	0A0h	;make SDH byte
	out	iRgSDH
	mvi	a,iCmdRcal	;RESTORE/RECALIBRATE command in A
	out	iRgCmd
;
	lxi	h,hdbuf	;HL=load adr for HD boot sector
	lxi	b,iRgDat	;BC has count, port
;
	call	iWtRdy
	rnz		;non-0 if timed out or ERR
;
;	xra	a	;leaves zero in A
	out	iRgCLo
	out	iRgCHi	;Always Cylinder 0
	inr	a	;1-sector transfer
	out	iRgSCnt
	out	iRgSNum	;only sector 1
	lda	hstdsk	;get disk/head
	ori	0A0h	;make SDH byte
;
	mvi	a,iCmdRd ;read
	out	iRgCmd
;
	call	iWtDrq
	rnz		;non-0 if timed out or ERR
;
;no error, data ready, read it
	mov	d,h	;save bufadr for later
	mov	e,l
;
	inir
	inir		;read 512 bytes
;
;sector in RAM, check signature for valid boot sector
	lxi	h,btsigofs
	dad	d	;HL->signature string
;
	mvi	a,'C'	;1st char
	cmp	m
	if	debug
	rst	7	;pause here
	endif
	rnz		;return if no match
	inx	h	;matched 1st, bump to next
	mvi	a,'P'	;2nd char
	cmp	m
	rnz		;return if no match
	inx	h	;matched 2nd, bump to next
	mvi	a,'M'	;3rd char
	cmp	m
	rnz		;return if no match to signature string
;
	xchg	;HL->buffer
;
;We have what appears to be a successful load of a boot sector
;from the IDE hard disk.  De-select all floppies and indicate
;MOTOR OFF before loading A w/the SDH byte for the "disk" and
;jumping to the IDE boot sector.

	if	not debug
	lda	cunit	;get floppy selbits
	ani	0f0h	;de-select all drives
	ori	20h	;motor off
	out	dctrl1	;turn off the floppy
	else
	jr	skip0
	nop ! nop ! nop	;pad to keep code the same size
	nop ! nop ! nop
skip0:
	endif
;
	lda	hstdsk	;get disk
	ori	0A0h	;make SDH byte
	if not debug
	pchl		;pass to HD boot sector
	else
	rst	7	;back to debugger
	endif
;
;
; More floppy disk routines
;
fread:	shld	dmaad
	xchg
	shld	dmalen
;
	LXI	H,DMASTG	;DMAINIT ;point to DMA init string
	MVI	C,DMACMD	;DMACMD	port in C
	MVI	B,DSTGLGT	;count = 18. bytes
	OUTIR			;set up DMA controller
type1:	EI			;make sure interrupts are on!
	OUT	DCMMD		;FDC command port
	mvi	a,0ffh	; set interrupt flag
	sta	status		;set up default return status
	lxi	h,1000h		;set timeout countdown
type1a:	djnz	type1a		;B=0=256 loop/wait this many cycles
	lda	status	;see if command done yet
	bit	0,a		;Still BUSY?
	rz			;command finished, return w/A=status
;
	dcx	h		;--HL
	mov	a,h		;get H
	ora	l		;HL=0000?
	jrnz	type1a		;no, keep waiting
	dcr	a		;countdown expired, force NZ status
	ret			;and return error
;
; THIS SUBROUTINE SIMPLY OUTPUTS A "#", A CARRIAGE RETURN, AND A SPACE.
;
;	REGISTERS ALTERED:  A
;
hatch:	lxi	h,htchmsg
;
; THIS ROUTINE OUTPUTS A MESSAGE TO THE SCREEN.  THE MESSAGE MAY BE OF
; ANY LENGTH AS LONG AS IT IS STORED IN CONSECUTIVE BYTES AND TERMINATES
; WITH A BYTE CONTAINING ZERO.
;
;	INPUT PARAMETER:  HL-POINTS TO 1ST BYTE OF MESSAGE
;	REGISTERS ALTERED:  A,HL
;
DISMSG:	MOV	A,M		; GET A CHARACTER
	ORA	A		; TEST IF ZERO TERMINATOR
	RZ			; RETURN IF DONE
	CALL	CONOUT		; ELSE SEND TO SCREEN
	INX	H		; INCREMENT PTR
	JR	DISMSG		; GET NEXT BYTE
;
TESTU:	CPI	CONTU		; TEST FOR LINE REMOVAL
	JRNZ	TESTR		; WELL, IF NOT, TRY AGAIN
	CALL	HATCH		; ELSE, KILL LINE
;	JR	LININ		; RESTART ROUTINE
;
; THIS SUBROUTINE IS MAINLY USED FOR AND INPUT AND DISPLAY OF COMMAND
; LINES.  INPUT LINES CAN BE UP TO 32 CHARACTERS IN LENGTH (A <CR> IS
; INSERTED AS THE 33RD CHARACTER).  THE CHARACTERS ARE STORED IN A LINE
; BUFFER, SO THEY CAN BE ACCESSED LATER.  SIMPLE LINE EDITTING IS
; AVAILABLE IN THE FORM OF RUBOUT FOR REMOVAL OF SINGLE CHARACTERS (WITH
; ECHO), CONTROL-U FOR REMOVING THE ENTIRE LINE, AND CONTROL-R FOR RE-
; DISPLAYING A LINE WITHOUT THE ECHOS OF RUBBED OUT CHARACTERS.
;
;	REGISTERS ALTERED:  A,B,HL
;
LININ:	LXI	H,LINBUF	; INTIALIZE BUFFER PTR
	MVI	B,32		; SET BUFFER CHARACTER COUNT
;
; THIS IS THE MAIN LOOP IN THIS ROUTINE, WHERE CHARACTERS ARE ENTERED.
CHRLOP:	CALL	CONIN		; GET CHARACTER FROM KEYBOARD
	CPI	RUBOUT		; TEST FOR RUBOUT CHARACTER
	JRZ	RUB		; IF SO, PROCESS IT
	CPI	BACKSP		; TEST FOR BACKSPACE CHARACTER
	JRNZ	TESTU
;
RUB:	MOV	A,B		; GET CHARACTER COUNT
	CPI	32		; IF NONE, RUBOUT INVALID
	JRZ	CHRLOP
	DCX	H		; MOVE BUFFER PTR BACK
	MVI	A,BACKSP	; BACKSPACE OVER LAST CHARACTER
	CALL	CONOUT
	INR	B		;INCREMENT THE CHARACTER COUNT
	JR	CHRLOP
;
TESTR:	CPI	CONTR		; TEST FOR REDISPLAY
	JRNZ	ANYELSE
	CALL	HATCH		; END CURRENT DISPLAY LINE
	MVI	A,32		; COMPUTE # VALID CHARACTERS IN BUFFER
	SUB	B
	JRZ	CHRLOP		; IF NONE, JUST CONTINUE
	PUSH	B		; SAVE BUFFER CHARACTER COUNT
	MOV	B,A
	LXI	H,LINBUF	; POINT TO BEGINNING OF BUFFER
	CALL	LINOUT		; DISPLAY VALID CHARACTERS ONLY
	POP	B		; RESTORE BUFFER COUNT
	JR	CHRLOP		; CONTINUE
;
ANYELSE:MOV	M,A		; PUT CHARACTER IN BUFFER
	INX	H		; POINT TO NEXT SPOT
	CALL	CONOUT		; DISPLAY CHARACTER
	DCR	B		; DECREMENT CHARACTER COUNT
	jrz	any1
	CPI	cr		; IF <CR>, DONE
	RZ
	JR	CHRLOP		; IF NOT, CONTINUE
;
any1:	MVI	A,cr		; PUT IN FINAL <CR> IN BUFFER AT 33RD
	MOV	M,A		;  POSITION
;	JMP	CONOUT		; DISPLAY IT
;
; THIS IS A SUBROUTINE TO OUTPUT CHARACTERS TO THE CONSOLE, OR SCREEN.
; IF A <CR> IS TO BE OUTPUT, A <LF> IS ALSO OUTPUT.
;
;	INPUT PARAMETER:  A-ASCII CHARACTER TO BE DISPLAYED
;	OUTPUT PARAMETER:  A-ASCII CHARACTER THAT WAS DISPLAYED
;	REGISTERS ALTERED:  NONE
;
conout:
	PUSH	PSW		; SAVE CHARACTER
	cpi	cr		; see if carriage return
	jrnz	conout0		; brif not
	mvi	a,lf		; do a line feed
	call	conout
conout0:
	IN	SIOAC		; GET I/O CHANNEL STATUS
	ANI	txmty		; TEST IF READY
	JRZ	conout0		; LOOP UNTIL READY
	POP	PSW		; RETRIEVE CHARACTER
	OUT	SIOAD		; OUTPUT ON DATA LINE
	RET			; RETURN IF NOT
;
; Convenience routine for PORT command
;
chr3o:	call	hexascb	; Convert port number to ASCII
	mov	a,d	; Output the port number
	call	conout
	mov	a,e
	call	conout
	mvi	a,space	;put ASCII space after port number
	jr	conout
;
;
; THIS IS A SUBROUTINE TO RECEIVE CHARACTER INPUT FROM THE CONSOLE, OR
; KEYBOARD.
;
;	OUTPUT PARAMETER:  A-CHARACTER THAT WAS KEYED IN
;	REGISTERS ALTERED:  A
;
const:
	IN	SIOAC		; GET I/O CHANNEL STATUS
	ANI	RXRDY		; TEST IF CHARACTER AVAILABLE
	ret			;A=1,Z=0 if char avail,, else A=0,Z=1 
conin:
	call	const		; TEST IF CHARACTER AVAILABLE
	JRZ	CONIN		; LOOP TILL ONE IS
;
;alt entry if rxstat called by other routines and char is available.
conin1:
	IN	SIOAD		; GET CHARACTER
	ANI	7FH		; Remove extraneous bit
	cpi	'a'		; check for lower case
	rc
	cpi	'z'+1
	rnc
	ani	5fh		; convert to upper case
	RET

;
; This module is the Davidge Boot Rom Monitor.  Control passes to it
; when there is a timeout on the lack of disk boot.  A message is dis-
; played which explains why the monitor was called in and gives a brief
; summary of the five commands available.  Then, the main loop of this
; module is continually executed.  Commands are received, the parameters
; are collected, and the appropriate command routines are executed.
;
;
DSMON:
	LXI	H,SIGNON	; Point to sign-on message
	CALL	DISMSG		;  and display it
COMPROC:
	lxi	h,comproc	; set up return address
	push	h
	MVI	A,PROMPT	; Display prompt
	CALL	CONOUT
	CALL	LININ		; Get command line
;
; Test for valid command letter.
	LXI	H,LINBUF	; Point to line buffer
	MOV	A,M		; Get 1st char. entered
	CPI	'H'
;
	jrnz	compro2		;brif not help request
	pop	h		;else nix rtn adr (gets re-pushed)
	jr	dsmon		; If request for help, go do it
compro2:
	cpi	'B'		;boot the disk?
	jrnz	compro3		;brif not
	pop	h		;nix rtn adr (gets re-pushed)
	jmp	load		;and jump to loader
compro3:
	STA	COMCHR		; Save it
	LXI	B,5		; # of valid command letters
	LXI	H,COMTBL	; Ptr to table of valid command letters
	CCIR			; Compare
	JRNZ	ERROR		; If not a valid command,
				;  go to error routine
;
; The parameters are pulled out of the command, counted, and converted
; from ASCII characters into word values.  For a parameter with less
; than four ASCII characters, there is zero fill on the left.  More than
; four characters is a syntax error.  Use of any delimiters between the
; parameters other than spaces or commas is also a syntax error.
	LXI	H,LINBUF	; Point to 1st parameter character
	LXI	D,PARAM	; Point to block for parameter storage
	MVI	C,0	; Zero out the parameter count value
;
; Put parameters in parameter block, with zero fill.
COUNTP:	MVI	B,0FFH	; Zero out the bytes per param. count
	PUSH	H	; Save ptr to this parameter
COUNTB:	INR	B	; Else, increment byte count
	INX	H	; Point to next byte
	MOV	A,M	; Get byte
	CALL	ASCHEX	; Check for ASCII digit
	JRZ	COUNTB	; If not, check if delimiter
;
DELIM:	POP	H		; Retrieve parameter ptr
;	adi	'0'		; put the ascii bias back on it
	CPI	','		; Test for valid delimiter
	JRZ	DELIM1
	CPI	space
	JRZ	DELIM1
	CPI	cr		; Test for <CR>
	JRNZ	ERROR		; If not, there is a syntax error
;
DELIM1:	STA	DELIMC		; Store delimiter char.
	MVI	A,4		; Test if any zero fill needed
	SUB	B
	JRZ	FILLP		; If not, go fill parameter block
	JRC	ERROR		; If so, syntax error
	PUSH	B		; Save byte count
	MOV	B,A		; Put in B count of bytes to zero fill
	MVI	A,'0'		; ASCII character for zero
FILLZ:	STAX	D		; Put byte in parameter block
	INX	D
	DJNZ	FILLZ		; Continue until done
	POP	B		; Retrieve byte count
;
FILLP:	INX	H		; Increment ptrs
	MOV	A,M		; Get parameter byte
	STAX	D		; Put in parameter block
	INX	D
	DJNZ	FILLP		; Loop until done
	INX	H		; Skip delimiter character
	INR	C		; Increment parameter count
	mov	a,m		; get the delimiter
	CPI	cr		; Test for <CR>, test if done
	JRZ	PACK		; Jump ahead if so
	MOV	A,C		; Else test for too many parameters
	CPI	4
	JRC	COUNTP		; If not, get next parameter
;
; THIS ERROR ROUTINE SIMPLY DISPLAYS A QUESTION MARK AND CONTROL IS
; RETURNED TO THE MAIN COMMAND PROCESSING LOOP.
;
ERROR:	lxi	h,qmsg	; ERROR INDICATOR
	jmp	dismsg	; print message and return to start of Monitor
;
; Currently, each parameter is represented by a four byte hex string in
; the parameter block.  These will be converted to word values which
; will be stored in the parameter block, overwriting the ASCII strings.
PACK:	LXI	H,PARAM1	; Point to 1st parameter
	CALL	ASCHEXW		; Convert it
	SDED	PARAM1		; Store it
;
; Repeat for the other two parameters
	CALL	ASCHEXW
	SDED	PARAM2
	CALL	ASCHEXW
	SDED	PARAM3
;
;
; At this point, the command character has been saved, the parameters
; have been converted to word values and saved, and the parameter count
; has been stored in the C register.  The specific command routine may
; now be executed.
	LDA	COMCHR		; Get the command letter
	CPI	'D'		; Test for which command to do and go to
	JRZ	DISPLAY		;  the appropriate command routine
	CPI	'S'
	JZ	SETM
	CPI	'P'
	JZ	PORT
	CPI	'G'
	JRZ	GO
;
; This is where the FILL command is executed.  The first parameter is
; the starting address of a block of memory, the second parameter is the
; block ending address, and the third parameter is a byte value to store
; in all the bytes in the memory block.
FILL:	MOV	A,C	; Check for correct # of parameters
	CPI	3
	JRNZ	ERROR
	LHLD	PARAM3	; Insure that the 3rd parameter is a
	xra	a	;  byte value
	ora	h
	JRNZ	ERROR
	MOV	A,L	; Get fill byte
	LDED	PARAM1	; Get block beginning and ending addresses
	LHLD	PARAM2
;
FILLOP:	STAX	D	; Fill byte
	INX	D	; Point to next
	PUSH	H	; Save end address
	ORA	A	; Clear carry
	DSBC	D	; Test if done
	POP	H	; Restore end address
	JRNC	FILLOP	; If not done, continue
	RET		; Go get another command
;
; The GO command is executed here.  One parameter is entered, the
; address to which program control is to be tranferred.
GO:	dcr	c	; Test for correct # of parameters
	JRNZ	ERROR
;
	LHLD	PARAM1	; Get execution address
	PCHL		; Pass control to it
;
;
; This is where the DISPLAY command is done.  The first parameter is the
; starting address of memory to be displayed.  It is rounded down to be
; on a 16 byte boundry.  The second parameter, if entered, is the ending
; address in memory.  If not entered, it will be computed such that 16
; lines of 16 bytes each are displayed.  If entered, if is rounded up to
; be on a 16 byte boundry.  Each display line has the address of the
; first byte in the line, 16 bytes of data, and the ASCII of those bytes
; (a "." is used for non-displayable characters).  If the display is
; excessively long, it can be terminated by entering a <CR> from the
; keyboard.
DISPLAY:MOV	A,C		; Check for correct # of parameters
	dcr	a
	jrz	DISPLA1
	cpi	2
	jrnc	ERROR
	inr	a	;restore count (clear Z, C)
DISPLA1:
	PUSH	PSW	; Save count and flags
;
	LHLD	PARAM1	; Get start address
	MOV	A,L	; Round it down
	ANI	0F0H
	MOV	L,A
	XCHG
;
	POP	PSW	; Retrieve count and flags
	LXI	B,16	; Default # of display lines
	JRZ	DISPREP	; Jump if default used
	LHLD	PARAM2	; Else compute # of lines
	ORA	A	; Clear carry
	DSBC	D
	PUSH	D	; Save start address
	LXI	D,010H
	DAD	D	; Approximate # of bytes to be displayed
	POP	D	; Retrieve start address
;
	SRLR	H	; Divide by 16 to get # of lines
	rarr	l
	SRLR	H
	rarr	l
	SRLR	H
	rarr	l
	SRLR	H	; Move hi L nibble to low
	rarr	l
;
	PUSH	H
	POP	B
;
;
; At this point, BC contains a count of lines to display and DE contains
; the start address of first byte to display.  The display loop which
; follows sets up and displays each line and checks the keyboard input
; to test for halting display.
DISPREP:PUSH	B	; Save count of display lines in alternate
	EXX	;  register set, as the value
	POP	B	;  is only used at the end of the loop
	EXX
;
; Display a line of bytes and other info.
DISLIN:	MVI	A,space	; Space character
	MVI	B,bufsiz	; # of bytes in display line buffer
	LXI	H,DISBUF	; Point to display line buffer
	PUSH	H	; Save ptr
CLRLOP:	MOV	M,A	; Fill display buffer with space char.
	INX	H	;  and put <CR> at end
	DJNZ	CLRLOP
	MVI	M,cr
	POP	H	; Point to display buffer
	MVI	B,16	; # of bytes per display line
;
; Display address of first byte of line.
	PUSH	D	; Save address pointer twice
	PUSH	D
	CALL	HEXASCW	; Put ASCII address in buffer
	INX	H	; Leave space after address
	POP	D	; Retrieve address
;
; Display 16 bytes
DISBYT:	LDAX	D	; Get byte from address
	PUSH	D	; Save address
	CALL	HEXASCB	; Convert to ASCII
	MOV	M,D	; Put in display buffer
	INX	H
	MOV	M,E
	INX	H
	INX	H	; Leave space after byte
	POP	D	; Retrieve address
	INX	D	; Increment address
	DJNZ	DISBYT
;
; Display bytes in ASCII
	POP	D	; Get address of 1st byte in line
	MVI	B,16	; Count of bytes
DISCHR:	LDAX	D	; Get byte
	CALL	DISASC	; Check if displayable
	MOV	M,A	; Put in buffer
	INX	H
	INX	D
	DJNZ	DISCHR	; Loop till done
	LXI	H,DISBUF	; Point to buffer
	CALL	LINOUT	; Send line to screen
;
; Test if a <CR>, for stopping display, has been entered.
	call	const	;char ready?
	JRZ	LINTST	; If not, jump ahead
	call	conin1	;get char
	CPI	cr	; Test for <CR>
	rz		; Else, get new command
	cpi	xoff	; see if XOFF
	cz	conin	; suspend if so
;
; Test if all lines displayed.
LINTST:	EXX
	DCX	B	; Decrement count of display lines
	MOV	A,B	; Test for zero
	ORA	C
	EXX
	JRNZ	DISLIN
	RET		; If done, get another command
;
; The SET command is executed here.  One parameter is entered, the
; address of the first (and maybe only) byte to be displayed and
; possibly altered.  The address of the byte and the contents are
; displayed.  The user then has the option of what to do.  If a <CR> is
; entered, the next address and byte are displayed.  If a period is
; entered followed by a <CR>, the command is terminated.  If a byte
; value followed by a <CR> is entered, the current memory address is
; loaded with that value and the next address and byte are displayed.
; All other inputs are syntax errors.
SETM:	dcr	c	; Test for correct # of parameters
	JRNZ	ERR1
	LDED	PARAM1		; Get initial memory address
;
; Following is the change memory loop for this command.  First, display
; the memory address and its value.
CHGLOP:	PUSH	D	; Save current memory address
	LXI	H,LINBUF	; Point to output line buffer
	CALL	HEXASCW	; Convert addr to ASCII & put in buff
	POP	D	; Retrieve address
	MVI	M,space	; ASCII space after address
	INX	H	; Point to next buffer location
	LDAX	D	; Get byte value from memory location
	PUSH	D	; Save address again
	CALL	HEXASCB	; Convert to ASCII
	MOV	M,D	; Put in buffer
	INX	H
	MOV	M,E
	INX	H
	MVI	M,space	; Put space after byte value
	LXI	H,LINBUF	; Point to beg. of line buff again
	MVI	B,8	; Count of bytes to display
	CALL	LINOUT	; Output the line
;
;
; Now wait for an input from user and check it.  Do what is indicated
; or do an error exit.
	CALL	LININ
	LXI	H,LINBUF	; Point to line buffer
	MOV	A,M	; Get byte
	CPI	'.'	; Test if done
	JRNZ	TRYCR	; If not, test if skipping to next addr
	POP	D	; Clear stack
	INX	H	; Point to next byte which should be <CR>
	MOV	A,M
	CPI	cr
	rz		; If so, go get next command
ERR1:	JMP	ERROR	; If not, syntax error
;
TRYCR:	CPI	cr	; Test if <CR> for skipping
	JRNZ	ALTER
	POP	D	; If so, increment address ptr and continue
	INX	D
	JR	CHGLOP
;
ALTER:	POP	D	; Retrieve memory address
	call	newbyte	;get byte to store, Z=1,OK. Z=0,error
	JRNZ	ERR1	; Syntax error if not
;
CHANGE:	MOV	A,B	; Get new byte value for address
	STAX	D	; Put in memory
	INX	D	; Point to next address and continue
	JR	CHGLOP

;
; The PORT command is done here.  One parameter, the port address, is
; entered.  The port address and the read in value for it are displayed.
; The user can then enter a byte value followed by a <CR> and that value
; will be output on the port, or just a <CR> and nothing will happen.
; Any other input is a syntax error.
PORT:	dcr	c	; Test for correct # of parameters
	JRNZ	ERR1
	LHLD	PARAM1	; Insure that parameter is a byte value
	xra	a
	cmp	h	; insure port number in range
	JRNZ	ERR1
	MOV	C,L	; Set up for input instruction
	MOV	A,L
	call	chr3o
	INP	A	; Get port value
	call	chr3o	; display it
	CALL	LININ	; Wait for user input
	LXI	H,LINBUF	; Point to input line buffer
	MOV	A,M	; Get first byte entered by user
	CPI	cr	; Test if done with command
	rz		; If so, go get another command
;
	call	newbyte	;get byte to output
	jrnz	err1
;
OUTPRT:
	OUTP	B	; Output it to port
	RET		; Go get another command

;
;get byte to store/output
newbyte:
	CALL	ASCHEX	; Chk for ASCII dig. & get byte value
	RNZ		; If not a digit, syntax error
	MOV	B,A	; Save byte value
	INX	H	; Get next input byte
	MOV	A,M
	CALL	ASCHEX	; Check for ASCII and get value
	JRNZ	nwbyt1	;brif not digit, check for CR
;
	SLAR	B	;Got 2nd digit
	SLAR	B	; Multiply 1st digit entered x16
	SLAR	B
	SLAR	B
	ADD	B	;make byte value
	MOV	B,A	;Save it
	INX	H	;bump to next
	MOV	A,M
nwbyt1:	CPI	cr	;test for <CR>. Z=1,OK. Z=0,err
	ret

;
; THIS SUBROUTINE OUTPUTS A LINE, OR PART OF A LINE, TO THE SCREEN.
; A BUFFER POINTER IS GIVEN ALONG WITH A CHARACTER COUNT OF BYTES TO
; DISPLAY.  IF THE COUNT PASSED IS ZERO, CHARACTERS ARE TAKEN FROM THE
; BUFFER AND DISPLAYED UNTIL A <CR> IS ENCOUNTERED.
;
;	INPUT PARAMETERS:  B-CHARACER COUNT OR ZERO
;			  HL-POINTER TO LINE BUFFER
;	REGISTERS ALTERED:  A,B,HL
;
LINOUT:	XRA	A	; CLEAR A REGISTER AND ZERO GALG
	CMP	B	; TEST FOR ZERO COUNT
	JRNZ	PAROUT	;IF NOT, JUMP TO DISPLAY PARTIAL LINE
LIN01:	MOV	A,M	; GET CHARACTER FROM BUFFER
	CALL	CONOUT	; SEND TO SCREEN
	CPI	cr	; TEST FOR <CR>
	RZ
	INX	H	; INCREMENT BUFFER PTR
	JR	LIN01	; LOOP TILL DONE
;
PAROUT:	MOV	A,M	; GET CHARACTER FROM BUFFER
	CALL	CONOUT	; DISPLAY IT
	INX	H	; INCREMENT BUFFER PTR
	DJNZ	PAROUT	; LOOP TILL DONE
	RET
;
;
; THE PURPOSE OF THIS SUBROUTINE IS TO CONVERT AN ASCII CHARACTER REPRE-
; SENTING A NYBBLE HEX VALUE INTO THAT VALUE.  ERROR IS INDICATED IF
; CHARACTER NOT AN ASCII HEX DIGIT.
;
;	INPUT PARAMETER:  A-ASCII CHARACTER
;	OUTPUT PAMPAMETERS:  A-BYTE VALUE, VALID ONLY IF NO ERROR
;			    Z FLAG-SET IF OK, NOT SET TO INDICATE ERROR
;	REGISTER ALTERED:  A
;
ASCHEX:	CPI	'0'	; TEST FOR VALID RANGE 0-9
	RC		;return if less than '0' (Z=0)
	sui	'0'	;conv potential digit
	cpi	10	;more than 9?
	JRNC	LETTER	; IF NOT, TRY FOR A-F
letter1:
	CMP	A	; indicate valid
	RET
;
LETTER:
	sui	7	;bump down to letters
	CPI	10	; TEST FOR VALID RANGE A-F
	JRC	letter2	;brif < 10 (0AH)
	CPI	16
	JRC	letter1	;brif < 16 (10H)
letter2:
	ADI	'7'	;else put it back to char
	ret		;and return w/Z=0
;
; THIS SUBROUTINE CONVERTS TWO ASCII CHARACTERS INTO A BYTE VALUE.
; THERE IS AN ERROR RETURN IF EITHER OF THE ASCII CHARACTERS REPRESENT
; SOMETHING OTHER THAN A HEX DIGIT.
;
;	INPUT PARAMETER:  D,E-ASCII CHARACTERS
;	OUTPUT PARAMETERS:  A-BYTE VALUE, IF VALID RETURN
;			    Z FLAG-SET IF VALID RETURN, NOT SET
;			     OTHERWISE
;	REGISTERS ALTERED:  A,D,E
;
ASCB1:
	mov	d,m	;get first digit
	inx	h
	mov	e,m	;get second digit
	inx	h
ASCHEXB:MOV	A,D	; GET HIGH ORDER CHARACTER
	CALL	ASCHEX	; CONVERT TO VALUE
	RNZ		; RETURN IF NOT HEX DIGIT
	rlc		; X2
	rlc		; X4
	rlc		; X8
	rlc		; X16
	MOV	D,A	; SAVE IT
;
	MOV	A,E	; GET LOW ORDER CHARACTER
	CALL	ASCHEX	; CONVERT TO VALUE
	RNZ		; RETURN IF INVALID
	ADD	D	; ADD IN HIGH ORDER BYTE
	CMP	A	; INDICATE OK RETURN
	RET
;
;
; THIS SUBROUTINE IS SIMILAR TO THE RECEEDING ONE EXCEPT THAT FOUR ASCII
; CHARACTERS, POINTED TO BY HL, ARE CONVERTED INTO A WORD VALUE.  THERE
; IS ERROR RETURN, ALSO.
;
;	INPUT PARAMETERS:  HL-POINTER TO 4 BYTE STRING OF ASCII
;			    CHARACTERS
;	OUTPUT PARAMETERS:  DE-WORD VALUE
;			    Z FLAG-SET IF VALID RETURN, NOT SET
;			     OTHERWISE
;	REGISTERS ALTERED:  A,DE,HL
;
ASCHEXW:
	CALL	ASCB1	; CONVERT INTO BYTE VALUE
	RNZ		; RETURN IF INVALID
	PUSH	PSW	; SAVE BYTE VALUE
;
	CALL	ASCB1	; CONVERT
	POP	D
	RNZ
;
	MOV	E,A	; LOW ORDER BYTE IN E
	RET
;
; THE PURPOSE OF THIS SUBROUTINE IS TO CONVERT A NYBBLE VALUE (4 BITS)
; INTO AN ASCII CHARACTER.
;
;	INPUT PARAMETER:  A-LOWER FOUR BITS CONTAIN NYBBLE
;	OUTPUT PARAMETER:  A-ASCII CHARACTER REPRESENTING NYBBLE
;	REGISTERS ALTERED:  A
;
HEXASC:	ANI	0FH	; CLEAR UPPER NYBBLE, JUST IN CASE
	adi	90h
	daa
	aci	40h
	daa
	RET
;
; THE SUBROUTINE CONVERTS A BYTE VALUE INTO 2 ASCII CHARACTERS
;
;	INPUT PARAMETER:  A-BYTE VALUE
;	OUTOUT PARAMETER:  D,E-ASCII CHARACTERS
;	REGISTERS ALTERED:  A,D,E
;
HEXASCB:
	PUSH	PSW	; SAVE BYTE VALUE
	rrc		; SHIFT UPPER NYBBLE TO LOWER NYBBLE
	rrc
	rrc
	rrc
	CALL	HEXASC	; CONVERT TO ASCII
	MOV	D,A	; SAVE HIGH ORDER CHARACTER
;
	POP	PSW		; GET LOWER NYBBLE
	CALL	HEXASC		; CONVERT
	MOV	E,A		; STORE
	RET
;
; THIS SUBROUTINE CONVERTS A WORD VALUE INTO A STRING OF 4 ASCII DIGITS
; WHICH ARE INSERTED IN MEMORY WHERE SPECIFIED.
;
;	INPUT PARAMETERS:  DE-WORD VALUE
;			   HL-POINTER TO WHERE ASCII STRING SHOULD BE
;			    STORED
;	OUTPUT PARAMETER:  HL-POINTER TO LOCATION IMMEDIATELY AFTER
;			    STRING
;	REGISTERS ALTERED:  A,DE,HL
;
HEXASCW:
	MOV	A,D	; GET UPPER BYTE
	PUSH	D	; SAVE INPUT WORD
	call	hexw1	;CALL	HEXASCB		; CONVERT TO 2 ASCII DIGITS
			;MOV	M,D		; STORE DIGITS IN STRING
			;INX	H
			;MOV	M,E
;
	POP	D	; GET LOWER BYTE
	MOV	A,E
hexw1:	CALL	HEXASCB	; CONVERT
	MOV	M,D	; STORE IN STRING
	INX	H
	MOV	M,E
	INX	H
	RET
;
; THIS SUBROUTINE DETERMINES IF THE GIVEN ASCII CHARACTER IS DISPLAYABLE
; OR NOT.  IF IT IS, THE ASCII CHARACTER ITSELF IS RETURNED.  IF NOT, A
; PERIOD IS RETURNED.
;
;	INPUT PARAMETER:  A-ASCII CHARACTER
;	OUTPUT PARAMETER:  A-ASCII CHARACTER GIVEN AS INPUT IF IT'S
;			    DISPLAYABLE,
;				ASCII PERIOD OTHERWISE
;	REGISTER ALTERED:  A, IF NON-DISPLAYABLE CHARACTER
;
DISASC:	CPI	space
	JRC	PERIOD
	CPI	RUBOUT
	RC
PERIOD:	MVI	A,'.'
	RET
;
SIGNON:
	DB	cr,cr
	DB	tab,tab,'* * * * * DISK TIME'
	DB	' OUT * * * * *',cr,cr
	DB	'System can''t boot off disk.  Check disk, reset, and '
	DB	'try again.',cr
	DB	'If this doesn''t work, a ROM Monitor has been provided'
	DB	' for use in',cr
	DB	'primitive board test functions.',cr,cr
	DB	'Available commands are:',cr,cr
	DB	tab,'B)oot the disk',cr
	DB	tab,'D)isplay memory 16 bytes/line (D100,300)',cr
	DB	tab,'S)et memory, byte by byte (S300)',cr
	DB	tab,'P)ort value display/alter (P40)',cr
	DB	tab,'G)o exec code (G100)',cr
	DB	tab,'F)ill memory (F500,600,20)',cr
	DB	tab,'H)elp, redisplay this summary',cr,cr
	DB	'Note that altering some values may affect operation of'
	DB	' the ROM Monitor.',cr,cr,0
;
bootmenu:
	db	cr,tab,'Boot:',cr
	db	tab,'H)ard Disk',cr
	db	tab,'F)loppy Disk',cr
	db	tab,'M)onitor',cr,cr
	db	tab,'Other keys abort countdown',cr,0
;cntstr:
	db	space,BACKSP,0
;
htchmsg:db	'#',cr,space,0
qmsg:	db	'?',cr,0
;
LINBUF:
DISBUF:	DS	70		; Buffer for input and output lines
bufsiz	equ	$-LINBUF-1	; report 1 less for terminator
PARAM:				; TABLE FOR COMMAND PARAMETERS
PARAM1:	DS	4
PARAM2:	DS	4
PARAM3:	DS	4
DELIMC:	DS	1		; Storage for delimiter found in input
				;  strings
COMCHR:	DS	1		; Storage for command character entered
;
;
	end	;end of D3115 ROM image....
