ASM access to array

Heinz malagana15 at yahoo.com
Tue Feb 1 14:47:38 PST 2011


Wow, thanks for the reply. Changing the 'enum dsize' to 'uint dsize = 4;' seems to
produce some results...i guess it's working now (i have no way to verify it is
working but looks like bits are being rotated by rol). One thing, if i replace
dsize with 4 in all lines, the code compiles but again it does nothing, weird uh?

Is D_InlineAsm_X86 really needed? I saw it is listed in the predefined versions
table. Is this version for custom use or is it used internally by the compiler to
specify that inline ASM is available or not? Inline ASM is always available right?

Anyway, thanks for the code. I was wondering: Is there any other way to directly
use operands with class members, array items in this case? I mean, for variables
local to functions i use the variables as if they were in a D code statement, but
in your code we have to create local variables and move them between registers,
the values are moved too.

// LOCAL VARIABLE EXAMPLE
void MyFunct()
{
    uint temp;
    asm
    {
        rol temp, 8;
    }
}

If i'm going to create local pointers and constants and move them across registers
then, to accomplish the same result, would it be better (or the same) to create 2
local ints, rol them and then move them to their respective place (this way the
compiler might generate better code):

// EXAMPLE
class MyClass
{
    private uint[] array;

    private void MyFunc()
    {
        uint a = array[0], b = array[1];
        asm
        {
            rol a, 8;
            rol b, 16
        }
        array[0] = a;
        array[1] = b;
    }
}

Thanks 4 everything!!!!!!!!!!!


More information about the Digitalmars-d-learn mailing list