Binary Adding Machine

2 min read
27 September 2022


Recently, I have began reading the renowned "Code The Hidden Language of Computer Hardware and Software" by Charles Petzold. It can be found here. I highly recommend this book especially if you're new to computer science. Charles does an excellent job of explaining difficult topics in a palatable and user-friendly manner. I'd like to add that a revised edition of this book was released recently and is available here.



In chapter 12, Charles describes how to make a simple binary adding machine to add two binary numbers with 8 bits. I decided to make an implementation of this machine in Minecraft as well as in JavaScript. The complete JavaScript repository can be found here.



In this article, we will walk through the entire process step-by-step. I will demonstrate how I was capable of following the directions in chapter twelve to create this machine in both JavaScript and Minecraft. If you would like a more in-depth explanation of any of the topics listed below I would suggest you read chapter twelve of the book mentioned earlier.



Introduction



First, we need to be able to add two binary numbers of 1 bit to add two binary numbers of 8 bits. The sum of these two 1-bit numbers will be a 2-bit number. We'll refer to the first part of this 2-bit number the "sum" part and the second one the "carry" part. You can sing a song about it:



0 plus 0 equals 0.
editum



0 plus 1 equals 1.



1 plus 0 equals 1.



1 plus 1 equals 0, carry the 1.



The table below shows the sum of our two 1-bit numbers.



Logic Gates



We'll need logic gates to do this. We'll start with the AND gate, since we can use it to calculate the carry bit. Here's the gate I've constructed in Minecraft (with some assistance from Mumbo Jumbo).

In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up