; WhatCPU.asm
;
; Actually a hand conversion of WhatCPU.c by Dave Haynie
;	done by Ethan Dicks 14-mar-88
;	beautification done by Ethan Dicks 14-Dec-88
;
; I did this as my first project in assembler.  Documentation is very
; scanty regarding the use of structures in assembler.  I got the magic
; offset into the ExecBase structure for the AttnFlags word by compiling
; Dave Haynie's program with Lattice, on a friend's machine, then
; running omd on the .o file.
;
; V 1.1
;  Since I got a copy of the C-A v1.0 Macro Assembler, and the assembler
;  includes with Lattice V4.01, I have been able to convert this program
;  over to the niceties of INCLUDE files.  I also too the opportunity to
;  streamline the code to the tune of about 40 bytes, making this one of
;  the smallest useful utilities.
;
; V 1.2 (07-Mar-1989)
;  The text strings have been changed slightly, to save about 12 bytes.
;  Other than that, there have been no significant changes.
;
; This program was most recently compiled on:
;
; assem
;	MC68000 Macro Assembler  Version 10.178
;	Copyright (C) 1985 by Tenchstar Ltd., T/A Metacomco.
;	All rights reserved.
;
; Blink
;	Blink - Version 5.0
;	Copyright (c) 1988 Lattice, Inc.  All Rights Reserved.
;
;
; To recompile:
;	assem WhatCPU.asm -i your_include_directory -o WhatCPU.o
;	blink WhatCPU.o
;
; This code is freely redistributable, although not pretty.
;
	section	code


		include	"exec/execbase.i"
		include "libraries/dos.i"
		include "libraries/dos_lib.i"
		include "exec/funcdef.i"
		include "exec/exec_lib.i"

AbsExecBase	equ	4

start:		movea.l	AbsExecBase,a6		;put ptr to ExecBase in a6
		lea	dos_name(pc),a1		;point to library name
		moveq.l	#0,d0			;pick any version
		jsr	_LVOOpenLibrary(a6)	;open dos.library
		movea.l	d0,a5			;save DosBase in A5
		jsr	_LVOOutput(a5)  	;get OutputHandle into D0
		move.l	d0,d5			;save OutputHandle in D5
;
; print title message
;
		move.l	#header,d2		;print intro message
		moveq.l	#25,d3			; 25 chars long
		bsr.s	print   		;output string
;
; check processor type bits
;
		btst.b	#AFB_68020,AttnFlags+1(a6) ;check 68020 bit
		beq.s	not68020		;nope... not set
		move.l	#mc68020,d2		;point to "20"
		moveq.l	#2,d3			; 2 chars long
		bra.s	break			;print processor type and
						;  check co-processor bit
;
not68020:	btst.b	#AFB_68010,AttnFlags+1(a6) ;check 68010 bit
		beq.s	not68010		;nope... not set
		move.l	#mc68010,d2		;point to "10"
		moveq.l	#2,d3			; 6 chars long
		bra.s	break			;print processor type and
						; check co-processor bit
;
not68010:	move.l	#mc68000,d2		;must be 68000; print it
		moveq.l	#2,d3			; 2 chars long
						;print processor type and
						; check co-processor bit
						;
						; *** WARNING ***
						;*  Fall through *
						; ***************
;
break:		bsr.s	print			;output processor string

		btst.b	#AFB_68881,AttnFlags+1(a6) ;check 68881 bit
		beq.s	not68881		;nope... not set
		move.l	#mc68881,d2		;print " 68881"
		moveq.l	#6,d3			; 6 chars long
		bsr.s	print
not68881:
;
; print <CR> at end of line
;
		move.l	#cr,d2			;finish off with <crlf>
		moveq.l	#2,d3			; 2 chars long
		bsr.s	print   
;
; clean up and exit
;
		movea.l	a5,a1			;get DosBase
		jsr	_LVOCloseLibrary(a6)	;close dos.library
		moveq.l	#0,d0			;set return code
		rts				;go home
;
; subroutines
;
print:		move.l  d5,d1			;set output handle
		jsr     _LVOWrite(a5)		;write string to console
		rts				;go back
;
; data section
;

;
; byte aligned data
;
dos_name:	DOSNAME
header:		dc.b	'System Configuration: 680'
mc68020:	dc.b	'20'
mc68010:	dc.b	'10'
mc68000:	dc.b	'00'
mc68881:	dc.b	' 68881'
cr:		dc.b	13,10

		end
