Andrei's Blog
Архив
« Июнь 2006 »
ПнВтСрЧтПтСбВс
   
1
2
3
4
5
6
7
8
9
10
11
13
14
15
16
17
18
19
20
21
23
24
25
26
27
29
  
       
Сегодня
XML
Search

Связи
 

Хиты страниц за сегодня: 52

Все | CMT | Gadgets | Other | RM | Solaris | Wireless
« Previous day (Jun 21, 2006) | Main | Next day (Jun 23, 2006) »
20060622 четверг Июнь 22, 2006
Opteron Easter Egg
If you have a system with AMD Opteron processor(s), then try running the following program on it:
#include  <stdio.h>

inline void cpuid(unsigned int op, unsigned int *eax, unsigned int
*ebx, unsigned int *ecx, unsigned int *edx)
{
   __asm__("cpuid"
   : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx)
   : "a" (op)
   : "cc");
}

int main(void)
{
   unsigned int eax,ebx,ecx,edx;
   unsigned int i=0;
   char array[17];
   char *cp=array;

   cpuid(0x8fffffff, &eax,&ebx,&ecx,&edx);

   for (i = 0; i < 4; i++)
       *cp++ = eax >> (8 * i);
   for (i = 0; i < 4; i++)
       *cp++ = ebx >> (8 * i);
   for (i = 0; i < 4; i++)
       *cp++ = ecx >> (8 * i);
   for (i = 0; i < 4; i++)
       *cp++ = edx >> (8 * i);
   *cp = 0;

   printf ("%s\n", array);
}
It can be easily compiled on Solaris with gcc:
$ /usr/sfw/bin/gcc -o opteron opteron.c

июн 22 2006, 06:06:56 PM PDT Permalink Комментарии [3]