D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5302 - Inline assembler: Indexing struct fields not possible inside member function
Summary: Inline assembler: Indexing struct fields not possible inside member function
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords: bootcamp, iasm
Depends on:
Blocks:
 
Reported: 2010-12-01 10:21 UTC by Harry Vennik
Modified: 2020-08-21 06:42 UTC (History)
5 users (show)

See Also:


Attachments
Failing code (184 bytes, text/plain)
2010-12-02 07:52 UTC, Harry Vennik
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Harry Vennik 2010-12-01 10:21:53 UTC
@ DMD 2.050

An instruction like:

mov EAX, Struct.field[EDX];

compiles OK in free functions, but when inside a member function, the compiler complains about a wrong type of 'this' for type Struct.
Comment 1 bearophile_hugs 2010-12-01 12:29:54 UTC
Please, if possible add a complete minimal program that shows the problem.
Comment 2 Harry Vennik 2010-12-02 07:52:48 UTC
Created attachment 836 [details]
Failing code
Comment 3 Harry Vennik 2010-12-02 07:55:26 UTC
Comment on attachment 836 [details]
Failing code

Compiling this results in the following error message:

iasm_test.d(15): Error: this for i needs to be type S not type iasm_test.A
iasm_test.d(15): bad type/size of operands '(__error).i'
Comment 4 Walter Bright 2020-08-20 08:48:46 UTC
The attachment:

module iasm_test;

struct S
{
    uint i;
}

class A
{
    uint func(S* s)
    {
        asm
        {
            mov     EDX, s;
            mov     EAX, S.i[EDX];
        }
    }
}
Comment 5 Walter Bright 2020-08-21 06:42:32 UTC
The parser for the iasm operator expressions is quite limited compared with the regular D expressions is quite limited. It is also different in order to be like the Intel assembler syntax. However, this case can be handled using:

    mov EAX, S.i.offsetof[EDX];

instead of:

    mov EAX, S.i[EDX];

Marked as invalid because there is a way to make it work.