( ! ) Solo or NOT Solo what is the difference
sam_sam_sam
Posts: 2,286
I found this under Spin Math and Logic Operators
and it says the following under Assignment Usage " if solo"
"( ! ) [ if solo] Bitwise NOT "
My question is what IF it is not solo what is the difference
Please give a example of one that would not be solo
and explain the difference between the two
Please give a example of one that would be solo
What would this be !outa[4..9] solo or not solo ?
In Propeller Education Kit Lab version 1.2 on page 56 under " The Bitwise " ! " Operator in part it say the following
Then in the repeat loop, it uses the Bitwise NOT " ! " operator on outa [4...9] stores %100001, the command !outa [4...9] inverts all the bits to (1s become 0, 0 become 1 ) I understand this but is this solo or not solo
Here is why I am asking this in each of the example in the Propeller Education Kit Lab I am add note for each commands so that when I start to write my own code and I do not understand how to do something I do not have to hunt all over the to find it I hope every one understands Thanks for your help
I also a question about what comment that i can put for this part ( clkfreq/4*3 + cnt )
One last thing it would have been nice if there is a difference between solo / not being solo that at lease there would be a example what is the difference
and it says the following under Assignment Usage " if solo"
"( ! ) [ if solo] Bitwise NOT "
My question is what IF it is not solo what is the difference
Please give a example of one that would not be solo
and explain the difference between the two
Please give a example of one that would be solo
What would this be !outa[4..9] solo or not solo ?
In Propeller Education Kit Lab version 1.2 on page 56 under " The Bitwise " ! " Operator in part it say the following
Then in the repeat loop, it uses the Bitwise NOT " ! " operator on outa [4...9] stores %100001, the command !outa [4...9] inverts all the bits to (1s become 0, 0 become 1 ) I understand this but is this solo or not solo
Here is why I am asking this in each of the example in the Propeller Education Kit Lab I am add note for each commands so that when I start to write my own code and I do not understand how to do something I do not have to hunt all over the to find it I hope every one understands Thanks for your help
''This code example is from Propeller Education Kit Labs: Fundamentals, v1.2. ''A .pdf copy of the book is available from [url]www.parallax.com[/url], and also through ''the Propeller Tool software's Help menu (v1.2.6 or newer). '' ''File: LedsOnOff.spin ''All LEDS on for 1/4 s and off ''for 3/4 s. PUB BlinkLeds dira[4..9] := %111111 ' cnt - a register that counts system clock ticks ' ' clkfreq - a command that returns system clock frequency in Hz clock or ' a value that stores system clock ticks in one second ' ' waitcnt - a command that waits for the the cnt register to get ' to a certain value repeat outa[4..9] := %111111 waitcnt(clkfreq/4 + cnt) ' wait 1/4 of a second outa[4..9] := %000000 waitcnt(clkfreq/4*3 + cnt)
I also a question about what comment that i can put for this part ( clkfreq/4*3 + cnt )
One last thing it would have been nice if there is a difference between solo / not being solo that at lease there would be a example what is the difference
Comments
I am not clear about what you are asking for your first question, but for your second question...
if .... clkfreq/4 = 1/4th of a second, then
clkfreq/4*3 = 1/4th + 1/4th + 1/4th .... or 3/4ths of a second
Beau Schwabe
I am not clear about what you are asking for our first question,
What would this be !outa[4..9] solo or not solo ?
Here is why i am asking this question
I found this under Spin Math and Logic Operators
and it says the following under Assignment Usage " if solo"
"( ! ) [ if solo] Bitwise NOT " What do this mean if solo
The difference is this:
"!" is used as a bit operation. !$00ff = $ff00. Simply invert the state of each bit, and you have the result of "!".
"NOT" is used for comparison purposes as part of a IF - THEN construct, or expression. "NOT" does not invert the bits, only the comparison, when used this way. Examples would be X := NOT Y. If Y evaluates to "FALSE" -1, then X would contain "TRUE", or 0.
So there are two kinds of operators. Bit-wise operators operate on the bits, according to their truth tables. Useful for masks and to isolate specific bits, compare them, etc... on a binary level. These are called the "Bit-wise" operators.
The other kind are called "Boolean" operators, with the same names! The difference is booleans are all about comparing numbers, not operating directly ON the numbers.
Consider this:
X := X + NOT (Y > 5)
vs
X := X + (Y > 5)
If Y is greater than 5, the expression (Y > 5) returns true, or 0, resulting in the addition of zero to X, when that case is true. The NOT boolean operator can return the opposite of that, which is -1, or $FFFF. So the statement with the NOT in it, would add $FFFF to X, instead of 0, when Y is greater than 5.
Now, why the $FFFF and not just 1 for true?
Well, you can use the bitwise operation to select any number to add to X on a TRUE result with a bit-wise AND!
So let's say you want to add 6 to X when Y is greater than 5. This is easy to do with IF - THEN statements, but you can also do it with just a simple expression that contains that comparison thus:
X := X + NOT (Y > 5) & 6
This contains both kinds of operators! So, (Y > 5) gets evaluated and lets say that Y is greater than 5, so it evaluates to "TRUE", or 0. The NOT boolean operator inverts that to "FALSE", which is all bits set, or $FFFF_FFFF. The and "&" operator is a bitwise one, which will combine the number 6 with $FFFF_FFFF where the only bits set will be the bits that are a one in both arguments, which simply results in the number 6, which then is added to X.
That's a conditional addition using boolean and bitwise operators.
And about the only explanation I have for why TRUE on a Prop is all bits set. Makes this kind of thing easy cheezy, mapping directly to PASM instructions!
" if solo "
I am trying not to give any one a hard time
I just do not understand what this means " if solo "
The difference is this:
"!" is used as a bit operation. !$00ff = $ff00. Simply invert the state of each bit, and you have the result of "!".
which one would this be solo or not solo
"NOT" is used for comparison purposes as part of a IF - THEN construct, or expression.
____________________________________________________________________________________________________________________________
I just want to understand when I see if solo
I want to understand what this mean as far as when to use in code there are few more commands that have same thing on them
Here are the folowing "-" " ^^ " " || " " |<" "<|" " ! " "NOT" all have the if solo
Andy
When it's used with the IF statement, program flow is changed based on what that value is. By default, 0 = true, and all bits set is false, or -1, or $FFFF_FFFF.
Literally, if solo = 0, that's true, and the "then" part of the statement would be performed. If solo = $FFFF_FFFF, that's false, and the "then" part of the statement would not be performed.
It's possible to use a value directly as a default comparison with TRUE and FALSE.
The boolean form of NOT, inverts the comparison!
if not solo will invert the comparison value of solo. If solo = 0, or TRUE, NOT will invert that to be FALSE, which is the boolean or comparison opposite. When solo equals FALSE, NOT inverts that to TRUE, and the "then" part of the statement would be executed, just the opposite of what was stated above.
This what I was looking for now i understand the differece is when it says if solo
Literally, if solo = 0, that's true, and the "then" part of the statement would be performed. If solo = $FFFF_FFFF, that's false, and the "then" part of the statement would not be performed
I am sorry that I do not ask the question the right way
When we compare, we do math and look at the result, and we store that somewhere for the if command to use. When you see "if solo", it's just using solo as the result, implying a comparison was done somewhere else!
Say we want to compare whether or not X is equal to Y. We subtract X from Y, and get 0. That's TRUE! And they are equal. If we subtract X from Y, and we get a negative number, one is greater than the other, and if we get a positive number one is less than the other. And a more coarse comparison result would simply be -1, which is all bits set, which essentially means "not equal" too, depending on the kind of comparison desired.
Let's say we store that somewhere, like solo.
Now, if x is equal to y, and the result of that comparison is stored in solo, we could say this:
solo :=x-y
When they are equal, solo contains 0, right?
So then "if solo" would execute the "then" part of the statement, if the result of the comparison is TRUE.
!0 = $FFFF_FFFF
If !0 means take the value 0, invert it. that is $FFFF_FFFF, which is FALSE to the if statement.
On the other hand....
If NOT !0 means take the value 0, invert it, so that it equals FALSE above, then invert that to be TRUE for the if statement!
As far as I can tell, and in my own use "!" is ONLY A BIT OPERATOR. The word "NOT" is a boolean operator. Bit operator works on the bits themselves, where a boolean operator operates on values as comparisons, or products of comparisons.
The "!" operator doesn't care what the value is. It simply flips the bits! The "NOT" operator DOES care what the value is, and it's looking for TRUE = 0 or FALSE = -1, or all bits set.
Confusing subject. I spent a LOT of time on this early on in the 80's programming. Boolean operators have the same names as bit or bit-wise operators do, but they do very different things!