view tests/mini/naked_asm6.d @ 979:523bf4f166bc

Fix some assembler issues: The assembler was miscompiling "add" (specifically, the "add reg/mem, imm" variations). The change that caused this seems to have been made because without it, some "add"s didn't compile at all. This patch reverts the previous change, and makes sure assembler operands are remapped correctly even though the input operands auto-generated due to updating operations aren't explicitly used.
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 18 Feb 2009 21:46:14 +0100
parents 97688ff7cf93
children 855889b7b268
line wrap: on
line source

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

ulong retval() {
    version (X86)
    asm { naked; mov EAX, 0xff; mov EDX, 0xaa; ret; }
    else version (X86_64)
    asm { naked; mov EAX, 0xff; mov EDX, 0xaa; ret; }
}

ulong retval2() {
    return (cast(ulong)0xaa << 32) | 0xff;
}

void main() {
    ulong a,b;
    a = retval();
    b = retval2();
    printf("%llu\n%llu\n", retval(), retval2());
    version (X86)
    {
    assert(a == 0x000000aa000000ff);
    assert(a == b);
    }
    else version (X86_64)
    {
    assert(a == 0xff);
    assert(b == 0x000000aa000000ff);
    }
}