flat assembler
Message board for the users of flat assembler.

Index > Windows > Jump Variations ? near, far, relative, absolute,..........?

Author
Thread Post new topic Reply to topic
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 23 Sep 2010, 07:53
Quote:
Jump instruction — The JMP (jump) instruction unconditionally transfers program
control to a destination instruction. The transfer is one-way; that is, a return address
is not saved. A destination operand specifies the address (the instruction pointer) of
the destination instruction. The address can be a relative address or an absolute
address.
A relative address is a displacement (offset) with respect to the address in the EIP
register. The destination address (a near pointer) is formed by adding the displace-
ment to the address in the EIP register. The displacement is specified with a signed
integer, allowing jumps either forward or backward in the instruction stream.
An absolute address is a offset from address 0 of a segment. It can be specified in
either of the following ways:
• An address in a general-purpose register — This address is treated as a near
pointer, which is copied into the EIP register. Program execution then continues at
the new address within the current code segment.
• An address specified using the standard addressing modes of the
processor — Here, the address can be a near pointer or a far pointer. If the
address is for a near pointer, the address is translated into an offset and copied
into the EIP register. If the address is for a far pointer, the address is translated
into a segment selector (which is copied into the CS register) and an offset
(which is copied into the EIP register).
In protected mode, the JMP instruction also allows jumps to a call gate, a task gate,
and a task-state segment.

Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 1 - Basic Architecture, Page 222-223, 7-22

can anyone provide me some examples of those?
i only know "jmp label" and i dunno which one is it, is it relative address or absolute address?
also, can anyone just write a simple example for each type? the fact is i dunno their names.
Post 23 Sep 2010, 07:53
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 23 Sep 2010, 07:57
Post 23 Sep 2010, 07:57
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 23 Sep 2010, 09:24
Code:
A relative address = jmp ?????????
absolute address > An address in a general-purpose register  = jmp eax ;is that correct?
absolute address > An address specified using the standard addressing modes of the 
processor = jmp ???????
    


i was asking about the examples so i know which is which, i guess i mistyped the question
sorry but my native language isn't English
Post 23 Sep 2010, 09:24
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 23 Sep 2010, 12:58
"jmp label" is translated to jump to relative address (instruction pointer +- constant). You can also write this explicitly as "jmp $+5" where $ means address of current instruction.

jump to address in general purpose register is indeed "jmp eax"

jump to address specified using addressing: jmp [1234], jmp [eax], jmp [4*esi + ebx + 20]

All these are "near" jumps. Far jumps are not needed these days, only in system-level (ring0) programming.
Post 23 Sep 2010, 12:58
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Nameless



Joined: 30 Apr 2010
Posts: 95
Nameless 23 Sep 2010, 13:45
oh, kewl Very Happy
thanks Very Happy
Post 23 Sep 2010, 13:45
View user's profile Send private message Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 23 Sep 2010, 22:52
near direct jumps (mov eip,imm32)
near indirect jumps (mov eip,[modrm])
far direct jumps (mov cs,imm16, mov eip,imm32)
far indirect jump (lcs eip,[modrm])
condition jumps (if condition, add eip,imm32).


Note that near direct jumps are broken in 64bit mode.
Post 23 Sep 2010, 22:52
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 24 Sep 2010, 08:03
b1528932: those things in parentheses, what are they supposed to be? Some kind of pseudo-code?
Post 24 Sep 2010, 08:03
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.