1178
|
1 ********************************************************************
|
|
2 * CPU - CPU Determiner Subroutine Module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
743
|
6 * Basic09 subroutine module to determine the CPU type of the computer
|
|
7 * Test via:
|
|
8 *
|
|
9 * PROGRAM CPU
|
|
10 * DIM CPUType,Mode:integer
|
|
11 * RUN CPU(Type,Mode)
|
|
12 * PRINT "CPU type:";CPUType
|
|
13 * IF Mode=0 THEN
|
|
14 * PRINT "6809 Emulation mode"
|
|
15 * ELSE
|
|
16 * PRINT "6309 Native mode"
|
|
17 * ENDIF
|
|
18 * END
|
|
19 *
|
|
20 * returns: CPUType: 6809 or 6309 (decimal integer)
|
|
21 * Mode: 0=emulation mode, 1=native mode
|
1178
|
22 *
|
|
23 * Ed. Comments Who YY/MM/DD
|
|
24 * ------------------------------------------------------------------
|
|
25 * 1 Created ADK ??/??/??
|
743
|
26
|
|
27 nam CPU
|
1178
|
28 ttl CPU Determiner Subroutine Module
|
743
|
29
|
|
30 ifp1
|
|
31 use defsfile
|
|
32 endc
|
|
33
|
|
34 rev set 1 first revision
|
|
35 tylg set Sbrtn+Objct
|
|
36 atrv set ReEnt+Rev
|
|
37 edition set 1
|
|
38
|
|
39 org 0
|
|
40 rmb 2 return address
|
|
41 PCount rmb 2 number of parameters
|
|
42 Param1 rmb 2 1st param address
|
|
43 Length1 rmb 2 size
|
|
44 Param2 rmb 2
|
|
45 Length2 rmb 2
|
|
46 Size equ .
|
|
47
|
|
48 mod eom,name,tylg,atrv,start,size
|
|
49
|
|
50 name fcs /CPU/
|
|
51 fcb edition
|
|
52
|
|
53 Start ldd PCount,s get parameter count
|
|
54 cmpd #2 2 parameters?
|
|
55 bne p.error no, error out.
|
|
56
|
|
57 ldd Length1,s get size of the first parameter
|
|
58 cmpd #2 integer variable?
|
|
59 bne p.error no, error out.
|
|
60
|
|
61 ldd Length2,s
|
|
62 cmpd #2 integer variable?
|
|
63 bne p.error no, error out.
|
|
64
|
|
65 * do a 6309/6809 test
|
|
66 ldd #$FFFF make sure it's non-zero
|
|
67 * clrd executes as a pseudo-NOP ($10), and a CLRA
|
|
68 fdb $104F
|
|
69 tstb
|
|
70 bne is.6809
|
|
71 ldd #6309 it's a 6309
|
|
72 bra save.1
|
|
73
|
|
74 is.6809 ldd #6809 it's a 6809
|
|
75 save.1 ldx Param1,s where to put the CPU type
|
|
76 std ,x save the integer CPU type
|
|
77
|
|
78 * if it's a 6809, we don't need to do the next part, as we KNOW it's
|
|
79 * running in 6809 emulation mode!
|
|
80
|
|
81 * this is harder.... are we in native mode?
|
|
82 pshs cc,dp,x,y,u save all registers but D
|
|
83 * pshsw a NOP on a 6809
|
|
84 fdb $1038
|
|
85
|
|
86 leay native,pc native mode PC
|
|
87 leax emulate,pc emulation mode PC
|
|
88 pshs x,y save them
|
|
89 pshs cc,d,dp,x,y,u and the rest of the registers, too.
|
|
90 orcc #Entire set the entire bit in CC
|
|
91 rti
|
|
92
|
|
93 emulate leas 2,s emulation mode: kill native mode PC
|
|
94 clrb we're in emulation mode
|
|
95 fcb $8C skip 2 bytes
|
|
96 native ldb #1 in native mode
|
|
97 puls u restore W from off-stack
|
|
98 * tfr u,w a PULSW does an 'RTS' on a 6809
|
|
99 fdb $1F36
|
|
100 puls cc,dp,x,y,u restore all of our other registers
|
|
101 clra now d=0: emulation, 1: native
|
|
102 ldx Param2,s where to put the data
|
|
103 std ,x save native/emulation mode flag
|
|
104 clrb no errors
|
|
105 rts
|
|
106
|
|
107 p.error comb set the carry
|
|
108 ldb #$38 Basic09 parameter error
|
|
109 rts
|
|
110
|
|
111 emod
|
|
112 eom equ *
|
|
113 end
|