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, j;
     26    for (i = 0; i < 256; i++)
     27     buf[i] = (unsigned char) i;
     28 
     29    j = 0;
     30    for (i = 0; i < 130; i++) {
     31      printf("%08x\n", lookup(j));
     32      j += 0x01000001;
     33    }
     34 
     35    return 0;
     36 }
     37