Re: Best way to emulate BSR?




Jim Leonard 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.
Cheers,
Randy Hyde

.



Relevant Pages

  • Re: C / asm / long ints
    ... instructions that current-generation compilers generally do not emit. ... performance gain. ... Using BSR as an example of a special-purpose instruction which could ...
    (comp.lang.c)
  • Re: Best way to emulate BSR?
    ... and BSR looks like a great way to do that. ... target platform for this project does not support 386 instructions like ...
    (comp.lang.asm.x86)
  • Re: C / asm / long ints
    ... instructions that current-generation compilers generally do not emit. ... Using BSR as an example of a special-purpose instruction which could ... language bit-scanning loop. ...
    (comp.lang.c)