flat assembler
Message board for the users of flat assembler.

Index > Main > Disable automatic RIP-relative addressing

Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 03 May 2024, 09:07
I made a tiny update to the fasm2 package, exposing an option that was normally hidden under the hood of fasm encoders. You can now choose disable or enforce the automatic RIP-relative addressing in long mode, either for individual instructions:
Code:
        add     rax,[var]       ; by default RIP-relative
        add     rax,[fs:var]    ; by default absolute
{norip} add     rax,[var]       ; absolute
{rip}   add     rax,[fs:var]    ; RIP-relative    
Or you can disable automatic RIP-relative addressing for an entire range of code:
Code:
        use     norip    
To get back the default behavior, do:
Code:
        use     ripauto    

The instruction decorators and USE command remain undocumented except for a couple of examples in the old prototype. If you need a list of available options, you can find them in the encoder source (x86-2.inc).
Post 03 May 2024, 09:07
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 05 May 2024, 21:55
why don't
Code:
add rax,rip[fs:var]
add rax,abs[var]
    

as if it was size operator like dword, word, byte?

{decorator} would induce a lot of bloat and confusion in code as long as it will get more and more features
Post 05 May 2024, 21:55
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 798
Location: Russian Federation, Sochi
ProMiNick 05 May 2024, 22:28
I guess because RIP addressing isn`t size.
And by fasm2 design place for instruction modifiers is in {}.
[rest not related to RIP addressing - deleted]
Post 05 May 2024, 22:28
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 06 May 2024, 02:52
edfed wrote:
as if it was size operator like dword, word, byte?
There are two ways to view it. As an instruction modifier, or as an address modifier.

If you view it as an address modifier (or address specifier) then it could go inside the bracket, the same place the size operator goes.
Code:
mov rax,[abs address]
mov rax,[rel address]    
And if relative addressing is ever extended to EIP and/or IP then this can be combined together.
Code:
mov rax,[abs dword address]
mov rax,[rel word address]    
I think abs/rel is more descriptive of the actual intent. Using {rip}/{norip} is more typing and more abstract.
Post 06 May 2024, 02:52
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 06 May 2024, 08:01
edfed wrote:
why don't
Code:
add rax,rip[fs:var]
add rax,abs[var]
    

as if it was size operator like dword, word, byte?

{decorator} would induce a lot of bloat and confusion in code as long as it will get more and more features
The main new feature here is the ability to switch the encoder option for an entire block of source:
Code:
use norip    
This way you can change the encoding rules for existing code, while keeping the text unmodified and semantically pure. The decorator syntax is just a shortcut that allows to apply some of the new USE settings to a single instruction.

Interestingly, Intel proposed a syntax identical to fasm2 decorators for signalling prefix choices of the new APX instructions. Must have been convergent evolution (see the evolution of fasm2 decorators in the old thread about advanced x86 encoder).
Post 06 May 2024, 08:01
View user's profile Send private message Visit poster's website 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.