 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Thu May 31, 2007 3:50 am Post subject: Bitwise Operators. Explained. |
|
|
In almost all the asm tutorials I have read, they talk about these "bitwise operators" when giving a list of instructions. But I haven't seen any yet, that tell you what these are.
In order to be able to use the bitwise operators on hexadecimal numbers, you have to know how to convert them into binary, and back again. If you don't, well, you can still understand some of it. Or for the lazy people... just use the calculator in scientific mode that comes with windows. Or, if you actually want to learn (good for you) here is a good tutorial by Smartz993: http://forum.cheatengine.org/viewtopic.php?t=78249
Lets get started!
What is a Btiwise Operator?
A bitwise operator, as defined by google:
| Quote: | | A bitwise operation operates on one or two bit patterns or binary numerals at the level of their individual bits. |
Now that really doesn't mean much to people, if you don't already know what your talking about.
Basically, they are different ways of putting 2 binary numbers together into one by using mathematical operation. If you get what I mean. Don't worry if you don't, you'll understand once we've started.
There are 4 main bitwise operators: OR, XOR, AND and NOT
The Bitwise AND Operator
Let's take two hexadecimal numbers and AND them together: 256 AND 14D
Now if you know how to convert hexadecimal to binary, you should get these as the decimal numbers:
| Code: | 256 = 001001010110
14D = 000101001101 |
If you AND them together, the result will be 000001000100. Then we convert it back to hexadecimal which equals to 44. But how did I get that answer?
It's very simple actually. Put the two binary numbers above each other. Where two 1's are above each other, the result is 1. Else, the result is 0. It is very much like multiplying the two binary numbers. Here is a chart do show this information:
| Code: | 1 x 1 = 1
1 x 0 = 0
0 x 1 = 0
0 x 0 = 0 |
Try this operation: 134 AND 138
Very nice and simple. If you are really stuck and can't work it out, the answer is at the bottom.
The Bitwise OR Operator
With the OR operator, we start of the same as when we AND two hexadecimal numbers together. We will again use 256 OR 14D for our example.
Let's remind ourselves of what these numbers are in binary:
| Code: | 256 = 001001010110
14D = 000101001101 |
Using the OR operator, this would equal to 1101011111. Then we convert it back to hexadecimal which equals to 35F.
We get this result by stating:
If two 0's are above each other, then the result underneath is 0. Otherwise the result underneath them is 1. I can hear you begging for a chart, so here one is!
| Code: | 1 OR 1 = 1
1 OR 0 = 1
0 OR 1 = 1
0 OR 0 = 0 |
Get it? If so try doing this operation: 134 OR 138
Yes, I know, the same numbers as before. And, likewise, the answer is at the bottom.
The Bitwise XOR Operator
Again, we start by placing the two binary numbers above each other. We will still be using 256 XOR 14D as our example.
| Code: | 256 = 001001010110
14D = 000101001101 |
The answer in this case would be 001100011011. Once we have changed that back into hexadecimal, we get: 31B.
This time we have XORed them. Now your thinking, xor? :huh: What the hell is that?
Well, it is very much like the others.
If two numbers above each other are the same, the answer is 0. Else, the result beneath would be 1. Here comes the chart! OMG, watch out!
| Code: | 1 XOR 1 = 0
1 XOR 0 = 1
0 XOR 1 = 1
0 XOR 0 = 0 |
Nice. Try this: 134 XOR 138 Answer is at the bottom!
The Bitwise NOT Operator
The NOT bitwise operator is used to reverse a number. Let's take our trusty example, with a slight change: NOT 256:
The answer to this operation would be 110110101001, which when hexed is DA9.
What I did, is exactly what you think I should. I changed all the 1's into 0's, and vice versa. Table, if you need it:
The NOT bitwise operator is different from the others as it doesn't link two numbers. Hence, the difference in the example.
Try working out: NOT 138. As usual, the answers at the bottom.
Answers
| Code: | 134 AND 138
134 = 000100110100
138 = 000100111000
-------------------------
Ans = 000100110000 = 130 |
| Code: | 134 OR 138
134 = 000100110100
138 = 000100111000
-------------------------
Ans = 000100111100 = 13C |
| Code: | 134 XOR 138
134 = 000100110100
138 = 000100111000
-------------------------
Ans = 000000001100 = C |
| Code: | NOT 138
138 = 000100111000
-------------------------
Ans = 111011000111 = EC7 |
Conclusion
Well, this concludes my tutorial on bitwise operators. I hope it has helped you. If you have any questions, feel free to ask. If I have got anything wrong, please tell me.
Thanks for reading!
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair.
Last edited by --Pillboi-- on Thu May 31, 2007 11:11 am; edited 2 times in total |
|
| Back to top |
|
 |
TheSorc3r3r I post too much
Reputation: 0
Joined: 06 Sep 2006 Posts: 2404
|
Posted: Thu May 31, 2007 4:24 am Post subject: |
|
|
Or you can just read Uzeil's tutorial in part of his engine tutorial.
I didn't like how you described ANDing two bits as multiplying them, but I guess it can be done that way.
_________________
Don't laugh, I'm still learning photoshop! |
|
| Back to top |
|
 |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Thu May 31, 2007 4:28 am Post subject: |
|
|
| TheSorc3r3r wrote: | Or you can just read Uzeil's tutorial in part of his engine tutorial.
I didn't like how you described ANDing two bits as multiplying them, but I guess it can be done that way. |
Lol. He only does the AND bitwise operator.
I know, it's just, I tried to make it for complete noobs. Without confusing them with what it's actually doing.
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
| Back to top |
|
 |
Hertebeest Grandmaster Cheater
Reputation: 0
Joined: 30 Nov 2006 Posts: 764
|
Posted: Thu May 31, 2007 5:39 am Post subject: |
|
|
Nice tut. +rep
_________________
Not active anymore in MS. |
|
| Back to top |
|
 |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Thu May 31, 2007 5:41 am Post subject: |
|
|
| Hertebeest wrote: | | Nice tut. +rep |
Lol. Thanks.
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
| Back to top |
|
 |
dnation Master Cheater
Reputation: 0
Joined: 01 Apr 2007 Posts: 383
|
Posted: Thu May 31, 2007 5:42 am Post subject: |
|
|
nice pill, gj this will help alot!
_________________
Pm if u want my MSN email |
|
| Back to top |
|
 |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Thu May 31, 2007 5:43 am Post subject: |
|
|
| dnation wrote: | nice pill, gj this will help alot!  |
It's ok. Thanks.
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|