News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

fmul bug

Started by Biterider, June 29, 2022, 03:43:12 AM

Previous topic - Next topic

Biterider

Hi
If you code fmul without arguments, UASM accepts the mnemonic but translates it to fmulp

Debugger output
  fmul
DE C9                fmulp       st(1),st


The workaround is to add some arguments like
fmul st(0), st(1)


Biterider

jj2007

  fld1
  fldpi
  int 3
  fmul


MASM 6.15, 15.0, UAsm:
004010B1  |.  D9E8          fld1
004010B3  |.  D9EB          fldpi
004010B5  |.  CC            int3
004010B6  |.  DEC9          fmulp st(1), st                          ; float 3.1415926535897932380 (const PI)

HSE

Quote from: Biterider on June 29, 2022, 03:43:12 AM
If you code fmul without arguments, UASM accepts the mnemonic but translates it to fmulp

There is no fmul without arguments, is just an alias of fmulp, Same thing happen with fadd, fsub and fdiv  :thumbsup:
Equations in Assembly: SmplMath

jj2007

Random statistics from a major source:
110*fmul, of which 3*fmul ST, ...
67*fadd, of which 2*fadd ST, ...
67*fsub, of which 0*fsub ST...

The non-popping instructions are just not that popular :cool:

HSE

Quote from: jj2007 on June 29, 2022, 06:42:35 AM
The non-popping instructions are just not that popular :cool:

:biggrin: They are very popular in the form "fadd variable", etc.
Equations in Assembly: SmplMath

raymond

I would NOT consider it as a BUG unless you are using some weird assembler.

The MASM assembler has never interpreted any of the arithmetic float instructions without operands otherwise but to mean popping the top register after performing the operation on the top two registers ST0 and ST1. This applies to fadd, fsub, fmul and fdiv.

And I would expect that most other assemblers would be following the same rule.
Whenever you assume something, you risk being wrong half the time.
http://www.ray.masmcode.com

quarantined

Quote from: raymond on June 29, 2022, 01:28:59 PM
I would NOT consider it as a BUG unless you are using some weird assembler.
Like uasm? lol
I never use anything other than good old (literally) masm from the masm32 SDK myself. Don't understand the need for these other variants (uasm, jwasm, etc...) if masm already does what is expected from it.

jj2007

Quote from: raymond on June 29, 2022, 01:28:59 PMI would expect that most other assemblers would be following the same rule.

UAsm and AsmC behave exactly the same, and always have done so. As Hector wrote above, fmul is an alias for fmulp.