Page 1 of 1

Error: too many memory references for `bts'

Posted: Thu Dec 25, 2014 3:04 pm
by tsdnz
Hi, We compiling with no optimisations I get this error, when full optimistation is on there is no error message. Any ideas?

Code: Select all

DatabaseServer.cpp: Assembler messages:
1>  DatabaseServer.cpp:730: Error: too many memory references for `bts'
Here is inline code.

Code: Select all

#define Lock_BTS_onfail( ptr, _bit, fail_label ) { \
	volatile QWORD* __ptr = (volatile QWORD*)(ptr);   \
	asm goto( "lock btsq %0, %1 \t\n"           \
	"jnc %l[" #fail_label "] \t\n"               \
	: /* empty */                                \
	: "g" (_bit), "m" (*__ptr)       \
	: "memory", "cc"                             \
	: fail_label );                              \
}
And the routine is

Code: Select all

		FIL static void Lock(volatile void* pData, BYTE Bit)
		{
			volatile QWORD* pQWORD = (volatile QWORD*)pData;

			while (true)
			{
				Lock_BTS_onfail(pQWORD, Bit, fail);
				return;

fail:
				while ((*pQWORD) & ((QWORD)1 << Bit)) { }
			}
		}

Re: Error: too many memory references for `bts'

Posted: Thu Dec 25, 2014 3:44 pm
by xenos
The "g" constraint allows for a memory location - use "r" instead to force _bit into a register, or "rJ", which will alternatively allow a constant in the range 0-63.

Re: Error: too many memory references for `bts'

Posted: Thu Dec 25, 2014 4:19 pm
by tsdnz
Hi, I have tried other combinations as well, but no luck, not sure why??

Code: Select all

#define Lock_BTS_onfail( ptr, _bit, fail_label ) { \
	volatile QWORD* __ptr = (volatile QWORD*)(ptr);   \
	asm goto( "lock btsq %0, %1 \t\n"           \
	"jnc %l[" #fail_label "] \t\n"               \
	: /* empty */                                \
	: "rJ" (_bit), "m" (*__ptr)       \
	: "memory", "cc"                             \
	: fail_label );                              \
}

Re: Error: too many memory references for `bts'

Posted: Thu Dec 25, 2014 4:20 pm
by tsdnz
This works, but it is not what I need

Code: Select all

FIL static void Lock(volatile void* pData, BYTE Bit)
		{
			volatile QWORD* pQWORD = (volatile QWORD*)pData;

			while (true)
			{
				Lock_BTS_onfail(pQWORD, 63, fail);
				return;

fail:
				while ((*pQWORD) & ((QWORD)1 << Bit)) { }
			}
		}
But this does not??

Code: Select all

FIL static void Lock(volatile void* pData, BYTE Bit)
		{
			volatile QWORD* pQWORD = (volatile QWORD*)pData;

			while (true)
			{
				char aaa = 63;
				Lock_BTS_onfail(pQWORD, aaa, fail);
				return;

fail:
				while ((*pQWORD) & ((QWORD)1 << Bit)) { }
			}
		}

Re: Error: too many memory references for `bts'

Posted: Thu Dec 25, 2014 4:32 pm
by tsdnz
This is giving:

By the way I am in 64 bit mode.

Code: Select all

1>  DatabaseServer.cpp: Assembler messages:
1>  DatabaseServer.cpp:730: Error: operand type mismatch for `bts'
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Code: Select all

#define Lock_BTS_onfail( ptr, _bit, fail_label ) { \
	volatile QWORD* __ptr = (volatile QWORD*)(ptr);   \
	asm goto( "lock btsq %0, %1 \t\n"           \
	"jnc %l[" #fail_label "] \t\n"               \
	: /* empty */                                \
	: "rJ" (_bit), "m" (*__ptr)       \
	: "memory", "cc"                             \
	: fail_label );                              \
}

Re: Error: too many memory references for `bts'

Posted: Thu Dec 25, 2014 5:14 pm
by tsdnz
The answer is:

FIL static void Lock(volatile void* pData, QWORD Bit)

Change the Bit to QWORD LOL

Time for a new computer, development machine crashing almost every 5-10 minutes.

Thanks for your help XenOS