1 #include <stdio.h>
2
3 static signed int test[] ={
4 0,
5 1,
6 -1,
7 0x7fffffff,
8 0x80000000,
9 0x12345678,
10 0x87654321,
11 0x55555555,
12 0x11111111,
13 0xaaaaaaaa,
14 };
15
16
hex_to_dec(signed int num)17 static unsigned long hex_to_dec(signed int num)
18 {
19 unsigned long addr = 0;
20
21 asm volatile(
22 " cvd %2,%0"
23 : "=m" (addr) : "a" (&addr) , "d" (num) : "memory");
24 return addr;
25 }
26
main()27 int main()
28 {
29 int i;
30
31 for (i = 0; i < sizeof(test) / sizeof(test[0]); i++)
32 printf("%lx\n", hex_to_dec(test[i]));
33 return 0;
34 }
35