flat assembler
Message board for the users of flat assembler.
Index
> Main > Jumps translation control |
Author |
|
Tomasz Grysztar 08 Feb 2006, 13:46
There are no direct near jumps using absolute addressing in the Intel Architecture. Or did I misunderstood something?
|
|||
08 Feb 2006, 13:46 |
|
CodeX 08 Feb 2006, 14:00
You're right, I need to refresh my knowledge of IA.
Thank you for giving such a quick answer You can remove a topic if you like to. |
|||
08 Feb 2006, 14:00 |
|
r22 08 Feb 2006, 20:21
You can always use a CALL instead of a jmp
call SomeLabel SomeLabel: add esp,4 ;; clean the stack from the call ... |
|||
08 Feb 2006, 20:21 |
|
Tomasz Grysztar 08 Feb 2006, 21:11
CALL uses relative addressing the same as JMP.
|
|||
08 Feb 2006, 21:11 |
|
r22 08 Feb 2006, 22:44
If I'm not mistaken a near Call has two encodings
Call RelOffset ; IP + Offset is encoded E8 ? Call Reg/addr ; IP = Reg/Addr is encoded FF ? |
|||
08 Feb 2006, 22:44 |
|
Tomasz Grysztar 08 Feb 2006, 22:57
These are direct and indirect call, same as there is direct and indirect jump.
The opcodes are: Code: JMP CALL Direct near E9 E8 Direct far EA 9A Indirect near FF /4 FF /2 Indirect far FF /5 FF /3 Near direct jumps are relative, far direct jumps are absolute. The symmetry between JMP and CALL is broken only by the direct short jump - the JMP instruction with 8-bit displacement (opcode EB). |
|||
08 Feb 2006, 22:57 |
|
Giant 11 Feb 2006, 01:11
The closest I've gotten to a direct jump is by using a temporary register. As in
mov eax,0x12345678 jmp eax It is pretty compact and fast, if I am not mistaken. |
|||
11 Feb 2006, 01:11 |
|
Reverend 11 Feb 2006, 11:16
Code: push 012345678h
retn |
|||
11 Feb 2006, 11:16 |
|
Giant 12 Feb 2006, 02:51
I would advise against push xxxxxxx retn combination.
Although I haven't tested it first hand, according to Intel, every call should be matched up with a return. Pentiums have a call/return branch prediction buffer, and returning to an arbitrary location flushes it, causing all kinds of performance problems. |
|||
12 Feb 2006, 02:51 |
|
Madis731 14 Mar 2006, 14:20
You are correct - the mov eax,location \ jmp eax is better because it can be predicted by that tiny knowledge the CPU has been given.
push modifies the esp and writes over any information at current esp offset. Return again changes esp. Neither of the sequences change flags so overall the mov variant is better. Although the push variant is ALWAYS shorter 1 to 3 bytes is you want that |
|||
14 Mar 2006, 14:20 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.