Re: Converting register val to IRQ no
- From: "Voidcoder" <voidcoder@xxxxxxxxx>
- Date: Fri, 29 Jul 2005 09:55:54 -0700
I assume You are looking for a !very fast! code and
simple bit scanning for some reason does not satisfy you.
Some CPUs have a special instruction for this
but note this can be used if !only one! bit is set at
a time.
Personally i use the following code and it works
just nice:
INT WhichBit32(UINT value)
{
INT bit = 0;
while (bit < 32)
{
if (value & (1 << bit))
return bit;
}
return -1;
}
Of course there are better solutions like
first checking which half-word is nonzero,
then which half-byte is nonzero and then
just several comparison. But in the most cases
several additional instructions does not make
the weather.
"ms" <ms@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:u0Kods6kFHA.3960@xxxxxxxxxxxxxxxxxxxxxxx
> Hi, I am writing the OEMInterruptHandler function in my OAL. I am following
> PQ model.
> I would like to convert the register value in my interrupt pending register
> to a decimal value
> = to my IRQ no. so i can then use the OalIntrStaticTranslate function on the
> IRQ.
> If i have a value in my register ie 0x80000000 which is equal to IRQ 32 is
> there some
> simple C code to convert this value to 32.
>
> Regards
> ms
>
>
>
>
.
- Follow-Ups:
- Re: Converting register val to IRQ no
- From: Voidcoder
- Re: Converting register val to IRQ no
- References:
- Converting register val to IRQ no
- From: ms
- Converting register val to IRQ no
- Prev by Date: Re: Remote Admin / Configuration
- Next by Date: Re: Converting register val to IRQ no
- Previous by thread: Converting register val to IRQ no
- Next by thread: Re: Converting register val to IRQ no
- Index(es):
Relevant Pages
|
|