Crash - Launch a new game - ZDoom for Linux

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post by Blzut3 »

Is there a particular way you want me to do this? I can probably disassemble r_main.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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.
Guest

Re: Crash - Launch a new game - ZDoom for Linux

Post 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
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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;
} 
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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;
}  
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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.
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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?
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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;
Blzut3
 
 
Posts: 3144
Joined: Wed Nov 24, 2004 12:59 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post 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.
User avatar
randi
Site Admin
Posts: 7746
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: Crash - Launch a new game - ZDoom for Linux

Post by randi »

Alright. Sounds good.
nerotriple6
Posts: 37
Joined: Fri May 13, 2011 3:09 pm

Re: Crash - Launch a new game - ZDoom for Linux

Post by nerotriple6 »

Cool, thanks a lot! :wub:

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?
Edward-san
Posts: 1774
Joined: Sat Oct 17, 2009 9:40 am

Re: Crash - Launch a new game - ZDoom for Linux

Post by Edward-san »

You should update the svn revision and recompile. This is all :P
nerotriple6
Posts: 37
Joined: Fri May 13, 2011 3:09 pm

Re: Crash - Launch a new game - ZDoom for Linux

Post by nerotriple6 »

Wicked. Thanks for fixing guys! :mrgreen: :twisted:
Post Reply

Return to “Closed Bugs [GZDoom]”