flat assembler
Message board for the users of flat assembler.
Index
> Main > FASM and NASM -- differences Goto page Previous 1, 2 |
Author |
|
rugxulo 26 Jan 2017, 00:41
Furs wrote: Oh yeah, I cringe everytime I do inline asm in GCC because I have to use it for compatibility. BinUtils' has supported ".intel_syntax" since GAS 2.10 (2000): "A new pseudo-op .intel_syntax has been implemented to allow gas to parse i386 assembly programs with intel syntax." Furs wrote:
GCC 3.0 (2001) added "-mintel-syntax" ... "to emit x86 assembly code using Intel style syntax". But I think newer ones prefer "-masm=intel" (e.g. GCC 6.3.0): "-masm=dialect" ... "Output assembly instructions using selected dialect. Also affects which dialect is used for basic asm and extended asm. Supported choices (in dialect order) are ‘att’ or ‘intel’. The default is ‘att’. Darwin does not support ‘intel’." |
|||
26 Jan 2017, 00:41 |
|
jorido 26 Jan 2017, 16:50
system error wrote: @jorido Macro in FASM doesn't really fit the definition of macros in NASM and / or MASM. FASM macros systems go beyond that. Then why not to use C# or C++ instead -- their level of abstruction goes even more futher |
|||
26 Jan 2017, 16:50 |
|
Furs 26 Jan 2017, 17:30
@rugxulo: Interesting, but wouldn't that conflict with inline asm made in AT&T syntax in other places? Or does the directive apply only within the current inline asm block? I'll check later when I can anyway.
jorido wrote: Then why not to use C# or C++ instead -- their level of abstruction goes even more futher Try create a data file with C++ macros or whatever you want, with no code even (without executing the program). With FASM you can even create your own "executable format" and it's simple with a few macros. For example if you use on-demand loadable code (like scripts), you'll likely prefer a custom tailored format than the bloated normal ones which assume a default executable. |
|||
26 Jan 2017, 17:30 |
|
system error 26 Jan 2017, 19:54
jorido wrote:
@jorido Well, if such the case, then there's no point in using NASM in the first place. C++ wins over NASM in terms of abstractions, hands down. C++ has macros too, right? So why bother using NASM's macros, again? Macro is not just a tool for abstraction. In FASM it's also used as a tool of expression used by machine language compiler enthusiasts. The inventors of C/C++ also used these tools when crafting their compilers. Lookup semantic analysis, lexer, parsers, tokenizers, finite-state machines, scanner etc. This is part of FASM 'culture' and this culture is being nurtured using complex FASM macro languages and systems like FASMG. Examples: Using FASM's macro to parse Zilog Z80 instruction sets. Emulating ARM architecture via FASM's macro languages. Using FASM macro systems to emulate AVR instructions architecture There are lots more if you look hard enough. I am not against NASM. It's a good assembler. Lots of references. But it's a x86 only assembler. It will be extremely painful to emulate any other incompatible architecture using its macro systems. So comparing NASM to FASM in such naive x86-way is semantically invalid, null and void because ARM and Zilog programmers use FASM too! If you can stay longer, maybe, just maybe I can grant you special lifetime membership of this board for free. That comes with free copy of FASM manual too, bro! |
|||
26 Jan 2017, 19:54 |
|
alexfru 23 Feb 2017, 11:54
I chose NASM long time ago when FASM either didn't exist yet or was in its infancy. I could use NASM for several different things (system code, DOS apps) and with several compilers (16-bit Borland Pascal and C; DJGPP).
FASM is great, but my C compiler needs some things only NASM and YASM provide out of the box (e.g. section fragment combining, 16-bit relocations in ELF files). I need to either preprocess the generated code specially for FASM or use some other hacks. I have a small tool to combine section fragments for FASM and perform conversion of the most basic assembler directives from NASM syntax to FASM syntax, which lets me use FASM for generating 32-bit protected mode executables (DOS/DPMI, Windows, Linux) just as with NASM/YASM. But for non-DPMI DOS executables I have to use NASM or YASM. One thing NASM is bad at is optimizing jumps (choosing shortest possible jump instructions). When given a large file with several thousands of jumps it assembles pathetically slow. YASM and FASM handle this better. |
|||
23 Feb 2017, 11:54 |
|
revolution 23 Feb 2017, 12:10
I think you are conflating assembling and linking.
Both fasm and NASM can generate object files (i.e. linkable files), with all the benefits of section coalescing and whatnot, via the use of an external linker. But, AFAIAA, only fasm can generate executable files directly from assembly source, without any linker required. These files do not support any section gymnastics. But you don't have to use this mode of output if it doesn't work nicely with your HLL compiler. Although, note that it is relatively easy to add macros to the source to allow section combining and executable generation in one step, no linker required. |
|||
23 Feb 2017, 12:10 |
|
alexfru 23 Feb 2017, 12:42
revolution wrote: I think you are conflating assembling and linking. I'm not sure about it. revolution wrote: Both fasm and NASM can generate object files (i.e. linkable files), with all the benefits of section coalescing and whatnot, via the use of an external linker. I have posted about this problem before. FASM's output with repeating sections within the same ELF object file is problematic to link (see that other thread). revolution wrote: But, AFAIAA, only fasm can generate executable files directly from assembly source, without any linker required. With a little bit of additional assembly code for the executable headers I can do the same with NASM. But it's irrelevant since I'm actually linking multiple object files and am not trying to make executables directly from assembly code. revolution wrote: These files do not support any section gymnastics. But you don't have to use this mode of output if it doesn't work nicely with your HLL compiler. And I don't. But like I said, it's irrelevant. revolution wrote: Although, note that it is relatively easy to add macros to the source to allow section combining and executable generation in one step, no linker required. I looked at some options, but ended up just writing a conversion tool. It's good enough for now. If/when it stops being good enough, I may revisit the issue. |
|||
23 Feb 2017, 12:42 |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.