μKenbak-1 assembler

109 views
Skip to first unread message

Dave Bell

unread,
Dec 6, 2018, 11:00:09 PM12/6/18
to Frank P., Altair-Duino, jim3...@gmail.com

OK, folks, this is a work-in-progress, but as it is, it is functional and (as far as I can tell) correct.

 

It’s written in Excel (huh, really?), with a mix of worksheet functions, keyboard macros, and VBA code.

I built a dictionary of all documented Kenbak-1 opcodes, in octal and as mnemonics.

 

The main event is the first tab, named Encoder.

The second tab, Decoder, was a quick disassembler, useful for analyzing code dumps from elsewhere.

Also attached are two Kenbak docs, including the original coding sheet.

 

In the Encoder tab, hitting ctrl-Q pops up an entry form, with Label, Address, and Instruction fields.

The address defaults to 3 initially, to preload the PC register. And the focus in in the Instruction foeld.

Start typing an instruction, say  you want to enter “LOAD A, CONSTANT”; as soon as you type the “L”, the combo box fills in “LOAD A, CONSTANT”. If you wanted “LOAD B …”, either type a little farther, or use the down-arrow to walk the (alphabetical) list of instructions. Click on the Insert button or double-Enter to insert the instruction (first byte only) at the current address. The address will automatically increment for the next step. If the instruction requires a second byte for a constant, address, etc., enter that as either a numeric (octal!) constant, or as a label. Before entering the line, you may also type a label in the Label field.

 

The Encoder emulates (sort of) a two-pass assembler. In the first pass, the programmer’s code is entered, taking up as many bytes as necessary as it grows, but labels are only entered as placeholder. In the second pass, the placeholders are resolved and filled in with the actual addresses. In this model, whenever you enter a name in the label field, it is added to the dictionary, along with its sequential address. The column next to the instructions, that is building the octal opcodes, immediately references the dictionary and the numeric address updates in real time. The label dictionary is actually a tail appended to the instruction dictionary (in the All Codes tab), so it’s all the same process.

 

Before starting to enter a program, hit ctrl-E to erase any pre-existing labels. As the new program is entered, the dictionary is extended again, for the new codes.

 

When you’re satisfied with the program as displayed, hit ctrl-W to write the code to a condensed block of octal bytes, ready to copy and paste into the Kenbak-1 JS Emulator’s Memory Loader page. Per Jim’s request, I added a similar block in hex, below the 16 lines of octal strings.

 

To the right, there are two columns labelled “Octal Addr” and “Code”. These are 256 row columns with the address and code bytes stacked up, useful if printed out (hint: use “set Print Area”) f0or hand entry into the Kenbak. And,to the right of those, the same data in hex…

 

As attached, the program contains Frank’s Hello World! Program, with the addition of writing the character to the output port as well as to serial using SYSEX. This runs fine in the JS Emulator, and if you slow the exectution down or use the single-step function, you can see each ASCII byte in the data LEDs.

 

Dave

Kenbak Coding Sheet HelloWorld 181206.xlsm

jim3...@gmail.com

unread,
Dec 7, 2018, 7:51:47 AM12/7/18
to Altair-Duino
Wow! Just Wow!

This is a nice piece of work. This along with a serial loader will make the Kenbak more than just a novelty if someone wants to do a bit of simple coding.

I've been building a KIM clone and going through the The First Book of KIM. I could see porting some of the simple projects from that over to the Kenbak now.

Thanks,
Jim

Dave Bell

unread,
Dec 7, 2018, 1:06:10 PM12/7/18
to jim3...@gmail.com, Altair-Duino

Thanks, Jim! It was a fun project.

Now, I need to add an RS-232 port or other means so I can reprogram the Atmega and stream in Kenbak code…

 

A couple notes on the assembler:

The shaded areas in the Encoder tab are pretty much keep-out zones.

They contain spreadsheet formulas that don’t change.

The clear, white area in columns C & D are where the code builds, and you can almost as easily enter stuff manually, especially in D. Useful for storing strings, instead of through the form.

                                                                                                                                          

Dave

--
You received this message because you are subscribed to the Google Groups "Altair-Duino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to altair-duino...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/altair-duino/168583cb-8f2e-4a85-8ee5-3fdb7d8ec8c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ardunaut

unread,
Oct 1, 2020, 10:12:51 PM10/1/20
to uKenbak-1
Hi Dave,
Thanks for your spreadsheet.
Trying to understand in detail the instructions of the Kenbak-1
I can understand the difference between LOAD A, CONSTANT   and  LOAD A, MEMORY
but I don't understand the difference between   STORE A, CONSTANT   and  STORE A, MEMORY
am i forgetting something?
regards,
Vicente

William J. Steele

unread,
Oct 1, 2020, 11:03:55 PM10/1/20
to Ardunaut, uKenbak-1
Check the Kenbak-1 manual.  On page PR-4 it states, "In the Store instruction the operand address is where the data is stored. In the Store Immediate instructions the data is stored in the second half of the instruction."

So, it's taking the A register's value (at address 00000000) and stuffing that value into the byte immediately following the Store instruction (00011011).

Bill


From: uken...@googlegroups.com <uken...@googlegroups.com> on behalf of Ardunaut <agr...@gmail.com>
Sent: Thursday, October 1, 2020 10:12 PM
To: uKenbak-1 <uken...@googlegroups.com>
Subject: Re: μKenbak-1 assembler
 
--
You received this message because you are subscribed to the Google Groups "uKenbak-1" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ukenbak-1+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ukenbak-1/d33c4b2a-2428-4c41-a4de-71492a04f050n%40googlegroups.com.

Ardunaut

unread,
Oct 2, 2020, 1:35:05 AM10/2/20
to uKenbak-1
Thanks for your help Bill, and for reminding me to always read the manuals.
Now that instruction makes sense, although I find an instruction changing the content of its own space a bit strange.
I was blocked by my Embedded Systems designer mindset where the code used to be in ROM.
regards,
Vicente
Reply all
Reply to author
Forward
0 new messages