MAGIC and DNS still wrong

Juergen Buchmueller pullmoll at t-online.de
Wed Jun 27 14:14:04 PDT 2007


After hunting high and low for the reason why after booting the emulation
wouldn't continue, but jump to 0 or just hang in an endless loop, I finally
took a close look at the Emulator MAGIC and DNS section.

Here's how I now think it works (best):

The CPU F1s "<-L LSH 1", "<-L RSH 1" and also "<-L LCY 8" do what they're
supposed to do. They don't care about the F2, yet. The _only_ difference is
that the bit that is shifted in as 0 with the normal shifts (it is called XC
in the schematics) will be different for the F2s MAGIC and DNS.

MAGIC handles just two cases:
	switch (f1) {
	case f1_l_lsh_1: /* <-L MLSH 1 */
		shifter |= t >> 15;
		break;
	case f1_l_rsh_1: /* <-L MRSH 1 */
		shifter |= (t & 1) << 15;
		break;
	}
MAGIC has nothing to do with the carrys ALUC0 or LALUC0, and neither the
emulator carry, as far as I can tell, so that's really all it has to do.

DNS is a little more complicated. First it determines the new carry source
like this:
	int cy;

	switch (ir[10-11]) { /* i.e. the CY field of IR */
	case 1: /* zero carry */
		cy = 0;
		break;
	case 2: /* one carry */
		cy = 1;
		break;
	case 3: /* complemented emu carry */
		cy = emu_cy ^ 1;
		break;
	default: /* emu carry */
		cy = emu_cy;
		break;
	}

Now it XORs this carry with the latched ALU carry (LALUC0), that is the
"shifter carry".

	cy ^= latched_aluc0;

And now comes the important difference to how you implemented it before,
and how I blatantly copied it including the bug ;-)

	switch (f1) {
	case f1_l_lsh_1: /* <-L LSH 1 */
		cy = l >> 15;
		shifter |= cy;
		break;
	case f1_l_rsh_1: /* <-L MRSH 1 */
		cy = l & 1;
		shifter |= cy << 15;
		break;
	}

In other words: the F1s shifts make the logic use bit 0 or 15 of L, and
not the (already computed) cy! You can clearly see this in the 08_ALU.pdf
schematics, where NEWCARRY is either XC, or the LSB or MSB of L, depending
on the signals SH1 and SH2, which are the decoded shift mode from the
microinstruction's F1.

Now DNS continues to test IR[12], the no-load bit, and if it is zero sets
emu_cy = cy and also writes the R register from the shifter.

Finally the SKIP is computed depending on IR[13-14], the complemented
NEWCARRY (i.e. cy == 0), and the shifter being zero.

With this change it looks like the code that was bootstrapped from the disk
drive is actually running. No pictures yet, though.


More information about the Altogether-devel mailing list