ASM access to array

bearophile bearophileHUGS at lycos.com
Tue Feb 1 16:44:57 PST 2011


Heinz:

>(i have no way to verify it is working but looks like bits are being rotated by rol).<

Create an unittest and test if the output-input pairs are correct.


>Is D_InlineAsm_X86 really needed?<

Someday D will run on other CPUs, like 64 bit ones, so 32 bit X86 will not work. To avoid problems it's better to get used to protect asm blocks with that. So it's not necessary, but it's a good habit and it doesn't hurt.


>Inline ASM is always available right?<

I think the (partial) D implementation for Dotnet didn't support asm. But even if all implementations support it, there are various kinds of CPUs, and each one needs a different asm.


>If i'm going to create local pointers and constants and move them across registers then, to accomplish the same result, would it be better (or the same) to create 2 local ints, rol them and then move them to their respective place (this way the compiler might generate better code):<

When the D compiler sees asm code, it locally switches off optimizations. I suggest you to compile your two versions, and take a look at the asm the D compiler produces (with obj2asm or with a free disassembler on Linux).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list