flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > [fasmg] Far return in 64-bit mode missing REX.W

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4602
Location: vpcmpistri
bitRAKE 06 Sep 2026, 02:31
REX.W is required in long mode for 64-bit retf.
SDM Vol. 2B 4-560 wrote:
In 64-bit mode, the default operation size of this instruction is the stack-address size, i.e., 64 bits. This applies to near returns, not far returns; the default operation size of far returns is 32 bits.
... they hide that little detail down at the bottom.

... and AMD hides it somewhere else - it's not on the instruction page.


Last edited by bitRAKE on 06 Sep 2026, 07:54; edited 2 times in total
Post 06 Sep 2026, 02:31
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: 21091
Location: In your JS exploiting you and your system
revolution 06 Sep 2026, 05:26
Please add more detail. It shows this for 1.73.31
Code:
use64
retf
ret    
Code:
flat assembler  version 1.73.31  (16384 kilobytes memory)
1 passes, 3 bytes.
00000000  48CB              retfq  ; <--- REX.W is set
00000002  C3                ret    
Looks fine to me.
Post 06 Sep 2026, 05:26
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4602
Location: vpcmpistri
bitRAKE 06 Sep 2026, 07:51
Not in fasm2.

flat assembler version g.l8vn

iirc, the version is not updated for changes to x86-2.inc
Code:
iterate instr, retf,retfq
        calminstruction instr? operand
                check   x86.mode = 64
                jno     forward
                emit    1,48h
        forward:
                call    instr, operand
        end calminstruction
end iterate    
... work around is easy.
Post 06 Sep 2026, 07:51
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-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.