Close

Setting HL to a defined value

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 02/01/2024 at 07:260 Comments

Since HL is undefined on power on, it is necessary to fill RAM with a sequence of instructions that will set it to a known value, regardless of where in that sequence of instructions execution begins.

One way is to fill RAM with 21h, so that LD HL,2121h gets executed again and again.

Another way is to fill RAM with DEC HL, with a single HALT somewhere in RAM being the last byte written using the bootstrapping scheme. HL points to the address following HALT. When execution starts HL will be decremented until HALT is reached. This means that whereever the HALT instruction is in RAM, HL will have the value 0001h by the time HALT is executed. I prefer this to the LD HL,2121h idea, because the Z80 has a pin indicating the HALT state, which will give some indication that bootstrapping is working correctly.

Discussions