History

x86-asm: Correct register size for pointer ops

A pointer is 64 bit as well, so it needs a full register for register operands.

Michael Matz committed 10 years ago

Commit 0b0e64c1 parent 7ab35c62 files · +10 −1Browse files

Unified · Split

2 files
  1. i386-asm.c +2 −1
  2. tests/tcctest.c +8 −0
i386-asm.c+2−1
@@ -1493,7 +1493,8 @@ ST_FUNC void subst_asm_operand(CString *add_str, · 1492 unmodified lines
1493 else if ((sv->type.t & VT_BTYPE) == VT_SHORT)1493 else if ((sv->type.t & VT_BTYPE) == VT_SHORT)
1494 size = 2;1494 size = 2;
1495#ifdef TCC_TARGET_X86_641495#ifdef TCC_TARGET_X86_64
1496 else if ((sv->type.t & VT_BTYPE) == VT_LLONG)1496 else if ((sv->type.t & VT_BTYPE) == VT_LLONG ||
1497 (sv->type.t & VT_BTYPE) == VT_PTR)
1497 size = 8;1498 size = 8;
1498#endif1499#endif
1499 else1500 else
tests/tcctest.c+8−0
@@ -2914,6 +2914,11 @@ void fancy_copy (unsigned *in, unsigned *out) · 2913 unmodified lines
2914 asm volatile ("" : "=r" (*out) : "0" (*in));2914 asm volatile ("" : "=r" (*out) : "0" (*in));
2915}2915}
2916 2916
2917void fancy_copy2 (unsigned *in, unsigned *out)
2918{
2919 asm volatile ("mov %0,(%1)" : : "r" (*in), "r" (out) : "memory");
2920}
2921
2917void asm_test(void)2922void asm_test(void)
2918{2923{
2919 char buf[128];2924 char buf[128];
@@ -2987,6 +2992,9 @@ void asm_test(void) · 67 unmodified lines
2987 val = 43;2992 val = 43;
2988 fancy_copy (&val, &val2);2993 fancy_copy (&val, &val2);
2989 printf ("fancycpy(%d)=%d\n", val, val2);2994 printf ("fancycpy(%d)=%d\n", val, val2);
2995 val = 44;
2996 fancy_copy2 (&val, &val2);
2997 printf ("fancycpy2(%d)=%d\n", val, val2);
2990 return;2998 return;
2991 label1:2999 label1:
2992 goto label2;3000 goto label2;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t