flat assembler
Message board for the users of flat assembler.
Index
> Main > [fasmg] Adding member offsets in structured tables |
Author |
|
bitRAKE 02 Jun 2021, 05:25
Code: mov rbx, vkWin32SurfaceCreateInfoKHRRef add rbx, vkWin32SurfaceCreateInfoKHRRef.hInstance ; This line doesnt work Code: mov rbx, vkWin32SurfaceCreateInfoKHRRef.hInstance Should also note that if you do: Code: lea rbx,[vkWin32SurfaceCreateInfoKHRRef.hInstance] Edit: if you really wanted just the offset it would be: Code: _offset = vkWin32SurfaceCreateInfoKHRRef.hInstance - vkWin32SurfaceCreateInfoKHRRef _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
02 Jun 2021, 05:25 |
|
bitRAKE 02 Jun 2021, 16:14
Using static structures usually results in simpler code, for example setting the hInstance would be:
Code: push [hInstRef] pop [vkWin32SurfaceCreateInfoKHRRef.hInstance] (again, assuming data is within 32-bit signed range of instruction) In 64-bit, not only is there very little syntactical change, but in the local space code doesn't require relocation. (as long as we avoid immediate 64-bit moves, MOVABS in gas/intel syntax) fasmg does the [RIP - relative] work in the background. What we loose is the the ability to do complex immediate accesses (ex. mov rax,[MyStruct+rcx*8+rdx] doesn't work in general); without first loading the base pointer into a register (cont. ex. lea rax,[MyStruct];add rax,rdx;mov rax,[rcx*8+rdx] would be required to perform the same action allowed in 32-bit). |
|||
02 Jun 2021, 16:14 |
|
DimonSoft 03 Jun 2021, 17:04
<OffTop>Thought the question was related to FASM1 until I noticed the namespace stuff. Seems like it’s time to add clear separation at this forum </OffTop>
|
|||
03 Jun 2021, 17:04 |
|
donn 04 Jun 2021, 18:49
It works! Was going to followup on this, but completely slipped my mind, sorry.
Just tried now, and getting same results using the mov instead of add, makes complete sense. Lots of other useful info in these comments also, more techniques in the arsenal is liberating. Following along with Intel's API Without Secrets series, exploring Vulkan a bit, moving away from AMD APP Compute. Got the Swap Chain up, need to Acquire Images next I think.. Also see the title has fasmg in it now. Thought about that when typing originally, usually I mention that. |
|||
04 Jun 2021, 18:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.