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
14931493 else if ((sv->type.t & VT_BTYPE) == VT_SHORT)
14941494 size = 2;
14951495 #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)
14971498 size = 8;
14981499 #endif
14991500 else
tests/tcctest.c+8−0
@@ -2914,6 +2914,11 @@ void fancy_copy (unsigned *in, unsigned *out) · 2913 unmodified lines
29142914 asm volatile ("" : "=r" (*out) : "0" (*in));
29152915 }
29162916
2917+void fancy_copy2 (unsigned *in, unsigned *out)
2918+{
2919+ asm volatile ("mov %0,(%1)" : : "r" (*in), "r" (out) : "memory");
2920+}
2921+
29172922 void asm_test(void)
29182923 {
29192924 char buf[128];
@@ -2987,6 +2992,9 @@ void asm_test(void) · 67 unmodified lines
29872992 val = 43;
29882993 fancy_copy (&val, &val2);
29892994 printf ("fancycpy(%d)=%d\n", val, val2);
2995+ val = 44;
2996+ fancy_copy2 (&val, &val2);
2997+ printf ("fancycpy2(%d)=%d\n", val, val2);
29902998 return;
29912999 label1:
29923000 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