The purpose / function of logical operators is to test whether a condition is true or false. There are logical operators, such as: AND, OR, NOT, etc. and mathematical operators, such as: add, divide, multiply, etc. I will show you the function of logical operators in this brief tutorial.
I will use the AND operator as an example.
We will use A and B as variables for the condition test, and will let the answer be Q and the result R.
If both A & B = Q, then R = True, otherwise R = False, if both bits are not equal to Q.
It's as simple as that. They are used to test conditions for being true or false based on a logical expression, like above.
Here is an example of AND being used in code in 6502 assembly:
We have the accumulator loaded with value 0 at address 00E7. The AND compares the accumulator to value 0x40, if it equals 0x40, the next instruction tells it to branch on equal to the instruction at B39F, which tells it to clear the carry. However, if it is false, it skips over the instruction and proceeds to the next instruction, which is to load the x register with value 0x06, then it loads again through slightly different logic. If the value has been subtracted, it will skip over to address B3A1. If that condition is false, it will increment the X register, and will compare X to value 0x09, if it equals 0x09, it will branch when the carry has been cleared. At least... That's what I think it does. My 6502 is a bit rough. I've only scratched the surace of it.
But at least now, you can see how logical opeators function, and if you don't... Go fuck yourself.
Wrote this because I was bored.
I will use the AND operator as an example.
We will use A and B as variables for the condition test, and will let the answer be Q and the result R.
If both A & B = Q, then R = True, otherwise R = False, if both bits are not equal to Q.
It's as simple as that. They are used to test conditions for being true or false based on a logical expression, like above.
Here is an example of AND being used in code in 6502 assembly:
We have the accumulator loaded with value 0 at address 00E7. The AND compares the accumulator to value 0x40, if it equals 0x40, the next instruction tells it to branch on equal to the instruction at B39F, which tells it to clear the carry. However, if it is false, it skips over the instruction and proceeds to the next instruction, which is to load the x register with value 0x06, then it loads again through slightly different logic. If the value has been subtracted, it will skip over to address B3A1. If that condition is false, it will increment the X register, and will compare X to value 0x09, if it equals 0x09, it will branch when the carry has been cleared. At least... That's what I think it does. My 6502 is a bit rough. I've only scratched the surace of it.
But at least now, you can see how logical opeators function, and if you don't... Go fuck yourself.
Wrote this because I was bored.