I got tired waiting for DEC's PAL assembler to run on a friends home DEC PDP-8e so I wrote this CDC 6500 simulator and ran the assembler binary there.
There were only eight instructions to simulate. I wrote seven of them in assembly language and one more in Fortran, the I/O transfer instruction (IOT).
The logical AND instruction coded up as three lines. One to fetch the argument, a second to perform the boolean operation, and a third to jump back into the interpreter's instruction fetching loop.
AND FETCH X3,X4 BX2 X2*X4 EQ INT1
The two's complement add (TAD) instruction required one line to perform the integer add and two more to isolate the 12 PDP result bits and carry from the 60 provided by the CDC computer.
TAD FETCH X3,X4 MX6 -13 IX2 X2+X4 BX2 -X6*X2 EQ INT1
The CDC had eight general purpose registers. Four of these were allocated to hold PDP registers.
X2 PDP-8 Link and Accumulator X3 PDP-8 Memory Address Register (most times) X4 PDP-8 Memory Data Register (most times) X5 PDP-8 Program Counter
Each PDP instruction occupied a single word. The program counter (X5) pointed to the next instruction which could be skipped by incrementing X5 inside an instruction.
The increment and skip if zero (ISZ) instruction had two parts. First the argument would be fetched, incremented and stored. Then the incremented result would be tested and the next instruction skipped if the result were zero.
ISZ FETCH X3,X4 SX4 X4+B1 BX4 X0*X4 STORE ,X4 NZ X4,INT1 SX5 X5+B1 BX5 X0*X5 EQ INT1
I loaded DEC's PAL assembler into my simulator and tried to use it without success. My simulator had a bug. It was as if there were a real PDP-8 with a bug and I had simulated it.
I borrowed the hardware diagnostics tape from a friend who maintained real PDP-8s for the university. When I ran this on my simulator the diagnostic identified a malfunctioning ISZ instruction.
It was right. I had coded the test of the incremented result backwards. Where I skip the skip if not zero (CDC NZ instruction) I had coded a jump on zero (CDC ZR instruction) by mistake. I'd been tripped up by the double-negative. To skip on zero I needed to jump on non-zero, thereby skipping the code that skipped.
I found my only bug. I was proud to have written something of this complexity while only making one mistake. I was also proud to have found it using software meant to test hardware, not my software.
I used this simulator to develop a Morse Transceiver application over a month with testing on real hardware once a week.