4

When disassembling the .com file for the Color Dream demoscene production with ndisasm, I get the following output:

$ ndisasm color_dream.com | grep "fmul to" -B3 -A3 -m1
00000033  D9C1              fld st1
00000035  B00D              mov al,0xd
00000037  D9C0              fld st0
00000039  DCC9              fmul to st1
0000003B  D8CA              fmul st2
0000003D  D8C0              fadd st0
0000003F  D802              fadd dword [bp+si]

DCC9 is disassembled to fmul to st1 which also corresponds with this list from the Salent disassembler.

All is well so far.

However, when assembling the fmul to st1 instruction with yasm, I get:

error: unexpected `,' after instruction

Instead of the expected DCC9 machine code.

My question is:

How can I write fmul to st1 in a way that yasm will understand?

Alexander
  • 9,737
  • 4
  • 53
  • 59
  • 2
    That's a strange thing :-O Anyway, to get `DC C9` use `fmul st1, st0`. – Jester Jun 08 '17 at 12:04
  • Don't you have some macro "to" by accident? Try yasm -e (pre-process only) to verify you are trying to compile `fmul to st1`, and not something different. That said, I have no idea whether `fmul to st1` should work with yasm, I'm just curious about that error message, sounds completely unrelated at first sight, so that's why I'm suspecting some macro jumping in unexpectedly. – Ped7g Jun 08 '17 at 12:10
  • `fmul to st1` is a *very* strange representation of that instruction. I've never seen ndisasm use that, and I don't see "fmul to" showing up anywhere online, either. The normal representation for that instruction would be `fmul st1, st`. – Cody Gray - on strike Jun 08 '17 at 12:14
  • 1
    For the record, my ndisasm version 2.10.01 also produces the `fmul to st1` and of course nasm doesn't like it. – Jester Jun 08 '17 at 12:26
  • 4
    Seems like a bug in ndisasm then. You should be able to (within reason) pass the output of ndisasm into nasm without seeing errors. – Cody Gray - on strike Jun 08 '17 at 12:45
  • @Jester Thanks! Please convert your comment into an answer so that it can be accepted. @CodyGray What's the difference between `fmul st1, st0` and `fmul st1, st`? – Alexander Jun 08 '17 at 14:18
  • 1
    @Alexander There should be no difference. I happen to have the Intel manuals open so I can quote easily: "*using the expression ST(0), **or simply ST**, to represent the current stack top and ST(i) to specify the ith register from TOP*" – Margaret Bloom Jun 08 '17 at 14:52
  • 1
    I have a book somewhere from decades ago that used this syntax. NASM took on this syntax and is documented. YASM although like NASM has differences. NDISASM is part of NASM. If YASM doesn't support it then it is a deficiency of that product (and where I'd send the inquiry). My YASM 1.2.0 deals with this syntax okay, and my NASM 2.11.05 works as well. – Michael Petch Jun 08 '17 at 20:57
  • 1
    They are the same, Alexander. The "0" is optional. Some assemblers use it, some don't, some accept both forms. `st` and `st0` always mean the same thing. So does `st(0)` (the parentheses are used in Intel syntax, but are less common on Gnu/Linux assemblers). – Cody Gray - on strike Jun 09 '17 at 09:30

0 Answers0