flat assembler
Message board for the users of flat assembler.
Index
> Non-x86 architectures > fasmg: Mix arm64 with x86 |
Author |
|
Tomasz Grysztar 29 Nov 2022, 18:50
Yes, it's possible with help of namespace separation:
Code: include 'win32ax.inc' define ARM64 namespace ARM64 include 'cpu/aarch64.inc' end namespace .code ; --------------------------- ; This function is in x86 ; --------------------------- MyFunction: mov eax, 1 ret namespace ARM64 ; --------------------------- ; This function is in ARM64 ; --------------------------- MyFunction: ret end namespace ; Back to x86. Here access the function as ARM64.MyFunction start: invoke ExitProcess,0 .end start For a clean solution, you could make it a strong isolation: Code: ; In the main namespace, define only PE format structures, with no specific CPU instructions: PE.Settings.Characteristics = IMAGE_FILE_EXECUTABLE_IMAGE or IMAGE_FILE_32BIT_MACHINE or IMAGE_FILE_LINE_NUMS_STRIPPED or IMAGE_FILE_LOCAL_SYMS_STRIPPED PE.Settings.Subsystem = IMAGE_SUBSYSTEM_WINDOWS_GUI format binary as 'exe' include 'format/pe.inc' ; When PE.INC was included manually, WIN32AX.INC does not do it itself: include 'win32ax.inc' ; Define global anchors for the namespaces: define X86 define ARM64 ; Put instruction sets into separated namespaces. Now they cannot interfere with each other. namespace X86 include 'cpu/80386.inc' use32 end namespace namespace ARM64 include 'cpu/aarch64.inc' end namespace .code namespace X86 ; --------------------------- ; This function is in x86 ; --------------------------- MyFunction: mov eax, 1 ret end namespace namespace ARM64 ; --------------------------- ; This function is in ARM64 ; --------------------------- MyFunction: ret end namespace namespace X86 start: invoke ExitProcess,0 end namespace .end X86.start To confirm correctness you can include 'listing.inc' (put it after the ".code" line to avoid processing all the headers). I got: Code: [0000000000401000] namespace X86 [0000000000401000] MyFunction: [0000000000401000] 00000200: B8 01 00 00 00 mov eax, 1 [0000000000401005] 00000205: C3 ret [0000000000401006] namespace ARM64 [0000000000401006] MyFunction: [0000000000401006] 00000206: C0 03 5F D6 ret [000000000040100A] namespace X86 [000000000040100A] start: [000000000040100A] 0000020A: 6A 00 FF 15 40 20 40 00 invoke ExitProcess,0 |
|||
29 Nov 2022, 18:50 |
|
alorent 30 Nov 2022, 04:35
Hi Tomasz,
Thanks a lot! Amazing! I never saw a more robust and flexible software in my life! I have done a quick test and it works perfectly! Thanks again! |
|||
30 Nov 2022, 04:35 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.