Day 7: Z80 Assembly, CP/M & Failing at stuff

This’ll be a short post, and in fact, I’m writing it the following day.  Yesterday I beat my head against the wall failing  & flailing.  I got some things blinking, so.. yay, but kept getting all sorts of compiler errors, even when some things sort of worked.

I entered a simple routine out of a book, ‘CP/M Assembly Language Programming’ by Ken Barbier.  The routine simply takes a character typed in and echos it back to the console, using CP/M’s built-in routines. To use these routines, you place the function’s number on the C register, using MVI, and then call BDOS at location 0005h.  Then I tried adding an OUT command to place those same characters on the LEDs at Port 0.  It actually worked, but I got errors. And then I realized:  The compiler is expecting 8080 assembly only, and I was typing in Z80 assembly. The out command in particular, is quite different.

In 8080 Assembler, OUT ##h takes whatever is on Register A, and puts it on the specified port. That’s it. Whereas Out in Z80 has a lot more options (which I will explore soon).

This page has a comprehensive list of all of the instructions for the Z80 & 8080, and shows how their mnemonics and methods differ.

I’d rather learn Z80 assembly, so lets see if we can’t find a Z80 assembler for CP/M.

 

This entry was posted in Blinking Lights. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *