Mercurial > projects > ldc
view tests/mini/naked_asm6.d @ 954:e048e36bc155
Added support for using a temporary to implement emulated ABI return from inline asm, could be easier to use, but I think this will do. It's so extremely target dependent in any case that doing a completely generic approach seems hard.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Sat, 14 Feb 2009 15:25:48 +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); } }