;**********************************************
;*					      *
;*                   BUS.M68		      *
;*   Displays The Contents of the S-100 Bus   *
;*					      *
;*       David F. Pallmann, 30-May-84	      *
;*					      *
;**********************************************

	SEARCH	SYS
	SEARCH	SYSSYM

START:	PHDR	-2,0,PH$REE!PH$REU	;program header

CHECK:	MOV	SYSTEM,D0		;D0 contains system status bits
	AND	#SY$CPA,D0		;check AM1000 bit
	BEQ	HEADER			;branch if clear (AM100/L)
	TYPECR	<? this is an AM1000, it has no bus>
	JMP	EXIT			;exit

HEADER:	TYPECR	The bus contains the following:
	CRLF				;newline

TYPCPU:	TAB				;tab
	TTYL	CPU			;safe to assume system has a CPU
	CRLF				;newline

TYPMEM:	TAB				;tab
	MOV	MEMEND,D1		;D1 contains amount of memory
	DIV	D1,#1024.		;divide by 1K
	AND	#177777,D1		;mask D1 to low-order word
	DCVT	0,OT$TRM		;output D1 in decimal
	TTYL	MEM			;type: K bytes
	CRLF				;newline

BOARDS:	LEA	A0,IOTABL		;A0 points to I/O address
	LEA	A1,TXTABL		;A1 points to device description text

LOOP:	CTRLC	EXIT			;branch on ^C
	MOV	(A0)+,D0		;D0 contains I/O address
	BEQ	EXIT			;branch on zero (end of table)
	MOV	D0,A2			;A2 contains I/O address
	CMPB	@A2,#-1			;is a board occupying I/O address?
	BEQ	NEXT			; no
	TAB				;tab
	TTYL	@A1			;type out device text
	CRLF				;newline

NEXT:	TSTB	(A1)+			;advance to next
	BNE	NEXT			; description
	BR	LOOP			;process next device

EXIT:	CRLF				;newline
	EXIT				;exit

;table of I/O addresses

IOTABL:	LWORD	^H0FFFE00		;SSD
	LWORD	^H0FFFF04		;AM120
	LWORD	^H0FFFF70		;DR200
	LWORD	^H0FFFFF0		;AM210
	LWORD	^H0FFFFF8		;AM300
	LWORD	^H0FFFFE8		;AM300 #2
	LWORD	^H0FFFFD8		;AM300 #3
	LWORD	^H0FFFF68		;AM300 #4
	LWORD	^H0FFFF60		;AM300 #5
	LWORD	^H0FFFFB0		;AM310
	LWORD	^H0FFFFB4		;AM310 #2
	LWORD	^H0FFFFB8		;AM310 #3
	LWORD	^H0FFFFC2		;AM320
	LWORD	^H0FFFF85		;AM330
	LWORD	^H0FFFFD0		;AM410/AM415
	LWORD	^H0FFFFC4		;AM420
	LWORD	^H0FFFFC0		;AM500
	LWORD	^H0FFFFA0		;AM600
	LWORD	^H0FFFFD4		;AM610
	LWORD	^H0FFFF0D		;AM620
	LWORD	0

;text constants

CPU:	ASCIZ	'AM-100/L 68000-based CPU (2-port serial)'
MEM:	ASCIZ	'K bytes of memory'

;table of I/O device descriptions
;items in this table must appear in the same order as their addresses do
; in IOTABL.

TXTABL:	ASCIZ	'software security device'
	ASCIZ	'AM-120 2-port serial (1-port parallel) I/O board'
	ASCIZ	'DR-200 16-port serial I/O board'
	ASCIZ	'AM-210 floppy disk controller'
	ASCIZ	'AM-300 6-port serial I/O board'
	ASCIZ	'AM-300 6-port serial I/O board #2'
	ASCIZ	'AM-300 6-port serial I/O board #3'
	ASCIZ	'AM-300 6-port serial I/O board #4'
	ASCIZ	'AM-300 6-port serial I/O board #5'
	ASCIZ	'AM-310 4-port serial I/O board'
	ASCIZ	'AM-310 4-port serial I/O board #2'
	ASCIZ	'AM-310 4-port serial I/O board #3'
	ASCIZ	'AM-320 line printer interface'
	ASCIZ	'AM-330 communications board'
	ASCIZ	'AM-410 or AM-415 SMD disk controller'
	ASCIZ	'AM-420 Priam disk controller'
	ASCIZ	'AM-500 Hawk disk controller'
	ASCIZ	'AM-600 magtape interface'
	ASCIZ	'AM-610 VCR interface'
	ASCIZ	'AM-620 streamer tape drive'
	EVEN

	END