This hasn't been tested except on a 68008, reads as 68000, and a 68020.
Code:
* this needs to be run at reset or else a way to get the vector base address needs to
* be known
MOVEQ 0,d0 * exception vector base, assumes 68000 here
MOVEA.l d0,a5 * point to vector base
MOVEA.l $10(a5),a0 * save the address exception vector
LEA continue(pc),a1 * get the continue address
MOVE.l a1,(a5) * save as the address exception vector
MOVE.l sp,d7 * copy the stack pointer
MOVE.l d7,d6 * copy the stack pointer again
JMP *+5(pc) * cause an address error - all processors
* now there is an address error exception frame on the stack the processor type can be
* deduced from the size of this frame
continue
MOVE.l a0,$10(a5) * restore the address exception vector
SUB.l sp,d7 * calculate the size of the stack frame
MOVEQ #0,d0 * default to 68000 processor
CMPI.b #$12,d7 * compare frame size with that of 68000
BEQ.s proc_found * if 68000 size then exit
MOVEQ #10,d0 * set 68010 processor
CMPI.b #$3E,d7 * compare frame size with that of 68010
BEQ.s proc_found * if 68010 size then exit
MOVEQ #70,d0 * set 68070 processor
CMPI.b #$26,d7 * compare frame size with that of 68070
BEQ.s proc_found * if 68070 size then exit
MOVE.l #300,d0 * set 68300 processor
CMPI.b #$1C,d7 * compare frame size with that of 68300
BEQ.s proc_found * if 68300 size then exit
MOVEQ #40,d0 * set 68040 processor
CMPI.b #$10,d7 * compare frame size with that of 68040
BEQ.s proc_found * if 68040 size then exit
MOVEQ #99,d0 * set 68099, unknown processor
CMPI.b #$24,d7 * compare frame size with that of 68020/030
BNE.s proc_found * if not 68020/030 size then exit
* else test for 68020/68030
MOVE.l $1A(a5),a0 * get illegal instruction exception vector
MOVE.l $7E(a5),a1 * get format error exception vector
LEA is_68020(pc),a2 * set our format error exception vector
MOVE.l a2,$7E(a5) * save format error exception vector
LEA is_68030(pc),a2 * set our illegal instruction exception vector
MOVE.l a2,$1A(a5) * save illegal instruction exception vector
MOVEQ #20,d0 * default to 68020 processor
dc.w $06FA,$0000,$0002 * CALLM #0,next_word(pc)
* call module, 68020 only
next_word
dc.w -1 * dummy data, cause format error
* illegal instruction exception arrives here
is_68030
MOVEQ #30,d0 * set 68030 processor
* format error exception arrives here
is_68020
MOVE.l a1,$7E(a5) * restore format error exception vector
MOVE.l a0,$1A(a5) * restore illegal instruction exception vector
proc_found
MOVE.l d6,sp * restore the stack pointer
ADD.l #68000,d0 * the processor type is in d0
Lee.