1 .z80 ; for M80, ignored by SLR assembler
6 UUNKNOWN equ 0 ;Unknown CPU
10 UX180 equ 4 ;HD64180 or higher
11 UHD64180 equ 5 ;HD64180
13 UZ8S180 equ 7 ;Z8S180, Z8L180
16 ;-------------------------------------------------------------------------------
33 ;-------------------------------------------------------------------------------
34 ; Check if register C exists. D holds mask of bit to test.
35 ; return z, if register exists
40 ; check, if register is changeable
43 in a,(c) ; get it back
45 out (c),l ; set register to original state
49 ;-------------------------------------------------------------------------------
58 ; E = 4 HD64180 or higher
61 ; E = 7 Z8S180, Z8L180
63 ;-------------------------------------------------------------------------------
64 ; Registers only in Z180+, not in HD64180
67 ; Registers only in Z8S180/Z8L180
86 ld e,U8080 ; Init return val, assume 8080
88 dec a ; 00 --> 0FFH 8080/8085: even parity; Z80+: No overflow
89 jp po,chk_z80 ; Z80+ if P/V flag reset
91 ; The 8085 logical AND instructions always set the auxiliary flag ON.
92 ; The 8080 logical AND instructions set the flag to reflect the
93 ; logical OR of bit 3 of the values involved in the AND operation.
94 ; (8080/8085 ASSEMBLY LANGUAGE PROGRAMMING MANUAL, 1977, 1978)
97 and a ; 8085 sets, 8080 resets half carry.
98 daa ; A=06 (8085) or A=00 (8080)
104 ld e,UZ80 ; Assume Z80
105 daa ; Z80: 099H, x180+: 0F9H
106 cp 99h ; Result on 180 type cpus is F9 here. Thanks Hitachi
110 ; At least Hitachi HD64180
111 ; Test differences in certain internal registers
112 ; to determine the 180 variant.
120 ;TODO: additional plausibility checks
122 ret ; I/O registers not found
124 ; Register (base) found.
129 ld c,omcr ; Check, if CPU has OMCR register
132 ret nz ; Register does not exist. It's a HD64180
135 ld c,cmr ; Check, if CPU has CMR register
138 ret nz ; register does not exist. It's a Z80180
140 inc e ; S180/L180 (class) detected.
143 ;-------------------------------------------------------------------------------
161 ;Z80 Z180(0W) Z180(MaxW)
162 loop: ;--------------------------
163 in a,(050h) ;11 10 +3*3 19
164 jp loop ;10 9 +3*3 18
165 ;--------------------------
168 ; jr loop ;12 8 +2*3 14
176 ; vim:set ts=8 noet nowrap