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

Re: Converting register val to IRQ no by Voidcoder

Voidcoder
Fri Jul 29 11:55:54 CDT 2005

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@discussions.microsoft.com> wrote in message news:u0Kods6kFHA.3960@TK2MSFTNGP12.phx.gbl...
> 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
>
>
>
>



Re: Converting register val to IRQ no by Voidcoder

Voidcoder
Fri Jul 29 12:00:56 CDT 2005

Huh! Forgot "++" :)

INT WhichBit32(UINT value)
{
INT bit = 0;
while (bit < 32)
{
if (value & (1 << bit))
return bit;

bit ++;
}

return -1;
}



"Voidcoder" <voidcoder@yahoo.com> wrote in message news:Og7vFMBlFHA.1416@TK2MSFTNGP09.phx.gbl...
>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@discussions.microsoft.com> wrote in message news:u0Kods6kFHA.3960@TK2MSFTNGP12.phx.gbl...
>> 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
>>
>>
>>
>>
>
>



Re: Converting register val to IRQ no by ms

ms
Fri Jul 29 08:46:00 CDT 2005

Thanks voidcoder
"Voidcoder" <voidcoder@yahoo.com> wrote in message
news:Ozl95OBlFHA.3552@TK2MSFTNGP10.phx.gbl...
> Huh! Forgot "++" :)
>
> INT WhichBit32(UINT value)
> {
> INT bit = 0;
> while (bit < 32)
> {
> if (value & (1 << bit))
> return bit;
>
> bit ++;
> }
>
> return -1;
> }
>
>
>
> "Voidcoder" <voidcoder@yahoo.com> wrote in message
news:Og7vFMBlFHA.1416@TK2MSFTNGP09.phx.gbl...
> >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@discussions.microsoft.com> wrote in message
news:u0Kods6kFHA.3960@TK2MSFTNGP12.phx.gbl...
> >> 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
> >>
> >>
> >>
> >>
> >
> >
>
>