http://d.puremagic.com/issues/show_bug.cgi?id=3421

           Summary: Inline assembler problems accessing static variables
           Product: D
           Version: 2.035
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: grahamc00...@yahoo.co.uk


--- Comment #0 from Graham <grahamc00...@yahoo.co.uk> 2009-10-19 08:03:19 PDT 
---
This code works in DMD v1.047 and fails in DMD v2.035

import std.stdio;

static int value1;

void main() {
    value1 = 2;
    asm {
        mov        EAX,1;
        mov        [value1],EAX;
    }
    writefln("value1 %d", value1);
}

The code generated in each case is:

Compiled under DMD v 1.047:

> u __Dmain l39
TEST03!__Dmain+0x0:
0x00402010  55               push         ebp                       
0x00402011  8bec             mov          ebp,esp                   
0x00402013  c705801445000200
            0000             mov          dword ptr [_D6test036value1i
(00451480)],00000002 
0x0040201d  b801000000       mov          eax,00000001              
0x00402022  a380144500       mov          dword ptr [_D6test036value1i
(00451480)],eax 
0x00402027  ff3580144500     push         dword ptr [_D6test036value1i
(00451480)] 
0x0040202d  ff3594b04400     push         dword ptr [_TMP0+00000004 (0044b094)] 
0x00402033  ff3590b04400     push         dword ptr [_TMP0 (0044b090)] 
0x00402039  b8f0b04400       mov          eax,0044b0f0              
0x0040203e  50               push         eax                       
0x0040203f  e830170000       call         _D3std5stdio8writeflnFYv (00403774) 
0x00402044  83c410           add          esp,10                    
0x00402047  5d               pop          ebp                       
0x00402048  c3               retn         
> 

Compiled under DMD v 2.0035:

> u __Dmain l43
TEST03!__Dmain+0x0:
0x00402010  55               push         ebp                       
0x00402011  8bec             mov          ebp,esp                   
0x00402013  53               push         ebx                       
0x00402014  64a12c000000     mov          eax,dword ptr fs:[0000002c] 
0x0040201a  8b08             mov          ecx,dword ptr [eax]       
0x0040201c  c781040000000200
            0000             mov          dword ptr [ecx+00000004],00000002 
0x00402026  b801000000       mov          eax,00000001              
0x0040202b  a304000000       mov          dword ptr [00000004],eax  
0x00402030  ff3594904200     push         dword ptr [_TMP0+00000004 (00429094)] 
0x00402036  ff3590904200     push         dword ptr [_TMP0 (00429090)] 
0x0040203c  648b152c000000   mov          edx,dword ptr fs:[0000002c] 
0x00402043  8b1a             mov          ebx,dword ptr [edx]       
0x00402045  8b8304000000     mov          eax,dword ptr [ebx+00000004] 
0x0040204b  e804000000       call        
_D3std5stdio19__T8writeflnTAyaTiZ8writeflnFAyaiZv (00402054) 
0x00402050  5b               pop          ebx                       
0x00402051  5d               pop          ebp                       
0x00402052  c3               retn         
>

The "D" code accesses 'value1' as dword ptr [ecx+00000004] and the inline
assember as dword ptr [00000004]

Is this a change in the language runtime specification for how module static
variables are accessed or it this a bug ?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to