flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Tomasz Grysztar
There are no direct near jumps using absolute addressing in the Intel Architecture. Or did I misunderstood something?
|
|||
![]() |
|
CodeX
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. |
|||
![]() |
|
r22
You can always use a CALL instead of a jmp
call SomeLabel SomeLabel: add esp,4 ;; clean the stack from the call ... |
|||
![]() |
|
Tomasz Grysztar
CALL uses relative addressing the same as JMP.
|
|||
![]() |
|
r22
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 ? |
|||
![]() |
|
Tomasz Grysztar
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). |
|||
![]() |
|
Giant
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. |
|||
![]() |
|
Reverend
Code: push 012345678h
retn |
|||
![]() |
|
Giant
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. |
|||
![]() |
|
Madis731
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 ![]() |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.