flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [SOLVED] Could be localptr & alterencoding combined together

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 30 Sep 2018, 21:00
Code:
start: 30.09.2018 23:53:22,70
source file: C:\Fasm2\SOURCE_G\DLL\fasmg.dll.asm
flat assembler  version g.ialrk
C:\Fasm2\SOURCE_G\DLL\fasmg.dll.asm [39] C:\Fasm2\SOURCE_G\DLL\../assembler.inc [96]:
        mov edi,characters
macro ? [10] macro mov [121] macro dd [13] macro dword [9]:
        dd v
Processed: dd v
Error: variable term used where not expected.
finish: 30.09.2018 23:53:55,92    


invoke altering(from localptr) was succrsfull, but what to do with mov?

from error I can see that it caused
in mov edi,characters
when
Code:
macro ? line&
        match {decorator} instruction, line
                macro ? any&
                        purge ?
                        x86.settings =: x86.settings
                        use decorator
                        instruction
                        restore x86.settings
                end macro
        end match
        outscope line
end macro    

operate on it
then should be operated
Code:
macro mov? dest*,src*
        match size [mem], ?src
                mov dest,src
        else if src relativeto ebp & src - ebp
                lea dest,[src]
        else
                mov dest,src
        end if
end macro     

Why "macro dd [13] macro dword [9]" is araised


Description: only chanded format macro
and keyword formad moved up in main source

Download
Filename: Fasm2.zip
Filesize: 402.97 KB
Downloaded: 638 Time(s)


_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 01 Oct 2018, 10:23; edited 2 times in total
Post 30 Sep 2018, 21:00
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 07:06
With the FORMAT macro you use the instruction set is not defined until FORMAT is specified. So you end up trying to overload MOV when MOV is not yet d efined. The FORMAT PE line then loads the instruction set for selected format and defines MOV from scratch, overshadowing the previous attempt of overloading it.

You either need to move that MOV macro to after the FORMAT line, or include instruction set independently from FORMAT.
Post 01 Oct 2018, 07:06
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 01 Oct 2018, 09:21
Thanks. It helps.
Code:
match ,{

        include 'win32a.inc'
        include 'localptr.inc'

} match -,{
else
        include 'ABI/WIN/win32a.inc'

end match
_ equ }

        format PE large NX DLL
        entry DllEntryPoint

match ,{
} match -,{
else
macro mov? dest*,src*
        match size [mem], ?src
                mov dest,src
        else if src relativeto ebp & src - ebp
                lea dest,[src]
        else
                mov dest,src
        end if
end macro

end match
_ equ }     
Post 01 Oct 2018, 09:21
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 09:23
Please note that this simple DLL version is now included in the official package and it has had some corrections made later.
Post 01 Oct 2018, 09:23
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 01 Oct 2018, 10:22
When I replaced format on it forward refferencing form i got not enough memory

Forward refferenced format macro is so greedy?
updated attachment in 1st post

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.
Post 01 Oct 2018, 10:22
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 10:32
You can get it to display the actual error by reducing the -R setting:
Code:
>fasmg fasmg.dll.asm -r100
flat assembler  version g.ialrk
fasmg.dll.asm [1]:
        format PE large NX DLL ;rename binary as 'fasmg.DLL'
macro PE [55]
Custom error: invalid argument.    
This looks like a bug in FORMAT.PE macro.
Post 01 Oct 2018, 10:32
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 01 Oct 2018, 12:56
Tomasz thanks again. I found that in PE macro I missed ":".

Now when I compiled project with -r100 - succes.
without - error not enought memory
Is it mean somewhere endless recursion? or whatever?
Post 01 Oct 2018, 12:56
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 13:02
This means there is an infinite recursion somewhere in the first pass. I'll look into it later.
Post 01 Oct 2018, 13:02
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 13:09
Wait, this is certainly the MOV macro, in the first pass FORMAT does not include instruction set, so MOV ends up recursive. You can correct the issue by enforcing variable status on MOV macro, you can do that by adding
Code:
purge mov?    
before the FORMAT line.
Post 01 Oct 2018, 13:09
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 01 Oct 2018, 13:22
Thanks again, such fix reduce compilation time from 39,5 sec to 32,3 and always successfull independent from switch -r.
Could it be placed somewhere else except first line of main source?

that solves problem too:
Code:
macro mov? dest*,src*
        match size [mem], ?src
                mov dest,src
        else if src relativeto ebp & src - ebp
                lea dest,[src]
        else
                mov dest,src
        end if
end macro

macro mov? dest*,src*
end macro

purge mov?     

(-) time penalty +0.2 sec -vs your variant, (+) but now it could be hidden in includes.
Post 01 Oct 2018, 13:22
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 14:51
This kind of problems could be avoided entirely if fasmg required additional syntax to mark macro as allowed to be recursive. It would break backward compatibility, but macro recursion is not frequently used, so it would not be a big problem. I should perhaps reconsider.
Post 01 Oct 2018, 14:51
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 01 Oct 2018, 19:34
I have tested it and I believe this is the right thing to do, even at the cost of having to update some macro packages. This really solves the problem of inadvertent recursion.
Post 01 Oct 2018, 19:34
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 817
Location: Russian Federation, Sochi
ProMiNick 01 Oct 2018, 23:56
Why colon twiced?
Code:
        else match =PE? settings, clause:;this is first
                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.DllCharacteristics = 0
                local seq
                define seq settings:;this is second    
Post 01 Oct 2018, 23:56
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8395
Location: Kraków, Poland
Tomasz Grysztar 02 Oct 2018, 05:47
Oh, I have mixed in the macro part from the other package by mistake. A flaw of a hasty commit, for sure.
Post 02 Oct 2018, 05:47
View user's profile Send private message Visit poster's website 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.