Re: Best way to emulate BSR?
- From: "Jim Leonard" <spamtrap@xxxxxxxxxx>
- Date: 23 Aug 2006 20:43:54 -0700
randyhyde@xxxxxxxxxxxxx wrote:
I have a need to determine the minimum number of bits to hold a certain
number, and BSR looks like a great way to do that. Unfortunately, the
target platform for this project does not support 386 instructions like
BSR. Is there a bitwise trick on emulating BSR?
How many bits do you have to check? That can make a big difference in
the choice of algorithm. If you're limited to a 16-bit number on a
pre-386 CPU, and memory storage isn't at a premium, I'd suggests a
256-byte lookup table that maps each byte value to the number of
leading zeros (or whatever you want) and then use the XLAT instruction
to do the dirty work a byte at a time.
That's the one, thanks very much!
.
- References:
- Best way to emulate BSR?
- From: Jim Leonard
- Re: Best way to emulate BSR?
- From: randyhyde@xxxxxxxxxxxxx
- Best way to emulate BSR?
- Prev by Date: Re: C++
- Next by Date: Re: I feel stupid... "Invalid combination of opcode and operand"
- Previous by thread: Re: Best way to emulate BSR?
- Next by thread: Re: Best way to emulate BSR?
- Index(es):
Relevant Pages
|