Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

elis-cool

cpuid

This topic is 5516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

im working on my own CPUID function, and its working good (what I have) so far, except one thing, its not returning the brand index correctly, on my p4 2.53GHz it returns 9, and on shil''s p4 Mobile it returned 22, but the index for a p4 is 8...
// nasm win32 syntax

segment .text
	
	;// Aligned on a one byte boundry:

	;//	struct CPUID

	;//	{

	;//		char szVenderId[16];

	;//		unsigned long dwFeatureFlags;

	;//		unsigned char ucBrandIndex;

	;//		unsigned char ucNumLogicalProcessors;

	;//		unsigned char ucLocalApicId;

	;//	};


	;// int _api_cpuid(CPUID* pInfo)

	global _api_cpuid
	
	;// Stack frame:

	;	pInfo @ ebp+8
	;	ret addr @ ebp+4
	;	old ebp @ ebp

_api_cpuid:
	push ebp
	mov ebp, esp
	pusha

	xor eax, eax
	cpuid
	mov eax, [ebp+8]

	mov [eax], ebx		; szVenderId
	mov [eax+4], edx
	mov [eax+8], ecx
	mov [eax+12], dword 0

	mov eax, 1
	cpuid	
	mov ecx, [ebp+8]

	mov [ecx+16], edx		; dwFeatureFlags
	mov byte [ecx+20], bl	; ucBrandIndex // here it is!!!!


	mov edx, ebx
	and edx, 00000000111111110000000000000000b	; bits 16-23 ucNumLogicalProcessors
	shr edx, 16
	mov byte [ecx+21], dl	; ucNumLogicalProcessors

	popa
	mov eax, dword 1
	pop ebp
	ret

MasterDepot

Share this post


Link to post
Share on other sites
Advertisement
Well, it''s actually good that you have a 9. That''s because according to http://www.sandpile.org/ia32/cpuid.htm that''s a .13 micron chip instead of an .18 micron one. So it''s right, no error in your code.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!