Author Topic: fmul bug  (Read 499 times)

Biterider

  • Member
  • ****
  • Posts: 974
  • ObjAsm Developer
    • ObjAsm
fmul bug
« on: June 29, 2022, 03:43:12 AM »
Hi
If you code fmul without arguments, UASM accepts the mnemonic but translates it to fmulp

Debugger output
Code: [Select]
  fmul
DE C9                fmulp       st(1),st

The workaround is to add some arguments like
Code: [Select]
fmul st(0), st(1)

Biterider

jj2007

  • Member
  • *****
  • Posts: 12944
  • Assembler is fun ;-)
    • MasmBasic
Re: fmul bug
« Reply #1 on: June 29, 2022, 05:01:46 AM »
Code: [Select]
  fld1
  fldpi
  int 3
  fmul

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

HSE

  • Member
  • *****
  • Posts: 2187
  • AMD 7-32 / i3 10-64
Re: fmul bug
« Reply #2 on: June 29, 2022, 06:08:11 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

  • Member
  • *****
  • Posts: 12944
  • Assembler is fun ;-)
    • MasmBasic
Re: fmul bug
« Reply #3 on: June 29, 2022, 06:42:35 AM »
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

  • Member
  • *****
  • Posts: 2187
  • AMD 7-32 / i3 10-64
Re: fmul bug
« Reply #4 on: June 29, 2022, 06:59:21 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

  • Member
  • ***
  • Posts: 309
    • Raymond's page
Re: fmul bug
« Reply #5 on: June 29, 2022, 01:28:59 PM »
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

  • Guest
Re: fmul bug
« Reply #6 on: June 30, 2022, 01:48:04 AM »
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

  • Member
  • *****
  • Posts: 12944
  • Assembler is fun ;-)
    • MasmBasic
Re: fmul bug
« Reply #7 on: June 30, 2022, 02:32:14 AM »
I 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.