On Monday, 9 January 2017 at 02:31:42 UTC, Chris M. wrote:
Right now I'm working on a project where I'm implementing a VM
in D. I'm on the rotate instructions, and realized I could
*almost* abstract the ror and rol instructions with the
following function
private void rot(string ins)(int *op1, int op2)
{
int tmp = *op1;
asm
{
mov EAX, tmp; // I'd also like to know if I could just
load *op1 directly into EAX
mov ECX, op2[EBP];
mixin(ins ~ " EAX, CL;"); // Issue here
mov tmp, EAX;
}
*op1 = tmp;
}
don't forget to flag
asm pure nothrow {}
otherwise it's slow.