flat assembler
Message board for the users of flat assembler.

Index > Main > [fasmg] C preprocessor and gas compatibility

Author
Thread Post new topic Reply to topic
sylware



Joined: 23 Oct 2020
Posts: 231
Location: Marseille/France
sylware 18 Jun 2022, 12:07
Hi,

I am about to write some x86_64 code again, but I am wondering how much fasmg (x86_64) assembler code is friendly to a C preprocessor. As far I as understand it, fasmg tokens should be ok with C preprocessor tokens.

Am I wrong? Or is there some obvious pitfalls experienced fasmg coders see which I don't.

This assembly code will very probably share some definitions with some C code.

Additionnaly, I may try to write the code in a way I could assemble it with binutils GAS *and* fasmg. Is this reasonable? I may do some "sed"-ing on the source file in order to "include" some "assembler abstraction layer" (trying to keep that minimal).
Post 18 Jun 2022, 12:07
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8106
Location: Kraków, Poland
Tomasz Grysztar 18 Jun 2022, 18:46
sylware wrote:
Am I wrong? Or is there some obvious pitfalls experienced fasmg coders see which I don't.
One pitfall that I know of is that quoted string tokens are interpreted differently by C vs fasmg. For example "\"" is a valid token for C, but error for fasmg, which requires """" syntax instead (legacy of assemblers like TASM).

I've been considering adding a switch (similar to RETAINCOMMENTS/ISOLATELINES directives) to support C-style quoted strings, but that would require a substantial refactoring of the tokenizer and its data structures, so I postponed it indefinitely.
Post 18 Jun 2022, 18:46
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: 19118
Location: In your JS exploiting you and your system
revolution 19 Jun 2022, 07:16
Since sed is on the table then pre-parse the source.
Code:
echo '"Hello \"world!\""' | sed 's|\\"|""|g'    
Post 19 Jun 2022, 07:16
View user's profile Send private message Visit poster's website Reply with quote
sylware



Joined: 23 Oct 2020
Posts: 231
Location: Marseille/France
sylware 19 Jun 2022, 15:37
Allright, I may give it a try, keeping in mind a sed pre-preprocessing may be required.
Post 19 Jun 2022, 15:37
View user's profile Send private message 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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.