24 May 2014, 22:31 | #1 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
Cpuid
is there an easy and/or reliable way to tell from asm what CPU your program is running on?
|
24 May 2014, 23:06 | #2 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Not sure if it's reliable (I have never used it yet), but I have some code that is supposed to do it. I'll just go and dig it up...
Edit: Found the code. Not sure where I got this from... Code:
*************************************************************************** * T E S T C P U T Y P E * *************************************************************************** ; INPUT: None ; ; OUTPUT: Result stored in "cpu" variable ; ; Tests the type of CPU installed. *************************************************************************** test_cpu_type: movem.l d0-d1/a0,-(a7) move.l 4.w,a0 move.b $129(a0),d0 move.l #68040,d1 ;68040 btst #$03,d0 bne.b .exit move.l #68030,d1 ;68030 btst #$02,d0 bne.b .exit move.l #68020,d1 ;68020 btst #$01,d0 bne.b .exit move.l #68010,d1 ;68010 btst #$00,d0 bne.b .exit move.l #68000,d1 ;68000 .exit move.l d1,cpu movem.l (a7)+,d0-d1/a0 rts cpu: dc.l 0 Last edited by Lonewolf10; 24 May 2014 at 23:11. Reason: found the code |
25 May 2014, 12:55 | #3 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
ok! i never looked at the Execbase structure as much as i should, what if you have a 68060 though?
|
25 May 2014, 21:31 | #4 |
Registered User
Join Date: May 2010
Location: London, UK
Posts: 268
|
Test bit 7. (Thanks to Stingray)
|
25 May 2014, 23:27 | #5 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
|
26 May 2014, 11:42 | #6 |
move.w #$4489,$dff07e
Join Date: Sep 2005
Location: Norfolk, UK
Age: 42
Posts: 2,351
|
|
26 May 2014, 13:32 | #7 | |
ex. demoscener "Bigmama"
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
|
Quote:
Code:
******* Bit defines for AttnFlags (see above) ******************************* * Processors and Co-processors: BITDEF AF,68010,0 ; also set for 68020 BITDEF AF,68020,1 ; also set for 68030 BITDEF AF,68030,2 ; also set for 68040 BITDEF AF,68040,3 BITDEF AF,68881,4 ; also set for 68882 BITDEF AF,68882,5 BITDEF AF,FPU40,6 ; Set if 68040 FPU ; ; The AFB_FPU40 bit is set when a working 68040 FPU ; is in the system. If this bit is set and both the ; AFB_68881 and AFB_68882 bits are not set, then the 68040 ; math emulation code has not been loaded and only 68040 ; FPU instructions are available. This bit is valid *ONLY* ; if the AFB_68040 bit is set. ; ; BITDEF AF,RESERVED8,8 ; BITDEF AF,RESERVED9,9 BITDEF AF,PRIVATE,15 ; Just what it says |
|
26 May 2014, 15:54 | #8 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
I suppose I really want to know if CPU has certain features or not, rather than the exact model (i.e. does it have 68020 addressing modes), and don't want to rely on OS patches or even OS versions. Maybe something like the following would work?
Code:
moveq #2,D0 move.w data(PC,D0*2),D0 ... data: dc.w 0, 0, $ff |
26 May 2014, 18:39 | #9 |
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
|
In that case you can just stick to checking the AttnFlags in execbase, because the 68020 is supported since Kickstart 1.2, and this flag will be set during early startup.
|
26 May 2014, 19:35 | #10 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
ah ok, so the 68020 bit is set even for 68030+ as well
|
29 May 2014, 19:13 | #11 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
Yes, see hooverphonique's reply to my question. As I understand it the bit relevant to the cpu is set, aswell as the bits to all the earlier cpu's. So if a 68040 was detected, the flag for the 68040 and the flags for the 68030,68020 and 68010 would all be set. |
29 May 2014, 23:41 | #12 |
Glastonbridge Software
Join Date: Jan 2012
Location: Edinburgh/Scotland
Posts: 2,243
|
d'oh, looks like i've not been paying attention in class
|
03 June 2014, 23:30 | #13 |
AMOS Extensions Developer
Join Date: Jun 2007
Location: near Cambridge, UK
Age: 44
Posts: 1,924
|
|
06 June 2014, 01:10 | #14 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
I could upload my RigInfo source to Coppershade, there's no sure fire way to tell the diff between 040 and 060 easily tho.
|
06 June 2014, 09:20 | #15 | |
Registered User
Join Date: Apr 2014
Location: Germany
Posts: 154
|
Quote:
you can identify whether its a 060 or 040. pseudo_example: lea its_a_060,A0 move.l A0,illegalvector movep its_a_040 If you want to see whether your CPU support Scaling address mode then I would just prope it. moveq #1,D0 lea data,A0 move.b -1(A0,D0*2),D1 -- The value in D1 will tell you whether your CPU supports scaling data dc,b 0,1 EDIT just noticed someone posted the same before... |
|
06 June 2014, 10:31 | #16 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,505
|
I wouldn't use MOVEP because future "super" 68060 re-implementation may implement it (also UAE for performance reasons implements all instructions in fast CPU modes unless specifically disabled)
EDIT: Of course testing only for MOVEP to check if emulation is missing (=getting exception) instead of crashing is probably good enough reason to test it For best compatibility I'd use exact same tests that KS ROM and 68040/060 libraries use (because obviously any re-implementation must pass those tests correctly too!). Only use if there is really need for "low level" check. MOVEC to/from VBR -> 68000 if exception MOVEC CACR -> 68010 if exception Set 68020 inst cache bit in CACR, read it back, if still set, at least 68020+ Set 68030 data cache bit in CACR, read it back, if still set, must be 68030 Set 68040/060 inst cache bit in CACR, read it back, if set, at least 68040+ MOVEC from PCR -> 68040 (or older) if exception Last edited by Toni Wilen; 06 June 2014 at 11:39. |
06 June 2014, 13:45 | #17 |
Moderator
Join Date: Nov 2004
Location: Eksjö / Sweden
Posts: 5,602
|
Tests that pass current hardware is good enough, and emulators should not be considered when coding for Amiga.
Toni's last line there to diff 060 from 040 does the job though, so why not use it? Turns out RigInfo.S was already uploaded :P With the CPU bit being Code:
;---cpu---------- moveq #"6",d0 move.b $129(a5),d4 ;processorinfo bmi.s .go060 ;"default" subq.w #2,d0 btst #3,d4 bne.s .cpuok ;040 subq.w #1,d0 btst #2,d4 bne.s .cpuok ;030 subq.w #1,d0 btst #1,d4 bne.s .cpuok ;020 subq.w #1,d0 btst #0,d4 bne.s .cpuok ;010 subq.w #1,d0 ;000 .cpuok: |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
|
|