of the normal indexed instructions, without having to resort to the documented or . There are several other undocumented instructions as well. Undocumented or illegal opcodes are not detected by the Z80 and have various effects, some of which are useful. However, as they are not part of the formal definition of the instruction set, different implementations of the Z80 are not guaranteed (or especially likely) to work the same way for every undocumented opcode. Bugs The instruction does not conform to the Z80 documentation. Both the and instructions are supposed to leave the carry (C) flag unmodified. The instruction operates correctly; however, during the execution of the instruction, the carry flag takes the results of a spurious compare between the accumulator (A) and the last output of the instruction. Example code EXAMPLE 1: The following Z80 assembler source code is for a subroutine named HELLO_WORLD. This is an introductory program which will print a message to the video display and then exit. Though simple, it demonstrates how an assembler source code is formatted and interacts with the display hardware through a computer operating system. This is necessarily specific to a particular computer hardware, operating system and assembler software. The example used is the TRS-80 Model 4 running TRSDOS/LS-DOS 6.x, produced by Tandy/Radio Shack and Logical Systems, with most any assembler sold by Radio Shack or Misosys Inc. (Series I/EDTASM, ALDS, EDAS or MRAS with -GC switch). The principal features of this configuration are universal to Z80 assemblers, even under CP/M. EXAMPLE 2: The following Z80 assembly source code is for a subroutine named memcpy that copies a block of data bytes of a given size from one location to another. Important: the example code does not handle the case where the destination block overlaps the source; a serious limitation, but one that is irrelevant for some applications—such as, especially, when the source is in ROM and the destination in RAM, so they can never overlap. The sample code is extremely inefficient, intended to illustrate various instruction types, rather than best practices for speed. The data block is copied one byte at a time, and the data movement and looping logic utilizes 16-bit operations. Furthermore, the Z80 has a single instruction that will execute the entire loop (LDIR). Note that the assembled code is binary-compatible with the Intel 8080 and 8085 CPUs. Instruction execution Each instruction is executed in steps