delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/09/21/10:15:15

From: "Carlo Bramini" <cbramix AT libero DOT it>
Newsgroups: comp.os.msdos.djgpp
Subject: Problem with multiplications
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Message-ID: <M2%i9.25731$Av4.488132@twister2.libero.it>
Date: Sat, 21 Sep 2002 14:07:40 GMT
NNTP-Posting-Host: 151.25.135.235
X-Complaints-To: abuse AT libero DOT it
X-Trace: twister2.libero.it 1032617260 151.25.135.235 (Sat, 21 Sep 2002 16:07:40 MET DST)
NNTP-Posting-Date: Sat, 21 Sep 2002 16:07:40 MET DST
Organization: [Infostrada]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi to eveyone,
I have a problem with DJGPP, but I'm going to think it's common with all
i386 target versions of this compiler.
I have two 32 bit numbers and I want to do:

c = (a*b) >> 32;

for getting the upper 32 bit DWORD.
Unfortunately, it doesn't work!
I have tried all possible options for optimization and from GCC 2.7.2.1. to
GCC 3.1, but I got a warning:

"warning: right shift count >= width of type"

and a code like that:

imul  eax,[ebp-8]
mov  ecx,32
sar    eax,cl

and it's a code that will never work!
If I apply a 'long long int' type to one of the operands I get the correct
result, but the compiler generates 4 multiplications instead of a single
one(!).
It's quite strange, because on other platforms I got correct results.
I tried MIPS, ARM, H8 and SH4, and it works as expected.
For example, on MIPS it calculates the MULT and then it copies rHI register
to the destination register.
I wonder why it didn't the same with EDX register for our Intels....
I would like to avoid an inline assembly function, because in my opinion it
isn't the best solution because Intel 386 and his successors can only use
EAX for target register, that's why the handling is a task of the compiler.
Last thing: the "-mno-wide-multiply" is not enabled.

What am I doing wrong?
Or is it not possible to do it?
Thanks in advance for all replies you guys will give to me.

Sincerely,

Carlo



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019