x86-asm: Correct register size for pointer ops

A pointer is 64 bit as well, so it needs a full
register for register operands.
master
Michael Matz 2016-10-03 20:39:48 +02:00
parent 7ab35c6265
commit 0b0e64c2c9
2 changed files with 10 additions and 1 deletions

View File

@ -1493,7 +1493,8 @@ ST_FUNC void subst_asm_operand(CString *add_str,
else if ((sv->type.t & VT_BTYPE) == VT_SHORT)
size = 2;
#ifdef TCC_TARGET_X86_64
else if ((sv->type.t & VT_BTYPE) == VT_LLONG)
else if ((sv->type.t & VT_BTYPE) == VT_LLONG ||
(sv->type.t & VT_BTYPE) == VT_PTR)
size = 8;
#endif
else

View File

@ -2914,6 +2914,11 @@ void fancy_copy (unsigned *in, unsigned *out)
asm volatile ("" : "=r" (*out) : "0" (*in));
}
void fancy_copy2 (unsigned *in, unsigned *out)
{
asm volatile ("mov %0,(%1)" : : "r" (*in), "r" (out) : "memory");
}
void asm_test(void)
{
char buf[128];
@ -2987,6 +2992,9 @@ void asm_test(void)
val = 43;
fancy_copy (&val, &val2);
printf ("fancycpy(%d)=%d\n", val, val2);
val = 44;
fancy_copy2 (&val, &val2);
printf ("fancycpy2(%d)=%d\n", val, val2);
return;
label1:
goto label2;