Z80 Assemblers on Mac

Tonight’s 8-bit activity involves building a Z80 assembler on the Mac. I found an assembler called Z80-ASM on a page at the University of Bielefeld. The problem is it doesn’t compile. I found a newer project at GNU, but I can’t get it to compile. To start I need to Autoconf, Automake and all that jazz. Maybe another day.

I did several things to get the assembler to compile (on Mac OS X/Catalina/Intel):

  1. Use GCC instead of the Xcode compiler. GCC can be installed easily using Homebrew. Two of the Makefiles need editing to set the path.
  2. One of the CPU pin names duplicates a definition. I renamed it.
  3. Fixed the path to the manual pages
  4. Inserted an error function into lcd-display

I’m still testing this, but the test suite of programs build… mostly. I built each one with z80-asm and compared with what is provided in the source code.

chris@YeOldeComputer% sh test.sh
 clock.asm
 MD5 (clock.z80) = a9ed9d5409fc1e925a650c7217e50992
 MD5 (out) = a9ed9d5409fc1e925a650c7217e50992
 example.asm
 MD5 (example.z80) = 12880569a1cbbd17069fb4ce303e86d3
 MD5 (out) = 12880569a1cbbd17069fb4ce303e86d3
 multi.asm
 MD5 (multi.z80) = 382cd8d72fef5d57dfb9d3e0153b161e
 MD5 (out) = 382cd8d72fef5d57dfb9d3e0153b161e
 timer.asm
 MD5 (timer.z80) = 488d14f31c29038f89c99fd9f9bf9a49
 MD5 (out) = 488d14f31c29038f89c99fd9f9bf9a49
 lcd_test.asm
 MD5 (lcd_test.z80) = b68d1296e19934a442ac074d215f22b2
 MD5 (out) = b68d1296e19934a442ac074d215f22b2

The tests divi, ti86_link2 and wait_tics are not correct. The first two don’t build properly (see below). The wait_tics file builds differently – I think it is due to labels having different values, but more testing is required.

chris@YeOldeComputer% z80-asm divi.asm 
             JP (IX)
 line 475: Invalid argument.
 No code generated
 chris@YeOldeComputer% z80-asm ti86_link2.asm 
     cp %00000010        ;check bit 1  (the White wire)
 line 45: Missing Operand.
 No code generated

The source code can be downloaded from the website and here is my patch. Or alternatively I’m tinkering on Github. Binaries for Catalina/Intel are here (N.B. the directory says Big Sur – I was tired. They do run on Big Sur as well, but you will need verify them on Big Sur. Use at your own risk.)

Z80-ASM is available under the GNU public license v2. The pictures of the Z80 is used under a CC license and are sourced from Wikipedia.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.