Bitmasking >>setting bits on and off on port a ..
OzStamp
Posts: 377
Hi to all Proppers.
attached a little program in asm..
I stumbled across this method .. how to set bits on and off on port A
maybe this has been here before .. if true· abort...
the syntax to look for in the code down the bottom ...
setpin7·········· long· |< 7
resetpin 7······ long··| < ! 7···
seems to work well its fast and easy to read...
Cheers Ron Mel OZ
attached a little program in asm..
I stumbled across this method .. how to set bits on and off on port A
maybe this has been here before .. if true· abort...
the syntax to look for in the code down the bottom ...
setpin7·········· long· |< 7
resetpin 7······ long··| < ! 7···
seems to work well its fast and easy to read...
Cheers Ron Mel OZ
spin
994B
Comments
instead of
mov outa,setpin7
you can use
or outa,setpin7
that way, you can control more than one pin in the same cog.
also instead of
mov outa,rstpin7
you can use
andn outa,setpin7
that way, you also save inverting setpin7 to make rstpin7 and save an long in the process [noparse];)[/noparse]
It only appears to work! It doesn't really.
!7 is the bitwise not of 7. = %11111111_11111111_1111111_11111000
|< uses (0..31) which is the bottom 5 bits. =%11000 = 24
So |< !7 is the same as %00000001_00000000_00000000_00000000, which is not what you intended at all, and only coincidentally works with your test.
Demo in attached file.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Help to build the Propeller wiki - propeller.wikispaces.com
Play Defender - Propeller version of the classic game
Prop Room Robotics - my web store for Roomba spare parts in the UK
You probably meant: ! |< 7 which is the one's complement of: |< 7
Baggers is correct. You're better off using OR and ANDN with the same bitmask to turn on and off the I/O pin(s).
Yes you are all correct ..
It does reset other bits if those pins are set to output...
I was playing with the various formatters of the encode syntax |< X
and stumbled across that ..
Not such a great find.. sorry guy's ..
I prematurely "spinned out "
I must hereby thank the following people for their snippets of asm code that we
have seen in all the posts here.. all these little snippets are now coming together into
a total· working program all in asm...it has been an interesting journey..
Kudo's to·· Our German "Freund" De Silva, Mike Green (Hey Mike how about you post a question one day)
Fred Hawkins ,Baggers·, Ale··, CardB_Guru·,Beau S. and probably another ten or so·.. their names elude me presently.
Phil Pilgrims "traps and tricks collection.." nice ..thnx
I have one snag to overcome ..need to·get a variable from ASM ( 1 COG initally) to
the Full Duplex serial object.. and as quick soon as possible to the Full duplex serial object
when this serial object ·is finished need to go back to the
COG feeding it·· all as soon as possible ..( no spin code if possible.)
Once I get one COG doing that there will be 3 COGS feeding the Full Duplex serial object etc etc..
·Cheers Ron Mel OZ..
Post Edited (OzStamp) : 12/12/2007 12:59:54 AM GMT