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

Связи
 

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

Все | CMT | Gadgets | Other | RM | Solaris | Wireless
« CPU Caps Beta refres... | Main | Asterisk PBX on... »
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]

Комментарии:

Nice. "Can't touch this"! For those that don't have quick access to an Opteron:
  % gcc -o opteron opteron.c
  $ opteron
  IT'S HAMMER TIME
And now I recall that "Hammer" was the Opteron code name.

опубликовал The Gadster Июнь 22, 2006 at 06:41 PM PDT #

too many semicolons in: cpuid(0x8fffffff, &eax;,&ebx;,&ecx;,&edx;); ?

опубликовал Dick Davies Июнь 23, 2006 at 03:21 AM PDT #

ha! ignore me - it's the RSS feed mistaking them for character entities and 'fixing' them :)

опубликовал Dick Davies Июнь 23, 2006 at 03:23 AM PDT #

Опубликовать комментарий:

Комментарии запрещены.