4

I've just been watching a rather interesting series of videos about the MITS Altair 8800. It has a button on the front panel to single-step the CPU one instruction at a time... Except that, on closer inspection, that's not actually what it does. What it actually does is convince the CPU that there's bus contention, preventing it from executing the next bus cycle until you press the button. So an instruction might actually take multiple steps, or none at all. (Well, other than to fetch the opcode.)

That's a slightly strange way of doing things. I came away with the following hypothesis:

  1. Big mainframes and minicomputers were explicitly designed from the start to allow instruction single-stepping, and made specific hardware design decisions to support this.

  2. The cost-optimised Intel 8080 IC that powers the Altair was not designed to support single-stepping, so the people at MITS had to come up with a kludge to make a CPU "single step" when it wasn't really designed to support that.

Is that approximately right? It sounds plausible to me, but then, I'm just making stuff up, so maybe I'm completely mistaken...

  • I have no clue here, but would be interested in some elaboration of your first point -- what are these design decisions enabling single-stepping in hardware? – Felix Palmen Jan 31 at 23:08
  • As a one time owner of an original production run Altair 8800 kit, there's a class of programs you can enter in from the front panel where single stepping is useful for debugging. altairclone.com/downloads/manuals/… Page 41, E. Operating Hints, 3. Debugging Programs. – user9041 Jan 31 at 23:37
  • @FelixPalmen Simply the addition of a front panel allowing to read and set all registers, PC and machine status register, as well as read and write all memory (on word level) and finally single stepping on an instruction level. All of this done on a hardware level, so without the interferance of any software monitor program (as what is used on microcomputers). These panels were an integral part of the CPU itself. – Raffzahn Feb 1 at 2:19
  • I think this is quite a common thing, the 68000 requires a constant clock signal, but it allows for asynchronous bus communication: it waits for the addressed peripheral (e.g. RAM, DUART) to pull a line called DTACK low once the data to be access has been placed on the data bus. Single stepping therefore requires you to control the DTACK line, keeping it high until you want it to step, then use a one-shot circuit to pull it low for a clock cycle, allowing the CPU to continue on to the next instruction but no further. – Matt Lacey Feb 1 at 5:17
  • 1
    @MathematicalOrchid Erm yes and no. A front panel of a mainframe is direct wired into the CPU. it's part of the CPU and connected with hundrets of wires direct to each part it accesses. Not realy possible on a micro. Ofc, a boundary scan system, like the JTAG TAP in use nowadays, could have been implemented to export information from the CPU while halted, like a mainframe but with less wireing - except the TAP would have been as complex as the 8080 (or any other early CPU) itself. So micros went without and it continued that way until today. – Raffzahn Feb 1 at 13:19
3

It has a button on the front panel to single-step the CPU one instruction at a time... Except that, on closer inspection, that's not actually what it does.

Exactly, and it's not what the button is intended to do. The purpose is not to single step an instruction, but to single step a cycle.

That's a slightly strange way of doing things.

No, it's exactly what what is needed. For one, single stepping an instruction sounds nice for software developers, but when it's about hardware, and that's what a CPU (and the Altair) is about. With cycle stepping the user is able to see every machine cycle and ho the bus reacts displayed.

On a closer look, this is exactly what you want as well as a software developer. The Altair CPU is an extreme bare bone construction. Just the CPU itself, a clock generator, an 8 bit port and a bit of glue logic. These switches and LEDs are your interface to the machine. Your terminal and your debugger. And all debugging functions there are.

There is no monitor program

Looking close you won't find any button to read out a register (like on a mainframe) or modify them. All you can do is look at the content of a memory address, modify it, and single step the CPU. And that's exactly how you follow the execution of a program and examine it's working.

  • First you see the address of the instruction fetched - go decode it from memory.

If the operation has parameters:

  • You'll see address and value of all operands fetched (one byte per step) - remember it

If the instruction des some memory access:

  • You'll see what address the CPU accesses and what values are read or stored.

If you remember all of this, your imagination will show you a debugger line of the instruction executed including all memory fetches and reads or writes. Cool, isn't it? And none of this would be visible if the button would be to single step on instruction level. All shown would be address and opcode of the next instruction to be executed.

Keep in mind, this computer operates at the lowest end possible. No software preloaded. Getting a PROM with some monitor program would have been an additional investment and another board to plug in - not to mention the need to buy a terminal of some sort.

Considering this it's amazing how much can be done by just looking at each cycle. And here also a major difference to mainframes is to be seen. mainframes don't eat and execute instructions on a byte level, but fetch whole instructions and then execute them. In so far a mainframe works more like a RISC CPU than a classic microprocessor.

The cost-optimised Intel 8080 IC that powers the Altair was not designed to support single-stepping, so the people at MITS had to come up with a kludge to make a CPU "single step" when it wasn't really designed to support that.

Nop. As explained, MITS did use this to allow program development and debugging on a very low hardware level, without any software involvement and still be able to provide some information.

From the CPU's point of view it would have been no issue to implement single stepping on instruction level as well. All needed to provide this is using the M1 signal provided by the CPU instead of PSYNC (as the excerpt provided in manassehkatz' answer describes) to reset the single step flip-flop. Of course now, not useful information beside instruction address and opcode can be derivated.

  • It's slightly frustrating that you can't see memory writes from the front-panel, only reads... But hey, that isn't your fault. :-) – MathematicalOrchid Feb 1 at 10:57
2

From the Altair 8800 Theory of Operation Manual & Schematics 1975:

The Single Step circuit consists of a dual single shot (IC M) for debounce and the SGL STP flip-flop (R-S type). When the machine is in a stopped mode, depressing the SS switch will set the SGL STP flip-flop. (The machine must be stopped for any of the front panel switches except RESET to be active.) This allows PRDY to go high. The machine will execute one machine cycle and PSYNC, on the next cycle, will reset the SGL STP flip-flop. This will pull PRDY low, stopping the machine.

I'm sure someone will come along with a far more detailed & complete explanation. But it looks to me like this was a useful side effect of other circuitry designed to tell the CPU to wait while DRAM refresh or other things were going on. End result - "cycle" rather than "instruction". But it works.

I suspect some of the confusion comes from the similar, but slightly different, operation of a software debugger. A software debugger can use any combination of virtualization, hardware assistance at some level (whether CPU-based or additional hardware) or even a simulator, or just some well-written software (i.e., that causes a return to the debugger program following each and every "real" instruction) to single-step through a program. A debugger, by its nature, works on full CPU instructions. It can't split them up because it is operating at a higher level (unless it is an extremely sophisticated simulation). But a hardware-level single-step process, like in the Altair, can function on machine cycles rather than CPU instructions. I think that could be extremely useful when debugging hardware problems, which in the new-at-the-time ecosystem of 8-bit microprocessors, probably happened quite a bit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.