The Game Boy game "Tetris" leaves a transmission interval of about a millisecond between bytes sent over the serial link, as suggested by the official Game Boy Programming Manual, to give the other device the time to keep up with the data if it were to have an interrupt. It does that by simply busy looping 240 times, every iteration of that loop takes 4 cycles for a total of 960 cycles, which is close enough to a millisecond. The relevant code looks like this
ld b, 240
.loop
ld b, b
dec b
jr nz, .loop
My question is, why did they use an LD B, B
instruction, and not a proper NOP
? Functionally, they're identical, they take the same time and they both set no flags. Could this be a remnant from development, with the instruction having a trap or debug function on development kits?