If you think you can do ti with subtraction and bit-shifting (without
requiring MMX or something similar) please show it to us.

With multiplication:

new_mask = color & alpha_mask;
new_mask >>= 6;
new_mask *= 0x7F;

Without multiplication:

new_mask = color & alpha_mask;
new_mask <<= 1;
new_mask -= new_mask >> 7;

This gets the same result with only two shifts and a subtraction.


Happy Hacking,

David E. McMackins II
Supporting Member, Electronic Frontier Foundation (#2296972)
Associate Member, Free Software Foundation (#12889)

www.mcmackins.org www.delwink.com
www.eff.org www.gnu.org www.fsf.org

On 2018-07-23 13:15, Bret Johnson wrote:
Multiple issues. First, if you're going to do it in "pure C", you
can't depend on anything like MMX. You're going to need to virtualize
the multiple-byte-functions-at-the-same-time manually, taking
advantage of CPU and data storage characteristics (little-endian,
two's complement, etc.). That pretty much defeats the purpose of
sticking with "pure C".

What you're trying to avoid is (conditional) JMPing and
multiplication/division, since they are costly in terms of speed, even
though they will work just fine. You are probably also going to want
to minimize the number of loops, since loops are also a type of JMP.
But, in modern CPU's with caches and branch prediction and pipelining
and similar enhancements, loops generally aren't that bad in terms of
overall speed. Any kind of speed or size optimization you do in C
(whether it's the compiler doing the optimization or you doing it
manually) again depends on specific CPU characteristics and features,
and again defeats the purpose of using "pure C".

If you think you can do ti with subtraction and bit-shifting (without
requiring MMX or something similar) please show it to us.

____________________________________________________________
'GENIUS' PILL - TOP 1% DIDN'T WANT THE PUBLIC TO KNOW ABOUT
The Brain Insider
http://thirdpartyoffers.juno.com/TGL3142/5b561b7888f711b787b75st03vuc
[1]


Links:
------
[1] http://thirdpartyoffers.juno.com/TGL3142/5b561b7888f711b787b75st03vuc

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Freedos-devel mailing list
Freedos-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-devel

Reply via email to