flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > [solved] [Encoding problem] mov al, [42] |
Author |
|
Tomasz Grysztar 27 Jun 2019, 20:01
In the long mode fasm automatically generates RIP-based addressing by default, unless you enforce use of absolute addressing (see section 2.1.19 of the manual). Therefore the instruction that gets generated by
Code: mov al, [42] Code: mov al, [rip+36] Code: use64 org 100h mov al, [42] Code: use64 mov al, [rip-220] PS. The r/m field value 101b in the long mode does not have the same meaning as in the legacy mode. |
|||
27 Jun 2019, 20:01 |
|
gtasm 27 Jun 2019, 20:19
Of course, I took it for granted that the address was an absolute one!
I have to dig and learn more about this new (for me) RIP-relative addressing. Thank you very much for your precise, structured and very quick answer, Tomasz! Tom |
|||
27 Jun 2019, 20:19 |
|
gtasm 27 Jun 2019, 20:41
Ah, if I may, I notice that
Code: mov eax, [42] is not encoding using RIP-relative addressing, even if it is shorter than the SIB-based addressing. But there may be a technical reason for that (maybe a shorter latency with this kind of encoding of the instruction)... Tom |
|||
27 Jun 2019, 20:41 |
|
revolution 27 Jun 2019, 22:35
Instruction latency and throughput is not a consideration inside fasm. Each CPU and code stream is different so there isn't really a way for the assembler to know.
For your code above, which I assume is using 32 bit mode, there is no EIP addressing mode. RIP addressing is only possible in 64 bit mode. |
|||
27 Jun 2019, 22:35 |
|
gtasm 27 Jun 2019, 23:08
Thank you revolution,
It is valuable to know that latency has no impact on FASM output. I share your point of view. Please forgive me for two mistakes I made: - not giving the context of my code (prefixed by use64, as previously) - confusing the output of FASM and the one of NASM that I used to double check my results. Using FASM, the output of: Code: use64 mov eax, [42] is the shortest possible, RIP-relative addressing based: Code: 8B 05 24 00 00 00 Only NASM outputs the longer SIB and absolute addressing based output. Sorry for the confusion, and again, thank you both very much for the responsiveness and the quality of your answers. Tom |
|||
27 Jun 2019, 23:08 |
|
bitRAKE 20 Oct 2020, 08:38
Wasn't there some syntactical sugar to make fasmg generate absolute addressing?
Code: mov rax,[dword $7FFE0014] ; 48:8B 04 25 $7FFE0014 _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
20 Oct 2020, 08:38 |
|
bitRAKE 20 Oct 2020, 09:12
Code: include 'cpu/x64.inc' use64 mov rax,[dword $7FFE0014] Code: include 'format/format.inc' format MS64 COFF mov rax,[dword $7FFE0014] _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
20 Oct 2020, 09:12 |
|
Tomasz Grysztar 20 Oct 2020, 09:31
bitRAKE wrote: I can't seems to get around the @src.auto_relative feature of x86.parse_operand. What am I missing? Code: compute mode, pre shl 3 no_address_size_prefix: compute mode, 0 |
|||
20 Oct 2020, 09:31 |
|
bitRAKE 20 Oct 2020, 09:44
Awesome! I was staring right at that too.
(Time to get some sleep.) Thank you! _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
20 Oct 2020, 09:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.