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:
- The values of A and HL are undefined when the Z80 resets. How can they be initialised?
- How can a signal be used to suppress INC L?
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.