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 ;-------------------------------------------------------------------------------
35 ;-------------------------------------------------------------------------------
41 db 19 ;HD64180 or higher
46 ;-------------------------------------------------------------------------------
47 ; Check if register C exists. D holds mask of bit to test.
48 ; return z, if register exists
53 ; check, if register is changeable
56 in a,(c) ; get it back
58 out (c),l ; set register to original state
62 ;-------------------------------------------------------------------------------
71 ; E = 4 HD64180 or higher
74 ; E = 7 Z8S180, Z8L180
76 ;-------------------------------------------------------------------------------
77 ; Registers only in Z180+, not in HD64180
80 ; Registers only in Z8S180/Z8L180
99 ld e,U8080 ; Init return val, assume 8080
101 dec a ; 00 --> 0FFH 8080/8085: even parity; Z80+: No overflow
102 jp po,chk_z80 ; Z80+ if P/V flag reset
104 ; The 8085 logical AND instructions always set the auxiliary flag ON.
105 ; The 8080 logical AND instructions set the flag to reflect the
106 ; logical OR of bit 3 of the values involved in the AND operation.
107 ; (8080/8085 ASSEMBLY LANGUAGE PROGRAMMING MANUAL, 1977, 1978)
110 and a ; 8085 sets, 8080 resets half carry.
111 daa ; A=06 (8085) or A=00 (8080)
117 ld e,UZ80 ; Assume Z80
118 daa ; Z80: 099H, x180+: 0F9H
119 cp 99h ; Result on 180 type cpus is F9 here. Thanks Hitachi
123 ; At least Hitachi HD64180
124 ; Test differences in certain internal registers
125 ; to determine the 180 variant.
134 ;TODO: additional plausibility checks
136 ret ; I/O registers not found
138 ; Register (base) found.
142 ld c,omcr ; Check, if CPU has OMCR register
145 ret nz ; Register does not exist. It's a HD64180
148 ld c,cmr ; Check, if CPU has CMR register
151 ret nz ; register does not exist. It's a Z80180
153 inc e ; S180/L180 (class) detected.
156 ;-------------------------------------------------------------------------------
177 ;808x Z80 Z180(0W) Z180(MaxW)
178 loop: ;---------------------------------
179 in a,(050h) ;10 11 10 +3*3 19
180 jp loop ;10 10 9 +3*3 18
181 ;---------------------------------
184 ; jr loop ;-- 12 8 +2*3 14
192 ; vim:set ts=8 noet nowrap