view tests/mini/asm1_1.d @ 1168:ab186e535e72

A different fix to #218 and DMD2682 that does not lead to constant folding regressions. Fixes run/const_15, run/c/const_16_B. The price is removing the lvalueness of struct literals. If it turns out too much code depends on this behavior or we don't want to break with DMD, we could keep struct literals as lvalues and instead convert struct literals used as expression initializers into struct initializers.
author Christian Kamm <kamm incasoftware de>
date Sun, 29 Mar 2009 11:43:45 +0200
parents 12b423e17860
children 08f87d8cd101
line wrap: on
line source

module tangotests.asm1_1;

extern(C) int printf(char*, ...);

int main()
{
    int i = 12;
    int* ip = &i;
    printf("%d\n", i);
    version (D_InlineAsm_X86)
    {
	asm
    	{
		mov EBX, ip;
        	mov EAX, [EBX];
        	add EAX, 8;
        	mul EAX, EAX;
        	mov [EBX], EAX;
    	}
    }
    else version (D_InlineAsm_X86_64)
    {
	asm
	{ 
		movq RCX, ip;
		movq RAX, [RCX];
		add RAX, 8;
		imul RAX, RAX;
		movq [RCX], RAX;
	}
    }
    printf("%d\n", i);
    assert(i == 400);
    return 0;
}