File: bug125959-x86.c

package info (click to toggle)
valgrind 1%3A3.12.0~svn20160714-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 120,428 kB
  • ctags: 70,855
  • sloc: ansic: 674,645; exp: 26,134; xml: 21,574; asm: 7,570; cpp: 7,567; makefile: 7,380; sh: 6,188; perl: 5,855; haskell: 195
file content (38 lines) | stat: -rw-r--r-- 626 bytes parent folder | download | duplicates (8)
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
31
32
33
34
35
36
37
38

#include <stdio.h>

unsigned char buf[256]; 

static int lookup ( int i )
{
  int block[3];
  block[0] = (int)&buf[0];
  block[1] = i;
  block[2] = 0;
  __asm__ __volatile__(
     "movl %0,%%esi\n\t"
     "movl 0(%%esi),%%ebx\n\t"
     "movl 4(%%esi),%%eax\n\t"
     "xlat\n\t"
     "movl %%eax,8(%%esi)\n\t"
     : : /*in*/"r"(block) : "esi", "ebx", "eax", "memory", "cc"
  );
  return block[2];
}

int main(void) 
{ 
  int i;
  unsigned j;

   for (i = 0; i < 256; i++) 
    buf[i] = (unsigned char) i;

   j = 0;
   for (i = 0; i < 130; i++) {
     printf("%08x\n", lookup(j));
     j += 0x01000001;
   }

   return 0; 
}