Close

A promising instruction sequence

A project log for Bootstrapping a ROMless Z80 using RS-232

Is it possible to bootstrap a simple ROMless Z80 system using only two wires - e.g. from an RS232 interface? This project explores this.

willstevenswill.stevens 01/10/2024 at 21:380 Comments

Consider this sequence of instructions:


DEC A

INC L

LD (HL),A

HALT


The binary codes for these are:

00111101
00101100
01110111
01110110

And the bits D7..D0 in this sequence  can be expressed as simple functions of the address bits:

D7=A2

D6=A1

D5=1

D4=A1 or /A0

D3=/A1

D2=1

D1=A1

D0=/A0


The consequence of running this are that the following sequence gets executed repeatedly (assuming that NMI and consequent jump to 66h occur after HALT is executed)

DEC A

INC L

LD (HL),A

HALT

RST 30h


This sequence fills 256 bytes of memory with a decreasing sequence of bytes (and also pushes values onto the stack when NMI occurs and when RST 30h is executed).


If the INC L instruction could be suppressed somehow during selected iterations of this sequence, then any desired sequence of bytes could be written to a block of 256 bytes of RAM.

There are a couple of questions to answer before this can be used as a bootstrap mechanism:

Discussions