Message board for the users of flat assembler.
> Main > limiting a variable to a certain range
hi, im new to the forums and fasm
im in the need of limiting a variable's contents to a certain range.
i thought about using a macro for this but a function would do just fine, its the method that im after rather than the package.
what I don't know is how to write an efficient bound routine. having the variable contents and checking for min and max, limiting to this range. what would be the most efficient way of doing this? is there a specific instruction that isn't in sse or similar extended sets?
its clear that i want to do this with pixel data to bound it into 8bits while working on 32bits but i'm using just normal x86 instructions...
it would be cool to learn about the most efficient method in, say, sse too.
are there any examples or instructions I could learn from?
|18 Jul 2008, 02:40||
PCMP* instructions can be used to test multiple values. There are many ways to use the mask produced. If possible it's better to use the mask directly than to branch execution. Usually, clamping can be integrated into the algorithm with saturation instructions, but PMIN*/PMAX* work too.
There are examples on the board - search for "SSE2".
|18 Jul 2008, 03:04||
< Last Thread | Next Thread >
Copyright © 1999-2020, Tomasz Grysztar.
Powered by rwasa.