annotate 3rdparty/subrtns/cpu.asm @ 3295:6b7a7b233925 default tip

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