# Taukamok - Visiting Professor of Computer Language

Machine Languages 101 - Professor: Taukamok

Lesson 1, The Processor and Base 2

Machines capable of performing complex calculations are known to us through the Goblins, the Gnomes, the Draenei, and the Titans. While the Titan machines are rare and immensely complex, the machines made by the Goblins, Gnomes, and Draenei are very well known and understood. These types of machines can govern other machines (such as in the case of artificial intelligence), can perform long, mathematical equations that would take hours, days, or even years to complete in a relatively small amount of time in comparison. They can also be made to execute specific tasks, such as tracking planetary movements or astral bodies or a plethora of other tasks that would be tedious and time consuming to do by hand. Additionally, these machines can provide a level of precision and consistency unachievable by mortal beings. These machines can also provide methods of communication. If one of these machines is connected to another, they may “talk” to each other. Yet, in what language do they speak, and if they are capable of communicating with other similar machines, how does one “talk” to a machine? How does one instruct a machine to perform tasks or computations? In order to understand how to talk to a machine, one must first learn what makes these sorts of machines work.

Firstly, to illustrate what makes a machine able to be communicated with, the traditional machine must be defined. A traditional machine is capable of one or more tasks, and unless if the machine is physically modified, it is unable of completing other tasks. Machines of this nature would be something like a mechanical clock, such as the large clocks mounted on the building in the Stormwind Canals. This mechanized clock will never do anything else besides track the time. Unless if the machine is modified to perform a different task, the machine will only be capable of doing what it was built to do. The only way that this rule can be broken is invoking the presence of magic. Even still, that magic can theoretically be denoted as a “change” to the machine, even if it is not by a traditional method (using hands, tools, etc.)

However, what if there was a type of machine that was able to perform a task that it was not originally intended to do? What if the internal structure of the machine was made in such a way that the machine was natively able to execute multiple kinds of tasks without any sort of physical manipulation? This type of machine uses a type of machinery that would best be described as “digital”. Instead of gears and cogs operating the “heart” of the machine, these digital machines use numbers to control its operation. By using numbers in a specific way, multiple tasks are able to be completed by the digital machine without changing its structure, even if the task to be executed was never devised or planned for by the one that created it.

Another stipulation of the digital machine is that, in order to be capable of removing the limitations of mortal error, it must not rely on anything that cannot be understood by mathematics. While mathematics and magic do have some overlap, the language of logic is ill-equipped to describe the machinations of the arcane. Thus, the digital machine is only capable of understanding what is known to logic. In this manner, the “perfection” of the machine’s output is only fallible by the use of the operator. If the machine is used correctly, the outputs of tasks given to the digital machine will always be correct. Similarly, a digital machine will not perform a task unless the machine is given something to work with. This is what defines the relationship between input and output. If one gives the digital machine is given some input, it will give output dependent only upon the given input. For instance, one may give a digital machine the statement “4 + 5 = ?”, and be told to solve the statement. This would be the input, and the solution “9” would be the output.

Yet, the method in which the digital machine is able to compute the output (and furthermore, accept input) is within the heart of the machine, the processor. The processor is a matrix of small components that accept energy in specific components at specific times, and by arranging this matrix in a specific way, the processor is able to “understand” numbers. This energy can theoretically be arcane or any other sort of energy so long as it has a negative charge. However, this energy used to power the processor is typically the same as which is found in lightning.

Now, how would a collection of small components, powered by the energy of lightning, be able to understand numbers? Let us first define the numbers we use for any sort of mathematics. Our understanding of mathematics is used by numbers in base 10. When we count, add, subtract, multiply, divide, etc. any number, we typically used the base 10 system, which means each digit is capable of holding 10 values, 0-9 (while some may see the number 0 as not a value as it represents there being nothing of something, it is very important to remember that mathematically, “nothing” is always a value). If there are two digits, there are a hundred possible values, 0-99. With three there are a thousand, 0-999, and so on and so forth. This numeric system was made popular as many races have 10 fingers, and using a number system with 10 as its primary component was easy to count with. Additionally, base 10 offers a few interesting benefits, such as what I described earlier. The maximum possible value of any number of digits is always found by 10^n – 1, where n is a positive integer. Base 10 also describes decimal and rational values easily, such as tenths, hundredths, thousandths, etc.

However, Base 10 is a very poor numeric system to use for digital machines. Why? Let us suppose a machine is capable of understanding one digit of Base 10. If this is true, this machine would need to be capable of representing 10 different values. If this is true, some machinery would need to be made to handle this functionality and it would most likely be more complex than the intention of the machine itself. For instance, if the machine were to switch between the numbers 8 and 7, there would have to be some function to switch between those two numbers. Same for 8 to 6, 8 to 5, etc. and the same for every other number. This means that there would be a total of 45 functions for only 10 outputs which is fairly inefficient. While there would be 90 functions for two separate digits (which we know would be capable of representing 100 values), if these two machines were linked together as they are in a digital machine, there would be a total of exactly 2,025 functions. For 3 digits there would be an astounding number of functions: 91,125. The idea of using Base 10 as a numeric system for digital machines is grossly inefficient.

Instead, imagine a light of Goblin or Gnomish make. This light can either be on or off. One uses a switch to allow energy to flow into the light bulb, and the same switch to deny power flowing into the light bulb. In essence, there is only one function that can describe two different values, a much more efficient solution than our 45-function machine to represent 10 values mentioned before. If there were two lightbulbs, each with their own switch, there would be 2 functions for 4 values. For 3 lightbulbs, there would be 3 functions with 8 different values, and for 4 there would be 4 functions for 16 values. Notice how the number of values keeps increasing exponentially while the growth of functions is linear with each additional lightbulb. Additionally, if, say, the function of turning these 4 lightbulbs on and off were properties of one machine, there would then be exactly 16 functions for representing these 16 values. Let us suppose that there were enough lightbulbs to represent 1,024 values. These lightbulbs would then require 1,024 different functions to represent those values. While there are many more “digits” present in the representation of this number as compared to the previous example, there is no need for something as wildly inefficient as 91 thousand functions with this system. This is why processors use a numeric system called Base 2 as opposed to Base 10.

One reading this may wish to understand how numbers work in Base 2, but in reality, one has already understood it. If one can understand the operation of a light bulb being turned on or off, one can understand the values capable of one digit in Base 2. While one digit in Base 10 is capable of 10 values, one digit is Base 2 is only capable of 2 values, 0-1. Just like Base 10, the maximum value of any number of digits can be described with an equation: 2^n -1, where n is the number of digits. Therefore, if there is one digit, there are two possible values, 0 and 1. For 2, there are 4 possible values, 0-3, for 3 digits there are 8 values, 0-7, and so on and so forth.

# -------------------------------------------------------

# -------------------------------------------------------

External Exercise – Combinatorics of Base 2:

On your own, find 4 coins of the same denomination. Find how many different combinations of heads and tails you can make with each of the coins, including 4 heads and 4 tails.

# -------------------------------------------------------

# -------------------------------------------------------

Let us relate back to the concept of light bulbs. If there are 4 lightbulbs, there are 16 different combinations of the same 4 lights that are on and off. With these hypothetical lightbulbs, one can use these to represent integer values in base 2. However, firstly, a review of digit position in Base 10 is in order. Digit values in Base 10 increase from the right being lowest in value to the left being highest in value. First is the “ones”, to the left of that is the “tens”, to the left of that is the “hundreds”, then the “thousands”, and so on. Again, this is one of the benefits of using Base 10 as a practical method for doing math that is easy to understand, each digit’s value is always going to be a combination of 10^n. However, with Base 2, each digit value is represented by a number of 2^n. Again relating back to the concept of 4 lightbulbs, let us say that these lightbulbs are arranged from right to left and that these lightbulbs were capable of representing numbers in Base 2. Suppose the lights are arranged in this manner: light on, light off, light off, light on. Also suppose that when a light is off it represents a 0, and if it is on it represents a 1. We could then represent the 4 lightbulbs as: 1,0,0,1 – or **1001**, of which 1001 is actually a valid Base 2 number. Next, we need to figure out figure out what Base 10 number is represented by the Base 2 number, **1001** (and no, it’s not one thousand-one). Relate to the fact that each digit in Base 10 is capable of representing 10 possible values. Let us say we have three digits. Alone these digits are all still combinations of 10 numbers each, but stacked together they represent 1,000 possible values. The right-most represents how many “ones” there are in the number, the middle how many “tens” there are in the number, and the left-most how many “hundreds” there are in the number. **Allow the below statement can represent the arbitrary number, 835.**

###### There are 5 ones.

###### There are 3 tens.

###### There are 8 hundreds.

Obviously, when added together, 8 hundreds, 3 tens, and 5 ones add up to 835. To convert Base 2 numbers into Base 10 numbers, the process is much of the same, however each digit represents exponents of 2 instead of exponents of 10. The number of digits in the Base 2 number denotes how many possible combinations/values there are in the number. The value of each digit is equivalent to: (2^n)/2, where “n” is a whole non-zero integer. Therefore the first digit is either nothing or 1 (Ex: 2^1 = 2, 2/2 = 1), the second is either nothing or 2 (Ex: 2^2 = 4, 4/2 = 2), the third is either nothing or 4 (Ex: 2^3 = 8, 8/2 = 4), and the fourth is either nothing or 8 (Ex: 2^4 = 16, 16/2 = 8). This means that to convert the Base 2 number, **1001**, into a Base 10 number, in the order of right to left:

###### (1) There is a one.

###### (0) There is not a two.

###### (0) There is not a four.

###### (1) There is an eight.

###### Added together, 1+0+0+8 = 9.

So now we know that the 4 lightbulbs, on, off, off, and on, can represent the number “9” in base Base 10 if the lightbulbs are seen as digits in Base 2. Represented in another way, there will be two sets of numbers in the table below. The top set will represent a digit value in Base 2, and the bottom will represent that digit’s value in Base 10:

Base 2 Digits |
## 1 |
## 0 |
## 0 |
## 1 |

Base 10 Values |
## 8 |
## 4 |
## 2 |
## 1 |

Additionally, it may also help to visualize each digit value of Base 2 as either being true/on (1) or false/off (0). If one has not already guessed the correlation, this is why Base 2 is also referred to as “binary numbers”, since each value has only two values: on or off, positive or negative, true or false, etc. Again, the Base 2 number **1001** can be represented in another way as such:

###### Is there a 1? Yes, so add 1 to the result.

###### Is there a 2? No, so don’t add 2 to the result.

###### Is there a 4? No, so don’t add 4 to the result.

###### Is there an 8? Yes, so add 8 to the result.

###### Again the result here is the same, 9.

# -------------------------------------------------------

# -------------------------------------------------------

#### External Exercise – Other numbers in base 2:

#### On your own, try to find the Base 2 value of 10, 2, 3, and 5.

# -------------------------------------------------------

# -------------------------------------------------------

Now, if we tried to represent the Base 10 value, 15, in Binary, it would be **1111**. How would we represent 16? We can’t add any more numbers from what we have, they have already been added. The maximum here is exactly 2^4 -1, of which we know 2^4 is 16, and subtracting one is 15. How then do we represent 16? The answer is that another digit is necessary to represent the Base 10 number, 16, in Base 2. Thus:

###### 1 0 0 0 0 = 16

With 5 digits, our maximum total Base 10 value is 31, which would look like: **11111**. What about 32? Same answer: **100000**, of which our new maximum value is 63 for 6 digits in Base 2. Again, each digit to the left represents the value of exactly 2 times the previous value in Base 10, and the digit value in Binary gives instruction on whether or not to add it to the result.

# -------------------------------------------------------

# -------------------------------------------------------

External Excercise – 8 digit Binary numbers:

On your own, convert these below numbers into Base 10.

## 1 |
## 0 |
## 1 |
## 0 |
## 1 |
## 0 |
## 1 |
## 0 |
## = |
## ? |

## 0 |
## 1 |
## 0 |
## 0 |
## 0 |
## 0 |
## 1 |
## 1 |
## = |
## ? |

## 1 |
## 0 |
## 1 |
## 1 |
## 1 |
## 0 |
## 1 |
## 0 |
## = |
## ? |

## 1 |
## 1 |
## 1 |
## 1 |
## 0 |
## 0 |
## 0 |
## 0 |
## = |
## ? |

## 1 |
## 1 |
## 1 |
## 1 |
## 0 |
## 0 |
## 0 |
## 1 |
## = |
## ? |

# -------------------------------------------------------

# -------------------------------------------------------

Now, to wrap this entire concept up, remember the heart of the digital machine, the processor? What if this processor was exactly like a series of lightbulbs. If the machine used Base 2, and the machine “knew” how many lights were turned on or off, then it would be able to understand numbers, yes? In all actuality, this is exactly how processors work. Instead of lightbulbs, a processor uses a series of components called “transistors”. Transistors can be made to be extremely small and even with different materials, but with all traditional digital machines, the concept is still the same. There must be some series of components in the processor that are powered or conversely, not powered. There must also be a function for the machine to interpret how many of the transistors are powered and how many are not, and to know the value of each transistor (1, 2, 4, 8, etc.). With these two concepts, the processor is able to understand numbers. Additionally, one who is reading this has taken the first step to learn how to communicate with machines.

However, before the end of this lesson, an update of Binary nomenclature is in order. Instead of using the term “digit” in reference to numbers in Binary (or Base 2), the term “bit” is used. Again, a bit is only capable of representing two values, true or false, 1 or 0, etc. Zero is always false and one is always true. If there are 8 bits, this is called a byte. If we have a 32 bit number, it is perfectly fine to also call it a 4-byte number. If we have 1,000 bits, we call this a kilobit, and 1,000 bytes is a kilobyte. From there, a million bits or bytes is a megabit or megabyte respectively, then gigabit or gigabyte for billions, and so on and so forth. In the next lesson, one will build upon the knowledge learned in this lesson and apply it to other portions of the digital machine. While a processor is able to understand numbers, this does not imply that it can single-handedly perform operations on those numbers to output results of a given input, so therefore the next lesson will be about * Memory and Processing*.

While I cannot supervise the completion of your homework, I must stipulate that anyone found using a computer or other calculation device to finish this work will be accused of Academic Dishonesty, and will be reported to the Dean.