Kenbak-1 Overflow and Carry Registers


Introduction to Kenbak-1 Overflow and Carry Registers

Kenbak-1 Overflow and Carry Registers will tell us when a math instructions results in a value that is out of range. In this post, we’ll discuss all values in OCTAL. Keep in mind the Kenbak-1 always thinks in BINARY. At the same time, humans, we tend to remember numbers better if they are in the form of a more regular digit. Normal people will usually think in decimal. For this post, though, let’s become slightly less normal, and think of everything in octal.

Let’s review the basic BINARY to OCTAL conversions:

Remember, the Kenbak-1 uses 8 bits that we number 0-7. This would be 3 bits for each octal value, except for the most significant bits. Bits 6 and 7 are the most significant bits, so the maximum value for the first octal digit is 3.

Examples:

333 = 11 011 011
165 = 01 110 101
007 = 00 000 111

As you can see, the maximum value possible here is 377 octal.

Overflow Vs. Carry

As humans we can think of these values in one of two ways. The number can be signed or unsigned. Signed values can have a negative number. Keep in mind, the Kenbak-1 does not know how we are thinking of these values, signed or unsigned. It simply gives us a result. It’s up to us to know if we want to expect a signed or unsigned value. At this point, we can then use either the Overflow or Carry bit in our program when we need to know if the value is no longer accurate (to what we expect). The value has exceeded the limits.

The registers for overflow and carry are 201, 202, and 203. This is for the A, B, and X registers respectively. As far as I know, the Kenbak-1 only uses 2 bits of each rebister. Bit 0 is for overflow, and bit 1 is for carry.

Basically, when the Kenbak goes over 177, it will set the overflow bit. Remember, this is bit 0 of the overflow and carry register. On the other hand, if the Kenbak goes over 377, it will set the carry bit. Both bits could represent an overvalue condition. The Kenbak simply tells us that if we recognize the number as signed, then we’ve exceeded 177. Likewise, if we expect the value to be unsigned, we’ve exceeded 377.

Demonstration Program

To demonstrate, I’m using the Kenbak-1 emulator at neocomputer.org. This is a good tool for testing a program before you enter it into a hardware replica. Thank you, David Richardson for putting this together!

As you can see, in memory cell 003, we initialize the program counter to start at 004. After that, we “pre-load” the “A” register with the value of 160. That way, we don’t have to wait so long to see the overflow bit go high.

Likewise memory cell 006-14, we simply set up a delay loop, then in memory cell 016, we jump back up to location 006.

Keep in mind that to start entering the program, you should hit start, then stop. Now press Clear. Enter 003, then SET, and CLEAR. At this point, you are ready to enter the program. Enter 004 on the buttons, then store then clear. Likewise for each line, enter the corresponding value, then press STORE, then CLEAR. When you are finished, press START, and watch your A register (000). Also keep an eye on the overflow and carry cell (201).

As you can see, when we go past 177, the Kenbak sets the overflow bit. Likewise, when the A register exceeds 377, it will set the CARRY bit, and start back at 0. Keep in mind that if you are thinking of this as a signed value, bit #7 is not part of the value. It’s simply the sign bit, and when it’s high, the number will be negative.

Image from NeoComputer.org/projects

Summary for Kenbak-1 Overflow and Carry Registers

In Short, the Kenbak sets the OVERFLOW bit when the value goes above 177. Likewise, the CARRY bit sets when the value exceeds 377. You can use these bits in your program how you wish!

For more information on vintage computers, visit the vintage computer category page!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *