4: From Binary To GUIs. Part 2.

Take Up Code - Un pódcast de Take Up Code: build your own computer games, apps, and robotics with podcasts and live classes

Categorías:

You’ve probably heard that computers only understand zeros and ones. So how does a computer go from zeros and ones to colorful graphical interfaces with buttons and web browsers? This is part two of two episodes that explain this. This episode is focused on a computer’s microprocessor and how values in memory are sometimes executed as instructions and sometimes used to supply extra information. Listen to the full episode or read the full transcript below. Transcript In part 1 of this episode, you learned all about bytes and memory with a tiny bit of math. Okay maybe a bit more than just a tiny bit. When I was planning these episodes, I realized you probably needed a chance to absorb all of that so I decided to break the topic into 2 parts. What about the microprocessor? Sometimes, I might just call this the processor for short. The microprocessor is what controls and directs everything and it does this by reading instructions one at a time from memory. It doesn’t know how to do anything on its own and relies on the values in memory making sense. Hopefully, you can see why we can’t rely on the random values in RAM to help here. That’s why we need some values to be ready in ROM the moment the computer wakes up and goes to get its first instruction. Where does it get this instruction? Well, for our computer, let’s say that the microprocessor has some built-in programming of its own that we can’t get to but that defines its basic behavior. This behavior tells the microprocessor that the very first thing it should do when it wakes up is go to memory address 0 and read that value. We’re going to want the memory addresses 0 through 999 which makes up 1000 addresses to map to our ROM. That way, we can rely on what the microprocessor will find when it looks in memory address 0. We’ll make sure that our computer places the 1000 bytes of RAM right after the ROM. So the RAM will be found in addresses 1000 through 1999. So what does it find at memory address 0? Well, it had better be the first instruction. The processor will read that instruction and execute it. How does it know what that means? How does it know what to actually do? The same built-in behavior that told it to go to memory address 0 in the first place also knows how to determine what to do. At this level, the types of things the processor will be doing look nothing like windows or web browsers. It takes millions of instructions to build even a small GUI application. It’s a good thing that microprocessors are very good at reading and executing the instructions. Once the processor executes an instruction, it has more built-in behavior that tells it where to find the next instruction and that will be at the next memory address. Let’s move away form processors for a moment and talk about instructions in general. Imagine that you’re playing a game with a friend and you can give your friend simple instructions turn left, turn right, jump, and take steps. The other person already knows how to turn left or right and will turn the proper direction by 90 degrees each time. And jump means to jump in place. But what about that other instruction to take steps? How many steps? Let’s limit the number of steps to 5 and let’s also allow 0 steps to mean take no action. Seems simple so far, right? The game will start with you saying “Power Up” and your friend will ask “What’s my first instruction?” We could have you issue the commands in English, but what if we make it a bit more interesting and you issue the commands as numbers. 0 will mean turn left, 1 will mean turn right, 2 will mean to jump, and 3 will mean to take steps. The instruction 3 which is for taking steps will need to be followed by another number for how many steps to take. You could if you wanted to write out all of your command numbers in order so they will be available without you needing to think about them. Th

Visit the podcast's native language site