The JMP instruction
Jump to the instruction specified in the operand.
The JMP instruction format
| Instruction | Description |
|---|---|
| JMP rel8 | Short jump to the relative address rel8. |
| JMP rel16 | Short jump to the relative address rel16. |
| JMP reg/mem16 | Short jump to the value in a register or memory location. |
| JMP ptr16:16 | Far jump by the ptr16:16 pointer. |
| JMP mem16:16 | Far jump to the address in memory mem16:16. |
Transfers program control to a different point in the instruction stream without recording return information. The destination operand specifies the address of the instruction to which the jump is performed. This operand can be an immediate value, a general-purpose register or a memory location.
The instruction can be used to perform four different types of jumps: near (within the current code segment), short (near with a limited range), far (intersegment) and task switch.
Usage example
In this example the jmp instruction performs an unconditional jump to the Skip label. The instructions between jmp and the Skip label will not be executed.
title .model small .stack 100h code segment public ; Start of the code segment assume cs:code main proc ; Start of the main procedure mov ax, 1234h ; Copy the value 4660h into the ax register jmp Skip ; Perform an unconditional jump to the Skip label mov ax, 4321h ; Copy the value 4321h into the ax register (this instruction will be skipped) mov bx, 5678h ; Copy the value 5678h into the bx register (this instruction will be skipped) Skip: mov ax, 4C00h ; Copy the process termination function number into ah and the value into al int 21h ; Call the interrupt main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".