Thread overview
[Issue 2617] asm silently accepts ambiguous-sized operations
Aug 21, 2020
Walter Bright
Aug 21, 2020
Vladimir Panteleev
Aug 21, 2020
Walter Bright
Aug 21, 2020
Walter Bright
Aug 21, 2020
Walter Bright
Aug 21, 2020
Dlang Bot
Aug 24, 2020
Dlang Bot
June 10, 2015
https://issues.dlang.org/show_bug.cgi?id=2617

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1 & D2                     |D2

--
October 14, 2016
https://issues.dlang.org/show_bug.cgi?id=2617

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |bootcamp
                 CC|                            |andrei@erdani.com

--
August 21, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> ---
The following code:

  uint func()
  {
    asm
    {
        naked;
        inc [EAX];
        inc byte ptr [EAX];
        inc short ptr [EAX];
        inc int ptr [EAX];
        inc long ptr [EAX];
    }
  }

generates:

  __D5test24funcFZk:
        inc     byte ptr [EAX]
        inc     byte ptr [EAX]
        inc     word ptr [EAX]
        inc     dword ptr [EAX]
        inc     byte ptr [EAX]   <== !!!!!

That last is certainly a problem; it should be rejected by the compiler. As for the first instruction, I'm concerned about changing the behavior. Messing with people's existing, working asm code is risky.

--
August 21, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

--- Comment #6 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to Walter Bright from comment #5)
> As for the first instruction, I'm concerned about changing the behavior. Messing with people's existing, working asm code is risky.

See issue 7388. The problem is that if you copy/paste code from another program, you'll get a different result. It probably should be deprecated, forcing users to explicitly specify the operand size.

--
August 21, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=21181

--
August 21, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> ---
(In reply to Walter Bright from comment #5)
> The following code:
> 
>   uint func()
>   {
>     asm
>     {
> 	naked;
> 	inc long ptr [EAX];
>     }
>   }
> 
> generates:
> 
>   __D5test24funcFZk:
>         inc     byte ptr [EAX]   <== !!!!!
> 

Filed as https://issues.dlang.org/show_bug.cgi?id=21181 so as not to confuse this issue.

--
August 21, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> ---
Looking at my ancient Intel 8088 manual, it says:

    INC [BX]

is ambiguous and so must use BYTE PTR or WORD PTR. Since the behavior of iasm is modeled after Intel's syntax, that pretty much settles it.

--
August 21, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #11603 "fix Issue 2617 - asm silently accepts ambiguous-sized operations" fixing this issue:

- fix Issue 2617 - asm silently accepts ambiguous-sized operations

https://github.com/dlang/dmd/pull/11603

--
August 24, 2020
https://issues.dlang.org/show_bug.cgi?id=2617

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #10 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11603 "fix Issue 2617 - asm silently accepts ambiguous-sized operations" was merged into master:

- c4805400cdb7a31a07941e5fb741bbbb02b96def by Walter Bright:
  fix Issue 2617 - asm silently accepts ambiguous-sized operations

https://github.com/dlang/dmd/pull/11603

--