Kenbak-1 SKIP Instruction 2


Introduction to the Kenbak-1 SKIP Instruction

The Kenbak-1 SKIP Instruction allows us to skip an instruction in memory. We base this on a certain bit at a memory cell being high or low. Let’s say we only want to display odd numbers. If bit zero is high on the value we want to display, we know that number is odd. Therefore, we could skip the instruction that stores the value to our display. Likewise, if we don’t want to display negative numbers. We can look at bit #7 of a byte. If this bit is high, then we can skip the instruction that displays the value, assuming we consider the values to be signed. Keep in mind, the Kenbak-1 does not know whether a value is signed or unsigned. It’s up to us how we wish to use the values. When a signed value is negative, the most significant bit (#7) is true.

SKIP is a two byte instruction. The first byte obviously contains the instruction and it’s parameters. The second byte contains the location of the memory cell we wish to look at. If the skip condition is true, then the program counter (cell #3) increments by 4. On the other hand, if the skip condition is false, the program counter, only increments by 2. For signed values, our limits are -128 to 127. Likewise, for unsigned values, our limits are 0 to 255.

I’ll be using the EmulatorKenbak-1 for this example. If you wish to buy a kit, you can purchase one from adwaterandstir.com

SKIP Instruction Layout:

Bit #7 -- Always High (1)
Bit #6 -- 0 for skip on 0, 1 for skip on 1
Bit #5, #4, and #3:  These three bits contain the bit number we wish to look at.
Bit #2, #1, and #0:  Always 010 for the SKIP instruction

Using the SKIP Instruction

To demonstrate, let’s enter a simple program that will act as a binary counter. We’ll continuously increment the A register, and dump this onto our LED display (cell #200) However, we only want to display the ODD numbers. Remember, to accomplish this, we can look at bit #0 of the A register. If this bit is off, then we will skip the lines of code that store the A register to the display.

Let’s enter the following program:

  • In cell #3, we simply initialize the program counter
  • In cell #4 & #5, we are loading a 0 to initialize the accumulator
  • For Cell #6 & #7, simply add the value of 1 to the accumulator
  • At Cell #10 & #11, we are looking at the A register. If bit 0 of the A register is off, we add 4 to the program counter. This will effectively skip #13 and #14. Therefore, we will only display odd numbers.
  • We write the A register to the display in cells #13 and #14.
  • Finally, in #14 and #15, we jump back to cell #6. This restarts the program without re-initializing the A regsiter.

Entering the Program

By now, most of you are familiar with how to enter a program into the Kenbak-1. Press START, then STOP to get the Kenbak to a known state. After that, press CLEAR, and enter 003 on the front panel buttons. Press SET. You are now ready to enter data at cell #3. On your buttons, enter 004, then store and clear. At this point, you are ready to enter each line of code. Just be sure to press STORE, then CLEAR after each line.

When you are finished, press START.

As you can see, only ODD values appear on the display.

Emulator at http://www.neocomputer.org/kenbak/kenbak1-JS.html

Summary for the Kenbak-1 SKIP Instruction

In short, the SKIP instruction can look at any bit of any byte in memory. We configure the instruction to skip the next 2 memory cells of the program. We base this on a particular bit out of a byte being high or low.

For examples of other instructions, visit the Kenbak-1 Category page!

— Ricky Bryce


Leave a comment

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

2 thoughts on “Kenbak-1 SKIP Instruction

  • Oliver

    Hello, my name is Olivier.

    First of all I thank you for your excellent work. Your articles are of very good quality. I am currently reading your series on the Kenbak-1. I am coding my emulator on an Atmega328P and your information is very valuable.

    I just wanted to point out a small error in the article about the “Kenbak-1 SKIP Instruction”.

    In the paragraph “SKIP Instruction Layout:” in the last line I think it is :

    Bit #2, #1, and #0: Always 010 for the SKIP instruction

    instead of Bit #2, #1, and #1: Always 010 for the SKIP instruction

    Thank you for your work.

    Best regards.

    • Ricky Post author

      Thank you Oliver! I’ll take a look at that, and make the correction. Hope you are enjoying that Kenbak! I have a lot of fun with mine, and learned a lot that I can apply to other processors as well. When you get down to the basics, you really understand what is going on at the hardware level, instead of just running someone else’s software, and taking the machine for granted! Take care! — Ricky