Fully Functional 1KB Hard Drive in Vanilla Minecraft

You can imagine it like every single bit being on a rail, like a train is. You can now control whether these bits are allowed to travel and what rail they will use using something like a railroad switch. The instructions that the CPU reads, set the switches in order to allow bits to travel to a certain direction or not.

To perform actions like multiplications, you have dedicated units on the processor chip itself, for example the must fundamental ones being Arithmetic Logic Units. So if you have a 32-bit CPU you can think of the memory consisting of 32-bit units (called a word of memory). And each of these need 32 little rails that connect every single bit to every calculating unit it can go to.

Because that gets very complicated very fast - this is for just four bit numbers!, even very advanced processors only have a handful of registers (memory units on the processor itself), and only perform operations (addition, multiplication, etc.) with data from these registers.

So in order to start a program, you will first need to load it off the hard drive, which is very large but also very slow to access, let's just say it's about a terrabyte in size. From there it goes to the working memory (typically RAM), which is smaller but faster - at 8 Gigabyte it would be less than 1% as big as a 1 TB harddrive. Then comes the cache, which again is smaller and faster, and is often seperated into different tiers (each smaller and faster than the last), possible numbers for a three-tiered cache would for example be 1 mb - 256 kb - 32 kb.

And then, finally, the data gets into the registers, which might for example be 16 registers holding 64 byte each (1 kilobyte in total) for each core on a modern 64 bit processor.

Now, if you want to run an actual program it goes like this:

  • The firmware and then the operating system stars first, so we can assume that it's already running. Other programs can only start by being called by another program, so let's say you double-click a desktop icon and your OS starts the program.

  • This instructs your CPU to load data. You can interpret "start this program" as "load the data from some memory address and execute it as instructions".

  • The CPU uses a command pointer that tells it which memory address it will execute next as a command. After executing that command, it will typically just jump to the next memory address to execute that one. Unless the command it reads is a "Jump" command, which specifies what other memory address to execute next.

  • When the data arrives, it might look something like this as a simple example:

  1. Add content of memory addresses 3 and 4 and save the result at address 3

  2. Jump to memory address 5

  3. 1

  4. 2

  5. If the content of memory address 3 is smaller than 5, jump to memory address 1

  6. Show the content of memory address 3 on the screen

  7. Jump to the address that is saved in memory address 9

  8. #a3ff1245 // a return address that was left behind by the higher-up program that started this one

So this program would increment the content of memory address 3 (which is 1 initially) by 2, until it is at least five. Then it would show the number on the screen (which of course wouldn't be quite as simple in reality), and then it would terminate itself by returning the control flow back to the higher-up program that called this one, by jumping the command pointer to an address that was left behind by the calling program.

/r/gaming Thread Parent Link - imgur.com