comparison 3rdparty/subrtns/cpu.asm @ 743:9d5be3fe8ebb

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