Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
tsdnz
Member
Posts: 333 Joined: Sun Jun 16, 2013 4:09 am
Post
by tsdnz » Thu Dec 25, 2014 3:04 pm
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)) { }
}
}
xenos
Member
Posts: 1121 Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:
Post
by xenos » Thu Dec 25, 2014 3:44 pm
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.
tsdnz
Member
Posts: 333 Joined: Sun Jun 16, 2013 4:09 am
Post
by tsdnz » Thu Dec 25, 2014 4:19 pm
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 ); \
}
tsdnz
Member
Posts: 333 Joined: Sun Jun 16, 2013 4:09 am
Post
by tsdnz » Thu Dec 25, 2014 4:20 pm
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)) { }
}
}
tsdnz
Member
Posts: 333 Joined: Sun Jun 16, 2013 4:09 am
Post
by tsdnz » Thu Dec 25, 2014 4:32 pm
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 ); \
}
tsdnz
Member
Posts: 333 Joined: Sun Jun 16, 2013 4:09 am
Post
by tsdnz » Thu Dec 25, 2014 5:14 pm
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