flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Custom FASM or FASMdllmod modification help needed.

Author
Thread Post new topic Reply to topic
andurilan



Joined: 09 Nov 2021
Posts: 3
andurilan 09 Nov 2021, 01:17
Hello,
This is my first post here, though I have read it for years.

I want to make a front end language that uses fasm as a backend compiler.
I have been trying to make a few modifications to the fasm source or fasmdllmod.
( for dll and x64 fasm support )

What I have been trying to achieve using x64dbg or ida debugging is this:
Code:
;
; some file.fasm
;
;   The current way to define a macro
macro some_other_macro a, b
{
    ;  ... Some Implementation that uses a and b
}

some_other_macro 1, 2
;
;   The custom way I want to define a macro

macro some_macro( a, b )
{
    ;  ... Some Implementation that uses a and b
}
some_macro( 3, 4 )
;
;   ... Irrelevant format declarations
;
entry start
start:
; ... Some other instructions
some_macro( rsi, rdi )  ; ... Note the use of enclosing parenthesises here
;
; ... Also allow for fasm directives to use of parenthesises
; Though this is not as important if I were able to correctly mod
; fasm to allow for defining and invoking macros using parenth's
db( "Hello, Operator.", Ah, 0h )
    


Is there any advice anyone would be able to provide of
what to change in fasm's preprocessor and assembly functions?

I have made a few attempts at customizing
process_line and assemble_line to recognize
"(" or 28h and ")" or 29h, and have tracked down the
errors using breakpoints, but i cant seem to find out
where the error floats from once it finds a builtin directive.

Any help would be greatly appreciated, as this would allow
my language to have native fasm support from the ground floor.

AA

_________________
AA
Post 09 Nov 2021, 01:17
View user's profile Send private message Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1040
Location: Russia
macomics 09 Nov 2021, 04:05
For exam,
Code:
macro some_macro_arg a, b { add a, b }

macro some_macro args& { local .f
  define .f OK
  match =(a=),args \{ restore .f
    some_macro_arg a \}
  match =OK, .f \{ restore .f
    some_macro_arg args \} }

some_macro ( [rbp], ax )
some_macro (  rsi, rdi  )
some_macro rax, [rbx]
some_macro cl,byte [r8+65536]

struc db args& { local .f
 define .f OK
 match =(a=),args \{ restore .f
        \. db a \}
 match =OK, .f \{ restore .f
        \. db args \} }

a db( "Hello, Operator.", 0Ah, 0h )
b db "Hello, Operator.", 0Ah, 0h    
something like that?
Post 09 Nov 2021, 04:05
View user's profile Send private message Reply with quote
nasm



Joined: 02 Nov 2021
Posts: 183
nasm 09 Nov 2021, 12:34
Advanced text substitution.
Post 09 Nov 2021, 12:34
View user's profile Send private message Reply with quote
andurilan



Joined: 09 Nov 2021
Posts: 3
andurilan 09 Nov 2021, 12:50
@macomics, TY, I will try this, but I was hoping to edit the source directly, in particular PREPROCESSOR.NIC and ASSEMBLER.INC . I'll report back later to see if this works for me.

@nasm, Yes, I already have a fasm preprocesor written in rust to take the file and remove certain characters to make it fasm compilable.

I was just hoping to do it directly in fasm's source files, as it is way less work than adding a third step to compilation of my frontend compiler.
Post 09 Nov 2021, 12:50
View user's profile Send private message Reply with quote
nasm



Joined: 02 Nov 2021
Posts: 183
nasm 09 Nov 2021, 13:05
You could use fasm's internal text substitution engine or you could use the one that comes with notepad++, it's a more powerful text substitution engine than the one inside fasm. Fasm's text substitution engine will give you a mile long source and it does minimal in practice, it's the opposite with notepad++'s text substitution, it will give you a lot of result from minimal source, it's very compact. People who have studied text substitution for decades disagree which of them are the most powerful.

_________________
Do you think anyone will sell their soul over a 10 cent yoghurt with a bad after taste that lasts, a decade?
Post 09 Nov 2021, 13:05
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.