7

(avery) #1

Getting retro with the Z80: software


TUTORIAL


Dive into Z80 assembly language


Getting retro with the Z80:


software


ast month, we built a Z80 computer
on a breadboard. This month, we’re
going to take a look at how to program
it using assembly language. Assembly
language is a symbolic version of
machine code. It uses names for the
instructions, registers, condition flags, etc. It also
allows you to label addresses in the code or data
and refer to the labels in the code rather than the
numeric addresses. The idea behind assembly
language is to provide a one-to-one mapping to
machine code, while being far more readable and
writable than a series of bytes.

TEMPORARY STORAGE
Every CPU has registers to store values that can
then be operated upon. The Z80 has a fairly rich
set of registers for an 8-bit CPU. It has an 8-bit
accumulator (called A), as well as six other general
purpose 8-bit registers: B, C, D, E, H, and L. These
six have the added utility that they can be used
in pairs (BC, DE, and HL) as 16-bit registers. That
allows working directly with addresses inside the
CPU in a very flexible and powerful way. Two other
important registers are the 16-bit index registers, IX
and IY. These let us do powerful array and structure
type operations very easily. We won’t be using them

L


YOU’LL NEED
z80pack
hsmag.cc/sWCRQK

Dave Astels
@dastels

Dave’s career started
in the 8-bit days, with
the Z80 and 6502, and
he’s been working with
computers ever since.
He does some writing
at daveastels.com and
learn.adafruit.com.


Above
You can build your
own system or
get a kit such as
this RC2014
Free download pdf