Page 6 of 6
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Sun Jun 12, 2011 11:50 pm
by Blzut3
Is there a particular way you want me to do this? I can probably disassemble r_main.
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Mon Jun 13, 2011 4:47 pm
by Blzut3
Here's the output from the disassembler for a version which works (MAKECONSTDivScale(32)) and the broken function. The line numbers may be a little off due to my modifications but you can find DivScale32() in there.
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Mon Jun 13, 2011 6:39 pm
by Guest
Hi !
Years later, I have the same problem (divide by 0) and I don't understand the fix in "r_main.cpp" or in "gccinlines.h"
Could you give me more precisions ?
Thanx
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Mon Jun 13, 2011 6:59 pm
by randi
What happens if you change it to this?
Code: Select all
static inline SDWORD DivScale32 (SDWORD a, SDWORD b)
{
SDWORD result, dummy;
asm volatile
("idivl %3"
:"=&a,a" (result),
"=d,d" (dummy)
: "a,a" (0),
"d,d" (a),
"r,m" (b)
: "%cc");
return result;
}
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Mon Jun 13, 2011 8:08 pm
by Blzut3
Code: Select all
/home/blzut3/Code/ZDoom/src/gccinlines.h: In member function ‘virtual void AActor::Tick()’:
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: can't find a register in class ‘AREG’ while reloading ‘asm’
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: can't find a register in class ‘AREG’ while reloading ‘asm’
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: can't find a register in class ‘AREG’ while reloading ‘asm’
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: ‘asm’ operand has impossible constraints
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: ‘asm’ operand has impossible constraints
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: ‘asm’ operand has impossible constraints
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: ‘asm’ operand has impossible constraints
/home/blzut3/Code/ZDoom/src/gccinlines.h:292:15: error: ‘asm’ operand has impossible constraints
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Mon Jun 13, 2011 9:00 pm
by randi
Okay, what about this?
Code: Select all
static inline SDWORD DivScale32 (SDWORD a, SDWORD b)
{
SDWORD result, dummy;
int zero = 0;
asm volatile
("idivl %3"
:"=&a,a" (result),
"=d,d" (dummy)
: "a,a" (zero),
"d,d" (a),
"r,m" (b)
: "%cc");
return result;
}
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Mon Jun 13, 2011 10:05 pm
by Blzut3
Same, only a line lower.
Edit: changing it to "idivl %4" and dropping the ampersand on the result line works (latter fixes the errors, former to avoid a different division by zero error). You can even use (0) per the first attempt as well this way. I, of course, have no idea what I'm doing, but that's what works.
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Fri Jun 17, 2011 6:38 pm
by Blzut3
Randy, do you want me to go ahead and commit what I have working or do you intend to find a better solution?
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Fri Jun 17, 2011 10:51 pm
by randi
Sorry, I forgot about this.
How does this fare:
Code: Select all
static inline SDWORD DivScale32 (SDWORD a, SDWORD b)
{
SDWORD result, dummy;
asm volatile
("xor %%eax,%%eax\n\t"
"idivl %3"
:"=&a,&a" (result),
"=d,d" (dummy)
: "d,d" (a),
"r,m" (b)
: "%cc");
return result;
}
Actually, I think I like this version better:
Code: Select all
int result = 0, dummy;
asm volatile
("idivl %3"
:"+a,a" (result),
"=d,d" (dummy)
: "d,d" (a),
"r,m" (b)
: "%cc");
return result;
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Fri Jun 17, 2011 11:18 pm
by Blzut3
Seems to work.
Edit: Still need to check the 2nd version. It will take awhile though since my 32-bit laptop isn't very fast.
Edit 2: Second version works as well.
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Fri Jun 17, 2011 11:44 pm
by randi
Alright. Sounds good.
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Wed Jun 22, 2011 11:48 am
by nerotriple6
Cool, thanks a lot!
Sorry but I just found this thread, relocated. Anywhoo, does it work to compile it normally now or is there some hocus pocus to be done?
Re: Crash - Launch a new game - ZDoom for Linux
Posted: Wed Jun 22, 2011 2:26 pm
by Edward-san
You should update the svn revision and recompile. This is all

Re: Crash - Launch a new game - ZDoom for Linux
Posted: Wed Jun 22, 2011 5:11 pm
by nerotriple6
Wicked. Thanks for fixing guys!
