Jump to content
  • Advertisement


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



This topic is 5604 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

	push ebp
	mov ebp, esp

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

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

	mov eax, 1
	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

	mov eax, dword 1
	pop ebp


Share this post

Link to post
Share on other sites
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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!