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
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.