Problem with unsigned multiplications



Hello group,

I have the following issue with multiplications. I have a MMX register
loaded with four signed words and I need to scale them using some
predefined scale factor. All my scale factors are less than 1, so I
multiply them by 65536 and now I have 4 unsigned constants.

So far, so good. Everything is good while my scale factors are less
then 0.5. I use pmulhw to obtain the results. I don't need to use
pmullw because its results contains no useful information for me.

Everything breaks whenever my scaling factors become 0.5 or greater.
The scaling factor value multiplied by 65536 has its most significant
bit set, which in turn treated by CPU as negative value. To overcome
this I need to find a module of my original values, use unsigned
multiply and then put the sign back. Wastes too much clock cycles, than
I can afford for this project.

Is there any way to overcome this issue? I feel it is possible, but I
don't see any clear way for that.

With best regards,
Vladimir S. MIrgorodsky

.



Relevant Pages

  • Re: rules of fixed-point arithmetic
    ... All fixed-point numbers have the same precision. ... keep your scale factors to powers of two, which is IMO not unreasonable, ... multiplications by arbitrary rational numbers. ... don't have to re-scale at all, except for when you reduce an accumulator ...
    (comp.arch)
  • Re: Problem with unsigned multiplications
    ... I have the following issue with multiplications. ... predefined scale factor. ... Is there any way to overcome this issue? ... Be careful about the ungood case of getting exactly 32768, which would wrap. ...
    (comp.lang.asm.x86)
  • Re: 120dpi setting for windows and dynamic added controls
    ... The scaling example is fine. ... dependent on the Windows default font used for the UI, ... This method calculated the relative scale sizes from ... user controls would scale correctly ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Button doesnt have to resize when the screen resolution is changed
    ... isn't telling the truth about it and that breaks the scaling. ... same size on screen, but the pictures that we ... made for the buttons don't scale to fit the button's size. ... Fonts do scale because they are vector based for modern ...
    (comp.lang.tcl)
  • Re: Windows Forms: Control.Scale(SizeF) does not work?
    ... I had a similar problem understanding Scale. ... the dimensions of everything that one time, ... since they will all be created before the first layout, ... After scaling happens, the original components will have their height ...
    (microsoft.public.dotnet.framework.compactframework)