Mercurial > projects > ldc
view tests/mini/naked_asm6.d @ 978:6a32d2e18175
Fix a latent bug in the asm code.
I think that technically, using "*m0" instead of "*0" allows LLVM to pick
between using the same memory as output 0 and using a new memory location.
(So far I haven't been able to construct a testcase that actually breaks
because of this, though)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Wed, 18 Feb 2009 03:38:12 +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); } }