Pasm - set a specific bit
Agent420
Posts: 439
Probably the Dumb Question Of The Day™
Say I have a register that contains the decimal number of a bit I want to set (0-31)...· What is the most efficient method to accomplish this?
I need to create a 1 bit mask·for later use.· X contains the bit # to set.· In this example, I reset the mask to 1 because I do not believe I will encounter a non-zero value.
I'm guessing that if I needed to address a potential 0 value, I'd test and use the carry flag in a rotate, but I have limited clock cycles for this application.
Look good, or is there a better method?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Say I have a register that contains the decimal number of a bit I want to set (0-31)...· What is the most efficient method to accomplish this?
I need to create a 1 bit mask·for later use.· X contains the bit # to set.· In this example, I reset the mask to 1 because I do not believe I will encounter a non-zero value.
mov mask,#1 '+ 4 reset pixel mask mov temp,x '+ 4 copy x to work and temp,#31 '+ 4 calc pixel bit # shl mask,temp '+ 4 set pixel mask
I'm guessing that if I needed to address a potential 0 value, I'd test and use the carry flag in a rotate, but I have limited clock cycles for this application.
Look good, or is there a better method?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Comments
I haven't tried it, though.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lonesock
Piranha are people too.
-Phil
Nonetheless, I did not realize the shift and rotate operations were limited to the lower 5 bits.· Thanks - that will give me a few more cycles ;-)
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Agent420) : 9/10/2009 7:12:12 PM GMT