Home | History | Annotate | Download | only in x86
      1 
      2 #include <stdio.h>
      3 
      4 unsigned char buf[256];
      5 
      6 static int lookup ( int i )
      7 {
      8   int block[3];
      9   block[0] = (int)&buf[0];
     10   block[1] = i;
     11   block[2] = 0;
     12   __asm__ __volatile__(
     13      "movl %0,%%esi\n\t"
     14      "movl 0(%%esi),%%ebx\n\t"
     15      "movl 4(%%esi),%%eax\n\t"
     16      "xlat\n\t"
     17      "movl %%eax,8(%%esi)\n\t"
     18      : : /*in*/"r"(block) : "esi", "ebx", "eax", "memory", "cc"
     19   );
     20   return block[2];
     21 }
     22 
     23 int main(void)
     24 {
     25   int i;
     26   unsigned j;
     27 
     28    for (i = 0; i < 256; i++)
     29     buf[i] = (unsigned char) i;
     30 
     31    j = 0;
     32    for (i = 0; i < 130; i++) {
     33      printf("%08x\n", lookup(j));
     34      j += 0x01000001;
     35    }
     36 
     37    return 0;
     38 }
     39