IMSAI 8080 & Altair 8800 hex dumps to octal

If you play around with entering programs via the toggle switches on the Altair 8800 or IMSAI 8080 or one of their clones, recreations, replicas or simulators, you may want to enter a hex dump of an assembler program via your front panel. While most experienced programmers prefer the hex notation, it is a bit error prone to convert the hex digits in your head into the binary notation of a nibble (4 bits). This is why many example programs in the original manuals and also the front panels of these systems feature the unusual octal notation. It is very simple to convert octal into binary and if you are used to UNIX permissions, you will already know these by heart.

Many assembler listings for these Intel eighty-eighty based machines that you can find online either include or are accompanied by a hex dump. Here below is a short python 3 script to convert these text files into lists of addresses, hex notation (for comparison to the source), octal notation (for easy entering into the front panel) and LED pattern (the binary notation for comparison to the lit LEDs on the front panel):

#!/usr/bin/env python3

from sys import argv, exit, stderr
from pathlib import Path

def error_exit(message):
    print(message, file=stderr)
    exit(255)

if len(argv) < 2:
    error_exit("missing argument\nUsage: " + argv[0] + " ")

hex_file = Path(argv[1])
if not hex_file.is_file():
    error_exit("file '" + argv[1] + "' not found")

byte_count = 0
for line in hex_file.open():
    line = line.strip()
    if len(line) > 0 and line[0] == ":":
        for nibbles in zip(line[1::2], line[2::2]):
            if byte_count == 0:
                print("addr\thex\toct\tled\n----\t---\t---\t---")
            byte_count = byte_count + 1
            hex_digits = ''.join(nibbles)
            digits = int(hex_digits, 16)
            led_digits = '{0:08b}'.format(digits).replace('0', '◦').replace('1', '•')
            print("{}\t{}\t{:03o}\t{}".format(byte_count, hex_digits, digits, led_digits))

Here is an example output from a light demo hex dump found on the z80pack site for the IMSAI 8080:

$ ./hex2oct.py lightdemo.hex 
addr	hex	oct	led
----	---	---	---
1	10	020	◦◦◦•◦◦◦◦
2	00	000	◦◦◦◦◦◦◦◦
3	00	000	◦◦◦◦◦◦◦◦
4	00	000	◦◦◦◦◦◦◦◦
5	3E	076	◦◦•••••◦
6	01	001	◦◦◦◦◦◦◦•
7	0F	017	◦◦◦◦••••
8	3E	076	◦◦•••••◦
9	FE	376	•••••••◦
10	D3	323	••◦•◦◦••
11	FF	377	••••••••
12	11	021	◦◦◦•◦◦◦•
13	01	001	◦◦◦◦◦◦◦•
14	00	000	◦◦◦◦◦◦◦◦
15	21	041	◦◦•◦◦◦◦•
16	00	000	◦◦◦◦◦◦◦◦
17	00	000	◦◦◦◦◦◦◦◦
18	19	031	◦◦◦••◦◦•
19	D2	322	••◦•◦◦•◦
20	0D	015	◦◦◦◦••◦•
21	69	151	◦••◦•◦◦•
22	05	005	◦◦◦◦◦•◦•
23	00	000	◦◦◦◦◦◦◦◦
24	10	020	◦◦◦•◦◦◦◦
25	00	000	◦◦◦◦◦◦◦◦
26	00	000	◦◦◦◦◦◦◦◦
27	07	007	◦◦◦◦◦•••
28	C3	303	••◦◦◦◦••
29	05	005	◦◦◦◦◦•◦•
30	00	000	◦◦◦◦◦◦◦◦
31	1C	034	◦◦◦•••◦◦
32	00	000	◦◦◦◦◦◦◦◦
33	00	000	◦◦◦◦◦◦◦◦
34	00	000	◦◦◦◦◦◦◦◦
35	01	001	◦◦◦◦◦◦◦•
36	FF	377	••••••••

Another, similar example can do the night rider lights on the IMSAI 8080.

Of course, these short examples are just good practice to get a feel for the toggle switch operation. In practice you would only ever do this to for boot strapping your larger applications from ROM and/or load applications from tape or floppy.

Discussion Area - Leave a Comment