The following two instruction sequences differ by only a single bit in the first instruction:
00110110 LD (HL),n 00100011 23h 01110110 HALT 00110100 INC (HL) 00100011 INC HL 01110110 HALT
Each bit except D1 is either 0,1,A0,A1,/A0
D1 = A0 or A1 or RTS
By executing sequence 1 and sequence 2 alternately, the whole of memory can be filled with a constant value (24h)
By executing sequence 2 alone over and over again, the whole of memory can be incremented by one.
By mixing sequence 1 and sequence 2 we can keep some locations fixed at 24h and increment others.
A procedure to fill RAM with any desired contents (but offset by an unknown address) is to start by alternating sequence 1 and sequence 2 then on each sweep through memory we can omit some sequence 1s to ‘release’ bytes which had been held at 24h, so that they start incrementing.
The issue of unknown offset can be resolved by first filling RAM with a single LD HL,nn and setting all other bytes to a harmless opcode. Then execute the contents of RAM. Then run the procedure again, this time with a known offset.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.