[Issue 12730] New: lea instruction accepts subtraction of scaling register but actually adds

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat May 10 21:17:12 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12730

          Issue ID: 12730
           Summary: lea instruction accepts subtraction of scaling
                    register but actually adds
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Keywords: iasm, wrong-code
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: dsimcha at yahoo.com

I ran into this while erroneously thinking that the lea instruction can be used
for three-operand subtraction of a register from another, as well as addition
and for subtraction of an immediate.  DMD accepts this code, but actually
performs addition.

import std.stdio;

void main() {
    uint a = 1;
    uint b = 2;
    uint c;
    asm {
        mov EAX, a;
        mov EBX, b;
        lea ECX, [EBX - EAX];
        mov c, ECX;
    }

    writeln(c);  // Prints 3 on both 32-bit and 64-bit
}

--


More information about the Digitalmars-d-bugs mailing list