In order to be able to do assembly language programming, we are obliged to use other number systems besides the one we normally use.
Our number system utilizes an organizational principle called 'place value' to keep relationships between differently sized numbers in the proper order. When we denote place value, we generally move to the left. As we move another 'place' to the left, we increase the numerical value of that particular 'place' by a specific amount. The amount of increase is denoted by the 'baseness' of the counting system, or in other words the base value.
The basic idea looks something like this:
10^5 10^4 10^3 10^2 10^1 10^0
100000 10000 1000 100 10 1
For base ten, this means that every successive 'place' is ten times the amount of the preceding base. So moving from right to left, we have the units place, tens place, hundreds place, etc...
To help us in counting, we have 10 numerical symbols, 0 through 9. (In case you did not know, 0 is always the first number counted in anything computer science related.)
However, computers do not process instructions in terms of base 10. Referring to our last post, when a computer acts on a programming language (through the compiler, interpreter, etc...) those instructions are transformed into groups of electrical patterns, and those patterns are placed into individual containers located on the memory chips placed on a stick of ram. Because the computer is dealing with electrical patterns, each container in the memory chip is either going to be on (charged) or off (not charged). Because there are only two possible states at play here, the system of binary was created to help us interpret the rendering of programming languages as machine code.
Another name for binary is base 2. Looking at our earlier explanation of base 10, we can infer that base 2 means that every successive 'place' to the left is 2 times greater than the place before it, so we have our units place, 2nds, 4ths, 8ths, 16ths, 32nds, 64ths, 128ths, etc...
Binary can be represented like this:
2^5 2^4 2^3 2^2 2^1 2^0
32 16 8 4 2 1
Because we only have two numbers, 0 and 1, an actual binary number will look something like 10001010101110000111. The number 5 in binary would look like this: 101. Referencing the short chart above, we can understand that there is a 1 in the 4's column, a zero in the 2's column, and a 1 in the 1's column. If you meditate on this for a few minutes, you should be able to get the basic idea.
Up next: building on decimal and binary, moving into octal and hexadecimal.
Top comments (1)
This will require some editing at some point, especially with regard to the binary and decimal place value demonstrations. For now- continuing on.