LDC inline assembler

Mike via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Wed May 6 06:31:06 PDT 2015


On Wednesday, 6 May 2015 at 10:31:15 UTC, Kai Nacke wrote:
> Hi Mike!
>
> This should do the trick:
>
> extern(C) ulong dosyscall(ulong a, ulong b, ulong c)
> {
>     import ldc.llvmasm;
>
>     ulong result = __asm!ulong("syscall", 
> "={rax},{rax},{rdi},{rsi},{rdx},~{rcx},~{r11}", 1, a, b, c);
>     return result;
> }
>
> A named register must be surrounded with { }. If any register 
> is ok then you can use simply r. As far as I know there is no 
> way that to tell LLVM that a memory range is clobbered.
>
> Regardsm
> Kai

Thank you! It works great. I added it to the Wiki for future 
reference:
http://wiki.dlang.org/LDC_inline_assembly_expressions

Mike


More information about the digitalmars-d-ldc mailing list