	.title	mtype - get machine type
	.enabl	lc
	.ident	-010000-
;+
; Abstract:	mtype
;
;	This subroutine returns the machine type and node
;	designation.
;
; Calling sequence:
;
;	jsr	pc,$mtype
;
; Returns:
;
;	r0 points to an ASCIZ string which contains the
;	   node name.
;	r1 is a number representing the machine type.
;	   (e. g., 34., 45., 70.)
;	r2 is a number representing the machine serial
;	   number (11/70's only) or 0 (all other types).
;
; Limitations:
;
;	This subroutine can only be called from a privileged
;	task because it must map to the I/O page to pick up
;	the system serial number on a PDP-11/70, and it must
;	map to the SCOM data area in order to find out the
;	machine type.
;
; Written: 30-Apr-1981, -1.0.0-, Bruce C. Wright
; Modified:
; Verified:
;-

;
; Global definitions
;
	.globl	$mtype		; Entry point
;
; Global references
;
	.globl	.pdp11		; Machine type
;
; Equates for the external page
;
se.exp	=	177764		; Serial number register (11/70)
;
; Tables
;
nodtbl:	.word	70.,10638.	; 11/70 BLUE
	.word	70.,11023.	; 11/70 RED
	.word	45.,0.		; 11/45
	.word	34.,0.		; 11/23
	.word	0.,0.		; End of table
strtbl:	.asciz	"BLUE"
	.asciz	"RED"
	.asciz	"YELLOW"
	.asciz	"ORANGE"
unkstr:	.asciz	"UNKNOWN"
	.even
;
$mtype::
	mov	@#.pdp11,r1	; Get the machine type.
	clr	r2		; Assume not 11/70.
	cmp	r1,#70.		; Is it an 11/70?
	bne	10$		; J if not, assumption correct.
	mov	@#se.exp,r2	; Get serial number on 11/70.
10$:	mov	#strtbl,r0	; Point to string table.
	mov	r3,-(sp)	; Save a scratch register.
	mov	#nodtbl,r3	; Point to table of serial numbers.
20$:	cmp	r1,(r3)		; Found a match?
	bne	30$		; J if not.
	cmp	r2,2(r3)	; Serial number match?
	beq	40$		; J if so.
30$:	tstb	(r0)+		; Find end of this string.
	bne	30$		; ...
	add	#4,r3		; Get to next entry.
	tst	(r3)		; End of table?
	bne	20$		; J if not.
	mov	#unkstr,r0	; Point to unknown (default) string.
40$:	mov	(sp)+,r3	; Recover R3
	return			; And return to the caller.
	.end
