It's not the assembler

A project log for Z80 Computer

An attempt to build a Z80 computer capable of running CP/M

techavtechav 06/01/2015 at 05:140 Comments

It never fails. If you get to the point where you start to suspect the Assembler/Compiler/Automated-tool-built-by-someone-much-smarter-than-you is what isn't working, then humility is sure to follow.

I salvaged a Zilog 8530 SCC (UART) from an old motherboard, wired it in, and threw together a quick assembly program to initialise and test it. It didn't work. For debugging, and so I could know if my code was at least getting past the initialisation, I added an LED to a register I have tied to address $F0 on the IO bus (something I know worked before). It didn't work.

I have a '154 4-to-16 decoder I'm using for peripheral select. The Z80 OUT instruction will output an address on the low byte of the address bus. I'm using the high nybble (A4-A7) of this address to provide chip select lines for up to 16 peripherals, with the low nybble (A0-A3) available for the device (e.g. A/B select on the SCC).

Probing around the '154 to figure out why not even the LED would light, nothing was working as expected. Output 15 was never enabled, 0 only blipped, 3, blipped, and 1 was all over the place. It almost seemed like an endian mixup, but surely the assembler wouldn't mix up something like that.

No, of course it wasn't the assembler. I had wired the '154 to A0-A3, instead of A4-A7. It didn't show up before, because I had always used $FF or $00 as the output address. Now that I'm to the point of using $F0 for the register, and $00-$03 for the SCC, it's a significant problem.

In my defense, thanks to allergy medication, I'm surprised I know which way is up. Cursed Spring.