#Z80 Machine Code, 88 6 bytes*
ww8><8ww<8ww8>
* Assumes certain conditions by entering from Amstrad BASIC
w LD (HL), A ## Saves A (0) to random memory location in (HL)
w LD (HL), A ## Saves A (0) to the same random memory location in (HL)
8> JR C, #3E ## C is initially unset, does nothing
< INC A // A=A+1
8w JR C, #77 ## C is unset unless A has overflowed, does nothing
w LD (HL), A // Saves A to the same random memory location in (HL (randomly initialised)
8> JR C, #3E ## C is still unset, does nothing
A
is initially 0 when entered from BASIC. It increments A
n times, then writes it n times to the same memory location (which is set to a slightly random location by BASIC)! The JR
Jump Relative operation never does anything since the C
flag is always unset, so is used to "comment out" the following byte! This version is slightly cheating by assuming certain entry conditions, namely entering from BASIC guarantees that A
is always 0 and the C
flag is unset. The location of (HL)
is not guaranteed to be safe, and in fact, is probably a dangerous location. The below code is much more robust which is why it's so much longer.