<< OK Or Cancel? | Home | Transferring Tacit Knowledge >>

AMD64 Easter Egg

This is old news by now. But it may be new to you.

I mentioned this in one of the round table stand up meetings some months ago, but never got around to blog it. It's a little easter egg program for the AMD64. I saw it here 275 days ago.

The reason it took me this long is that I want to clean the program up a little bit to get rid of the high level C stuff. I got a copy of Richard Blum's Professional Assembly Language from the local SoftwarePlus store when it went out of business last month (and was practically giving their books away (buy one at half price and get a second one (of less or equal value) free)). And one of his first examples is a cpuid program. So I modified the sample program a little bit to run the AMD64 easter egg instruction:

.section .data
output:
  .ascii "The processor slogan is 'xxxxxxxxxxxxxxxx'\n"

.section .text
.globl _start
_start:
  movl $0x8fffffff, %eax
  cpuid

  movl $output, %edi
  movl %eax, 25(%edi)
  movl %ebx, 29(%edi)
  movl %ecx, 33(%edi)
  movl %edx, 37(%edi)

  movl $4, %eax
  movl $1, %ebx
  movl $output, %ecx
  movl $43, %edx
  int $0x80

  movl $1, %eax
  movl $0, %ebx
  int $0x80

It uses a couple of Linux system calls. Assemble, link and run it thusly:

[weiqi@gao]$ as -o cpuid.o cpuid.s
[weiqi@gao]$ ld -o cpuid cpuid.o
[weiqi@gao]$ ./cpuid
The processor slogan is 'IT'S HAMMER TIME'
Tags :



Add a comment Send a TrackBack