flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > All that jumping

Author
Thread Post new topic Reply to topic
SeproMan



Joined: 11 Oct 2009
Posts: 70
Location: Belgium
SeproMan 07 Nov 2010, 14:43
The 3 instructions below all generate 3 bytes 66h,70h,xxh.
Is the operand size prefix not redundant?

Code:
use16
jo short dword myLabel
use32
jo short word myLabel
use64
jo short word myLabel
    


My second example generates 5 bytes 66h,0Fh,80h,xxh,xxh.
I wonder, should FASM even accept this instruction since Intel states that this encoding is Not Supported in 64-bit mode?

Code:
use64
jo near word myLabel
    


Perhaps someone could tell me more about this sentence I found in the "WHATSNEW.TXT" file.

Quote:

[-] The size operator applied to jump no longer applies to the size of relative displacement - now it applies to the size of target address.


Does "jump" mean just "jmp" or any kind of instruction that (potentially) performs a jump?
What exactly is "the size of target address"?

_________________
Real Address Mode.
Post 07 Nov 2010, 14:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 07 Nov 2010, 14:57
"size of target address" means the usage of either IP (16-bit), EIP (32-bit) or RIP (64-bit). The final size of the assembled jump instruction can still be short or long regardless of the size of (R|E)IP.
Post 07 Nov 2010, 14:57
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 07 Nov 2010, 15:27
Maybe this can help to clear it up:
Code:
      jmp     x               ;default is EIP in use32, short or near auto-selected
       jmp     short x         ;default is EIP in use32, one byte signed offset
    jmp     near x          ;default is EIP in use32, four byte signed offset

       jmp     dword x         ;force EIP, short or near auto-selected
     jmp     short dword x   ;force EIP, one byte signed offset
  jmp     near dword x    ;force EIP, four byte signed offset

     jmp     word x          ;force IP, short or near auto-selected
      jmp     short word x    ;force IP, one byte signed offset
   jmp     near word x     ;force IP, two byte signed offset    
Post 07 Nov 2010, 15:27
View user's profile Send private message Visit poster's website Reply with quote
SeproMan



Joined: 11 Oct 2009
Posts: 70
Location: Belgium
SeproMan 07 Nov 2010, 15:28
revolution,

It then depends solely on the use of the directive USE16/USE32/USE64
Does that mean that in the case of "jmp near" the addition of "WORD/DWORD/QWORD" is pointless?
Post 07 Nov 2010, 15:28
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 07 Nov 2010, 15:34
'word' and 'dword' overrides will control the generation of 0x66 prefix to change the target address size.

'near' and 'short' overrides will control the generation of 1 byte or 2/4 byte signed offsets.
Post 07 Nov 2010, 15:34
View user's profile Send private message Visit poster's website Reply with quote
SeproMan



Joined: 11 Oct 2009
Posts: 70
Location: Belgium
SeproMan 07 Nov 2010, 15:40
Thanks revolution.

Perhaps it would not have been so confusing for me, had Thomas not changed the behaviour of the size operator way back in 2006!
Post 07 Nov 2010, 15:40
View user's profile Send private message 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.