Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 4,140 of 4,675    |
|    Rick C. Hodgin to R.Wieser    |
|    Re: Bit Swizzling    |
|    08 Sep 20 21:51:01    |
      XPost: comp.lang.c, comp.arch.fpga       From: rick.c.hodgin@nospicedham.gmail.com              On 9/8/20 2:26 PM, R.Wieser wrote:       > (Too many xpost groups, had to remove one)       >       > Rick,       >       >> o |= (((v & (1 << s)) >> s) << d);       >       > If you reverse the two tables (having the output bits in order from high to       > low) you could left-shift the output by one and than OR the output with the       > right-shifted input masked with 1. In this specific case (all eight bits       > swizzeled) you do not even need to clear the output.       >       > My C(++) isn't worth anything, but I imagine it could look something like       > this :       >       > o <<= 1       > o |= (v >> s) & 1       >       > That takes, at least on a x86, 4 machine instructions per bit.       >       > The thing with writing C(++) that should work /everywhere/ is that you can't       > use optimalisations for a specific processor.              I appreciate your response, Rudy. I'm writing my own CAlive language,       and my request for an algorithm is to have my internal intermediate       language able to then generate optimum code sequences for a target ISA       given the constraints of that ISA.              It's a fairly complex task which is why I reached out for it. I'm       adding swizzle operator support so you can name an operator and apply       inlined swizzle operation to data (as an operator and not as a func-       tion call).              > And a remark : you've made that "swizzle" a function. Which means you will       > probably have a relative large overhead, possibly doubling if not tripling       > the ammount of instructions executed for each bit extraction and insertion       > (starting with the "call" and "return"). Rewiting it as a macro would       > probably be a good idea.              It was an example only of a worst-case scenario for swizzling data. I'm       sorry that wasn't more clear. :-)              --       Rick C. Hodgin              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca