source: http://www3.intel.com/cd/ids/developer/asmo-na/eng/257129.htm
by Eric Palmer
When targeting x64 platforms in Visual Studio .NET* 2005, programmers are no longer able to use inline assembly code as they did for 32-bit code. This forces the programmer to either rely on C/C++ code using intrinsics, or to tediously create a 64-bit MASM (.asm) version of the function. Unfortunately, the VS .Net 2005 implementation of the intrinsic for CPUID (__cpuid) recognizes only input arguments in the register eax, and not the more recently defined inputs in ecx, which are required for queries regarding cache parameters and certain multi-core characteristics. Thus, a 64-bit .asm listing is required for full use of the CPUID instruction. The following code samples demonstrate how to use the CPUID and RDTSC instructions with VS .Net 2005 for 64-bit (x64) platforms. The CPUID instruction is commonly used to obtain detailed information about the system’s CPU(s), and RDTSC is used to read the CPU’s internal time-stamp counter for timing and performance-measurement purposes. The RDTSC intrinsic (__rdtsc) does work as expected and can be used to replace inline assembly. To build the 64-bit .asm file, create a custom build step that calls the 64-bit MASM, "ml64.exe", as shown in the screen-shot below. For the 32-bit configuration, the cpuid64.asm file should not be built, so for platform Win32, set General -> Excluded From Build to Yes.
32/64-bit .c file (cpuid_32_64.c):
64-bit .asm file (cpuid64.asm):
We invite you to post a comment
(not monitored by customer support) on this page or send
a question directly to our support team.
isn.support@intel.com (2007-01-10T23:30:54.810) wrote:
New code sample posted for platform topology enumeration on IA-64: http://www3.intel.com/cd/ids/developer/asmo-na/eng/dc/itanium/335391.htm
isn.support@intel.com (2007-01-02T21:02:38.657) wrote:
nivedan_nigam, one of our engineers responds: I have tried the SIV on IA-64 from the following link – it seems to provide a lot of info: http://siv.mysite.orange.co.uk/index.html
nivedan_nigam@rediffmail.com (2006-12-22T04:04:45.123) wrote:
Is cpucount program is avilable for IA64 platform. Any pointeres
isn.support@intel.com (2006-10-19T21:20:59.993) wrote:
To find similar information for IA-32 platforms, see Khang Nguyen and Shihjong Kuo's article "Detecting Multi-Core Processor Topology in an IA-32 Platform": http://www3.intel.com/cd/ids/developer/asmo-na/eng/275339.htm |