Pasm - set a specific bit
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!
:read_x rdlong x, idx '+ 8 read x coord mov mask,#1 '+ 4 reset pixel mask shl mask,x '+ 4 set pixel mask shr x,#5 '+ 4 divide x by 32 = offset :xoff mov xoff,x '+ 4 store offset :mpix mov mpix,mask '+ 4 store pixel▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Post Edited (Agent420) : 9/10/2009 7:12:12 PM GMT