Mixin in Inline Assembly

Era Scarecrow via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 1 05:00:45 PDT 2017


On Tuesday, 23 May 2017 at 03:33:38 UTC, Era Scarecrow wrote:
> From what I'm seeing, it should be 8, 0ch, 10h, then 14h, all 
> positive. I'm really scratching my head why I'm having this 
> issue...
>
> What am i missing here?

More experiments and i think it comes down to static arrays.

The following function code

int[4] fun2() {
     int[4] x = void;
     asm {
         mov dword ptr x, 100;
     }
     x[0] = 200; //get example of real offset
     return x;
}

Produces the following (from obj2asm)

int[4] x.fun2() comdat
         assume  CS:int[4] x.fun2()
                 enter   014h,0
                 mov     -4[EBP],EAX
                 mov     dword ptr -014h[EBP],064h
                 mov     EAX,-4[EBP]
                 mov     dword ptr [EAX],0C8h        // x[0]=200, 
offset +0
                 mov     EAX,-4[EBP]
                 leave
                 ret
int[4] x.fun2() ends


  So why is the offset off by 14h (20 bytes)? It's not like we 
need a to set a ptr first.

  Go figure i probably found a bug...


More information about the Digitalmars-d-learn mailing list