JMP ( Unconditional Jump ) Instruction: This instruction is used to transfer the execution to the specified memory address unconditionally ( does not check any condition before jump). It is normally used to create an indefinite loop. The instruction format is
JMP 16 bit memory address
Actually it copies the specified memory address into the program counter register. Hence the microprocessor reads the next instruction from the address stored in the program counter. Now as usual the contains of the program counter register starts incrementing by one. Program executes sequentially until it encounters any other branch instruction.
See followings example to understand the working of JMP instruction.
Note: You must have noticed that Sex codes of IN and OUT instruction are written at two consecutive memory locations and Hex codes of JMP instruction are written at three consecutive memory locations. Without going into the details of the Hex codes and size of the instruction at this moment ( which will be discussed later in this chapter) let us concentrate on the working of the JMP instruction.
In the above program the instruction JMP 20502H will transfer the execution back to the first instruction which is stored at 2050H and keep on repeating the task by creating an indefinite loop.
The above program may be written as shown below using labels when written using assembler. In laboratory using microprocessor kit one has to the hex codes( programming techniques will be explained in detail in chapter4).
The label represent the memory address of the instruction written along with it. In the above program the label START represents the memory address 2050H where IN instruction is stored. It is referred by JMP instruction written at memory location 2054H.