Transistors and the Legend of Zelda

Zhila
5 min readJun 11, 2022

We’ve all heard the phrase “it’s all just 1’s and 0’s” when it comes to computing, but thinking about what that really means is mind-blowing.

So how does a computer actually work? The first basic component to understand are transistors. A transistor is essentially a switch that can turn electricity on and off extremely fast by use of a control wire and 2 electrodes.

Illustration of transistor with on and off states

Using transistors and some Boolean algebra, you can build a circuit known as a logic gate, translating the electrical current into “and”, “or”, and “not” functions.

For example, an “and” gate is built using 2 transistors, where both have to be switched on to allow electricity to flow through in order for the output to be set to “on” or “true”, which equates to an “and” logic statement since both items in the comparison must be true in order for the outcome to be true.

So now that we know we can use transistors and create circuits to calculate the output of a logic gate, we can abstract that concept away and not worry about the electricity flow. But what about the inputs?

How do we also use electricity to represent things like numbers, characters, graphics, etc? We can do this by using binary math as well as collectively agreeing as humans how to map a non-numerical item with a number.

So first let’s look at Binary. The math we learned in school was the decimal system, based on numbers 0–9. In the decimal system, once you reach the number 9, you replace the 9 with a 0 and add another digit to the left with the number 1, making 10. This can also be expressed as 1* 10¹ + 0* 10⁰.

Decimal system for calculating the number 186

Similarly, we can use this same method but with a base 2 (binary) system instead of base 10.

The decimal number 7 is equivalent to 111 in binary

Now for some computer lingo, each space of a single digit is stored as a bit of data, and 8 bits make a byte. So the number 7 is stored using 3 bits: 1,1,1. And when we think about those 1’s, we can again think of the transistor as being switched on, allowing electricity to pass through.

Computer memory chips are made of millions of these tiny transistors and they can even hold the electricity once the power has been switched off because the transistor has electrical insulation. This is why a usb stick (or your computer) can store what’s been saved to it even when it is not receiving any electricity. Otherwise everything would revert to a 0 every time the power was switched off, and all data would be lost.

Historically, computers were based on 8 bit architecture. If we go back to our binary math, the highest number storable on 8 bits is 255 in decimal, where all 8 digits are switched on to 1, or 11111111. Nintendo’s NES was based on 8 bit architecture, which is why in The Legend of Zelda, the maximum rupees Link could hold was 255 because the developers used only one 8 bit integer to store the rupee variable.

Of course they could have increased this variable to count past 255 by adding more storage, such as additional variables and counters or logic gates that would tell the additional variable when to start counting past 255, but this was an expensive trade-off at the time.

So that explains numbers, but how do we also represent characters, symbols, or even colors using 1’s and 0’s? Basically, we as humans came up with a standard where we agreed on the definitions of them by assigning each a number. Originally this was done with a table called ASCII, but the latest version of these definitions are Unicode, which was created in 1991 and has encoded all letters and characters (including different languages, and even emojis) to a number. And as we already learned, any number can be converted to binary and represented by 1’s and 0’s. So computer makers collectively add these tables to all computers so that they are all compatible with each other and speak the same language. 😉 You can read more about Unicode here.

Colors also are represented by numbers and this is where again the magic number 255 from our 8 bit origins appears. Every color can be represented by a mixture of Red, Blue, and Green. Black is 0,0,0 (the absence of color) and White is 255,255,255.

There is of course more to learn in terms of how transistors and circuits end up translating into graphics on the screen of your device, which I won’t cover here. All of that complexity which goes on under the hood of the computer is abstracted away to the end user (and even to most computer programmers), but the next time you are using your phone to watch a TikTok or check your email, you can now understand that they really are just a mix of circuitry, binary math, and some standards that computer scientists agreed on; it really is all just 1’s and 0's.

--

--