z80

package
v0.0.0-...-be83087 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

README

AoC on Z80

This directory is a step towards sufficient scaffolding to allow writing Advent of Code puzzle solutions in Z80 assembly. As of this writing, it is pretty incomplete, and only contains:

  • The z80ex package, which provides basic Cgo bindings to the z80ex Z80 emulator library.
  • The validate_test.go unit test that runs all existing solutions against the shared puzzle inputs and expected outputs.
  • The cmd/z80ex binary, which can use the library to run a Z80 program with I/O port 1 bound to the standard input/output streams, for manual testing.
  • Few Z80 utility routines for input and output of unsigned 16-bit and 32-bit integers.
  • Solutions for 2022-01 and 2023-01 in Z80 assembly, and //go:generate lines to assemble them.

Prerequisites for using this:

  • The z80ex library, installed so that its include file is available as <z80ex/z80ex.h> and the library available as -lz80ex in the library search path.
  • The z80asm assembler, and specifically a version including commit 320cce79, which fixes the "label defined" test expression (? foo). Notably, this is still broken in the version packaged in Debian.

The emulated Z80 machine model is as simple as it could possibly be. The machine has 64 kiB of RAM, filling the address space. The program is loaded at the beginning, and the stack pointer is set to make stack start growing from the top of the address space. Writing a byte into the I/O port 1 transmits it to standard output, while reading a byte reads it from standard input, returning 0 if at end of file. That is all.

If I end up writing more solutions, subsequent improvements could include:

  • A pure Go Z80 assembler. This would allow quality-of-life stuff like automated importing of library dependencies, and maybe even fancier stuff like inlining only-used-once routines.
  • A solution for debugging. The Visual Studio Code DeZog extension could be made to serve in this role, and its internal simulator should be capable enough for this, though some glue would be needed to support z80asm listing files. Alternatively, a homegrown TUI debugger might be an option.
  • Potentially some sort of extended memory system, but only if some puzzle problems turn out to really need more RAM than that.

Documentation

Overview

Package z80 is the parent package for all Z80-releated code.

At the moment there is no actual code directly in this package, but it holds the Go test that can be used to validate all the Z80 solutions.

Directories

Path Synopsis
Package y2022 contains Z80 solutions for AoC 2022.
Package y2022 contains Z80 solutions for AoC 2022.
Package y2023 contains Z80 solutions for AoC 2023.
Package y2023 contains Z80 solutions for AoC 2023.
cmd
z80run
Binary z80run executes an AoC Z80 program.
Binary z80run executes an AoC Z80 program.
Package z80ex contains Cgo bindings to the z80ex Z80 CPU emulation library.
Package z80ex contains Cgo bindings to the z80ex Z80 CPU emulation library.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL