tags:

views:

68

answers:

3

Can someone explain in English what a relative jump is in assembler?

+5  A: 

It is an OP code whose operand will cause execution to jump to an relative to the current address. The value of the operand is an offset.

Say the relative jump is on address 0x0005, with an operand of 3 - execution will jump to address 0x0008. If the operand is -3, execution will jump to address 0x0002.

Oded
+2  A: 

A relative jump differs from an absolute or long jump in that the instruction does not encode the entire target address to where execution will continue.

Rather, it encodes a portion of the address or an offset from the current instruction pointer, depending on the architecture. This saves program memory space and in non-pipelined architectures it will also execute slightly faster. The limitation is that you can only jump shorter distances.

For current instruction relative jumps, the range is often a signed offset of the storage size used to encode the address. For example, if an 8-bit opcode and 8-bit offset is used, then the jump range would be typically -126 to +129 from the jump instruction. The asymmetry is due to the fact that the offset is added to the instruction pointer, which at the time of the addition points to the next instruction instead of the current one.

Amardeep
+1  A: 

Jump to address relative to (with respect to) the current address (address of this relative jump instruction).

You need to specify the "by how much?" part in the operand.

claws