In the initial implemenation of the right-shift-and-cast operations only dealt with shift offsets greater than eight, but I realized I can be more general.
Here's a truth table for all possible right shifts and the equvalant general shift I need, including casting.
 
N  Original pattern     Shifted pattern      Result   Optimization
- -----------------    -----------------    --------  ----
0 01234567.89ABCDEF -> 01234567.89ABCDEF -> 89ABCDEF  X<<8  -.
1 01234567.89ABCDEF -> x0123456.789ABCDE -> 789ABCDE  X<<7   |
2 01234567.89ABCDEF -> xx012345.6789ABCD -> 6789ABCD  X<<6   |
3 01234567.89ABCDEF -> xxx01234.56789ABC -> 56789ABC  X<<5   | X<<(8-N)
4 01234567.89ABCDEF -> xxxx0123.456789AB -> 456789AB  X<<4   |
5 01234567.89ABCDEF -> xxxxx012.3456789A -> 3456789A  X<<3   |
6 01234567.89ABCDEF -> xxxxxx01.23456789 -> 23456789  X<<2   |
7 01234567.89ABCDEF -> xxxxxxx0.12345678 -> 12345678  X<<1  -'
8 01234567.89ABCDEF -> xxxxxxxx.01234567 -> 01234567  nop
9 01234567.89ABCDEF -> xxxxxxxx.x0123456 -> x0123456  X>>1  -.
A 01234567.89ABCDEF -> xxxxxxxx.xx012345 -> xx012345  X>>2   |
B 01234567.89ABCDEF -> xxxxxxxx.xxx01234 -> xxx01234  X>>3   |
C 01234567.89ABCDEF -> xxxxxxxx.xxxx0123 -> xxxx0123  X>>4   | X>>(N-8)
D 01234567.89ABCDEF -> xxxxxxxx.xxxxx012 -> xxxxx012  X>>5   |
E 01234567.89ABCDEF -> xxxxxxxx.xxxxxx01 -> xxxxxx01  X>>6   |
F 01234567.89ABCDEF -> xxxxxxxx.xxxxxxx0 -> xxxxxxx0  X>>7  -'
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment