Binary Adding Machine

From Scientific Programs
Jump to: navigation, search

Recently, I began reading the well-known "Code The Hidden Language of Computer Hardware and Software" by Charles Petzold. It is available here. This book is highly recommended, especially for those new to computer science. Charles does a great job of explaining complex concepts in a comprehensible and beginner-friendly manner. I would also like to mention that a new edition of this book has recently been released that you can download here.



Charles demonstrates how to create a binary adding machine that adds two binary numbers of 8 bits in size. I decided to make an implementation of this machine in Minecraft and also in JavaScript. You can download the complete JavaScript repository here.



This article will show you how to complete the entire procedure step-by-step. I will show how I was able to follow the instructions in chapter twelve to create this machine in both JavaScript and Minecraft. If you would want a more detailed explanation of any of the following topics I suggest you go through chapter 12 of the book mentioned earlier. My cms



Introduction



To add two binary numbers with 8 bits first, we need to be capable of adding two binary numbers with a 1-bit format. The sum of these two 1-bit numbers will result in a 2-bit number. We'll call the first part of this 2-bit number the "sum" bit and the second one the "carry" part. If you wanted to sing an anthem about it, you might say:



0 plus 0 equals 0.



0 plus 1 equals 1.



1 plus 0 equals 1.



Take the 1.



The table below describes the sums of our two 1-bit number.



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 part. Here's the gate I've built in Minecraft (with a little assistance from Mumbo Jumbo).