JMP (x86 instruction)
Encyclopedia
In the x86 assembly language
X86 assembly language
x86 assembly language is a family of backward-compatible assembly languages, which provide some level of compatibility all the way back to the Intel 8008. x86 assembly languages are used to produce object code for the x86 class of processors, which includes Intel's Core series and AMD's Phenom and...

, the JMP instruction performs an unconditional jump. Such an instruction transfers the flow of execution
Execution (computers)
Execution in computer and software engineering is the process by which a computer or a virtual machine carries out the instructions of a computer program. The instructions in the program trigger sequences of simple actions on the executing machine...

 by changing the instruction pointer register. There are a number of different opcode
Opcode
In computer science engineering, an opcode is the portion of a machine language instruction that specifies the operation to be performed. Their specification and format are laid out in the instruction set architecture of the processor in question...

s that perform a jump; depending on whether the processor is in real mode
Real mode
Real mode, also called real address mode, is an operating mode of 80286 and later x86-compatible CPUs. Real mode is characterized by a 20 bit segmented memory address space and unlimited direct software access to all memory, I/O addresses and peripheral hardware...

 or protected mode
Protected mode
In computing, protected mode, also called protected virtual address mode, is an operational mode of x86-compatible central processing units...

, and an override instruction is used, the instructions may take 16-bit
16-bit
-16-bit architecture:The HP BPC, introduced in 1975, was the world's first 16-bit microprocessor. Prominent 16-bit processors include the PDP-11, Intel 8086, Intel 80286 and the WDC 65C816. The Intel 8088 was program-compatible with the Intel 8086, and was 16-bit in that its registers were 16...

, 32-bit
32-bit
The range of integer values that can be stored in 32 bits is 0 through 4,294,967,295. Hence, a processor with 32-bit memory addresses can directly access 4 GB of byte-addressable memory....

, or segment:offset pointers.

There are many different forms of jumps: relative, conditional, absolute and register-indirect jump
Indirect branch
An indirect branch is a type of program control instruction present in some machine language instruction sets. Rather than specifying the address of the next instruction to execute, as in a direct branch, the argument specifies where the address is located...

s.

JMP $ can be used to hang the computer. The $ is used to refer to the same location where the instruction starts. That means that the instruction will jump to itself and thereby creating an endless loop
Infinite loop
An infinite loop is a sequence of instructions in a computer program which loops endlessly, either due to the loop having no terminating condition, having one that can never be met, or one that causes the loop to start over...

.

The following examples illustrate:
  1. a relative jump with a 16-bit pointer;
  2. a long jump (inter-segment), a relative jump with a 32-bit pointer;
  3. and a register-indirect absolute jump using the EAX register.

(Note that although the first and second jumps are relative, commonly the destination address is shown instead of the relative offset as encoded in the opcode.)

Example one: Load IP with the new value 0x89AB, then load CS with 0xACDC and IP with 0x5578.

JMP 0x89AB
JMP 0xACDC:0x5578


Example two: Load IP with the value 0x56789AB1, only in protected mode or unreal mode
Unreal mode
In x86 computing, unreal mode, also big real mode, huge real mode, or flat real mode, is a variant of real mode , in which one or more data segment registers have been loaded with 32-bit addresses and limits. Contrary to its name, it is not a separate addressing mode that the x86-32 and x86-64...

.

JMP 0x56789AB1


Example three: Jump to the value stored in the EAX register, only in protected mode.

JMP EAX
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK