This commit is contained in:
bellard
2003-04-14 22:23:55 +00:00
parent c5ab452d64
commit 0d6f8021ee
4 changed files with 30 additions and 4 deletions

View File

@ -1841,6 +1841,20 @@ static __inline__ __const__ unsigned int swab32(unsigned int x)
:"=q" (x)
: "0" (x));
return x;
}
static __inline__ unsigned long long mul64(unsigned int a, unsigned int b)
{
unsigned long long res;
__asm__("mull %2" : "=A" (res) : "a" (a), "r" (b));
return res;
}
static __inline__ unsigned long long inc64(unsigned long long a)
{
unsigned long long res;
__asm__("addl $1, %%eax ; adcl $0, %%edx" : "=A" (res) : "A" (a));
return res;
}
unsigned int set;
@ -1849,10 +1863,17 @@ void asm_test(void)
{
char buf[128];
unsigned int val;
printf("inline asm:\n");
/* test the no operand case */
asm volatile ("xorl %eax, %eax");
memcpy1(buf, "hello", 6);
strncat1(buf, " worldXXXXX", 3);
printf("%s\n", buf);
/* 'A' constraint test */
printf("mul64=0x%Lx\n", mul64(0x12345678, 0xabcd1234));
printf("inc64=0x%Lx\n", inc64(0x12345678ffffffff));
set = 0xff;