|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
MIPS...detecting least significant bit.I'm working on an assignment and have reached a road block. If I have a 16 bit integer like:
0000 0000 0000 0100 how would I check to see what the value in the LEAST significant bit is? Basically, how would I check to see if the least significant bit is 0 or 1? How would I code it? I am a beginner at MIPS...is there a simple instruction that detects this? Please help me. |
|
|
Re: MIPS...detecting least significant bit.On Thu, Oct 9, 2008 at 11:09 AM, Izzy K. <rjdfhorn_06@...> wrote:
> > I'm working on an assignment and have reached a road block. If I have a 16 > bit integer like: > > 0000 0000 0000 0100 > > how would I check to see what the value in the LEAST significant bit is? > Basically, how would I check to see if the least significant bit is 0 or 1? > How would I code it? I am a beginner at MIPS...is there a simple > instruction > that detects this? Please help me. My first guess at the solution (and forgive me for not knowing the MIPS instruction set --- so I'm just speaking in general machine language terms) is to loop while left shifting and testing with an AND 0x01. You need to count the loops to know when you encountered the first bit set. Now... often the result of the left shift sets a status register based on the previous value of the 0 bit (carry or underflow?) ... so your loop might be an instruction shorter --- not requiring the AND --- if this is the case. Now... this all seems rather fundamental. Even the brute force case of AND'ing with a bunch of values might pipeline well. Are you sure you should be taking this course? _______________________________________________ freebsd-mips@... mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-mips To unsubscribe, send any mail to "freebsd-mips-unsubscribe@..." |
|
|
Re: MIPS...detecting least significant bit.In message: <5f67a8c40810091158y4a334f17g7ee25f67888e84e8@...>
"Zaphod Beeblebrox" <zbeeble@...> writes: : On Thu, Oct 9, 2008 at 11:09 AM, Izzy K. <rjdfhorn_06@...> wrote: : : > : > I'm working on an assignment and have reached a road block. If I have a 16 : > bit integer like: : > : > 0000 0000 0000 0100 : > : > how would I check to see what the value in the LEAST significant bit is? : > Basically, how would I check to see if the least significant bit is 0 or 1? : > How would I code it? I am a beginner at MIPS...is there a simple : > instruction : > that detects this? Please help me. : : : My first guess at the solution (and forgive me for not knowing the MIPS : instruction set --- so I'm just speaking in general machine language terms) : is to loop while left shifting and testing with an AND 0x01. You need to : count the loops to know when you encountered the first bit set. Now... : often the result of the left shift sets a status register based on the : previous value of the 0 bit (carry or underflow?) ... so your loop might be : an instruction shorter --- not requiring the AND --- if this is the case. : : Now... this all seems rather fundamental. Even the brute force case of : AND'ing with a bunch of values might pipeline well. Are you sure you should : be taking this course? Or you could just call ffs. FFS(3) FreeBSD Library Functions Manual FFS(3) NAME ffs, ffsl, fls, flsl -- find first or last bit set in a bit string Warner _______________________________________________ freebsd-mips@... mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-mips To unsubscribe, send any mail to "freebsd-mips-unsubscribe@..." |
| Free embeddable forum powered by Nabble | Forum Help |