flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > are macros that can do expression evaluation supported ?

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 19 Aug 2020, 13:39
hey all.
are macros that can do expression evaluation supported ?
maybe something like this http://masm32.com/board/index.php?topic=94.0 ?
Post 19 Aug 2020, 13:39
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 19 Aug 2020, 14:45
It’s not clear where on the page is the feature you’re asking for. There is some support for calculations in FASM macros but generally assembly-time features are enough for calculations.
Post 19 Aug 2020, 14:45
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 20 Aug 2020, 01:32
fasm can solve basic algebra at assemble-time. And fasmg even more powerful. Given the 35 page post at the forum, it seems like you are looking for a code generator, though. If that is the case, why not just use a compiler then? A far more powerful tool for code generation.
Post 20 Aug 2020, 01:32
View user's profile Send private message Visit poster's website Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 22 Aug 2020, 17:35
bitRAKE wrote:
it seems like you are looking for a code generator, though. why not just use a compiler then?

SO from your question i GUESS that the answer is: 'NO it's NOT possible. look for a better assembler.'
Post 22 Aug 2020, 17:35
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4020
Location: vpcmpistri
bitRAKE 22 Aug 2020, 19:38
I'm glad you are able to get around to what you are trying to say.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 22 Aug 2020, 19:38
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: 20300
Location: In your JS exploiting you and your system
revolution 22 Aug 2020, 23:42
Expression evaluation is native in the assembler. No need for a macro to do it.
Code:
mov eax, 1 + 2 * (3 + 4)    
Post 22 Aug 2020, 23:42
View user's profile Send private message Visit poster's website Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 26 Aug 2020, 21:18
revolution wrote:
Expression evaluation is native in the assembler. No need for a macro to do it.
Code:
mov eax, 1 + 2 * (3 + 4)    

and with variables ?
Post 26 Aug 2020, 21:18
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20300
Location: In your JS exploiting you and your system
revolution 26 Aug 2020, 22:50
fasmFUN wrote:
revolution wrote:
Expression evaluation is native in the assembler. No need for a macro to do it.
Code:
mov eax, 1 + 2 * (3 + 4)    

and with variables ?
Yes. fasm is multi-pass and it can solve many expressions with variables or constants. Try it.
Post 26 Aug 2020, 22:50
View user's profile Send private message Visit poster's website Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 03 Oct 2020, 18:06
Quote:
Yes. fasm is multi-pass and it can solve many expressions with variables or constants. Try it.

i found that it can not do complex expression that evaluate to more than one instruction
Post 03 Oct 2020, 18:06
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 03 Oct 2020, 19:49
Example required.
Post 03 Oct 2020, 19:49
View user's profile Send private message Visit poster's website Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 10 Oct 2020, 20:01
DimonSoft wrote:
Example required.

yes. do you have one ?
Post 10 Oct 2020, 20:01
View user's profile Send private message Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 11 Oct 2020, 16:55
fasmFUN wrote:
i found that it can not do complex expression that evaluate to more than one instruction
Expressions evaluate to numbers, not instructions. Whether you conditionally emit instructions based on that number after (with if) is a different matter.
Post 11 Oct 2020, 16:55
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 11 Oct 2020, 17:24
fasmFUN wrote:
DimonSoft wrote:
Example required.

yes. do you have one ?

Example of what you were looking for.
Post 11 Oct 2020, 17:24
View user's profile Send private message Visit poster's website Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 15 Oct 2020, 01:12
Furs wrote:
fasmFUN wrote:
i found that it can not do complex expression that evaluate to more than one instruction
Expressions evaluate to numbers, not instructions. Whether you conditionally emit instructions based on that number after (with if) is a different matter.

but first they evaluate to asm instruction
anyway the meaning is that the compiler can handle only simple expressions
for examples:
mov eax,1*2+(3/4)
is a very simple expression because it evaluate to single asm instruction

this one:
mov eax, bb(n,2,3)

is complex because it should be evaluated to several instructions
which what i'm looking for from the compiler
at least with macros
as in the example link on top of thread
Post 15 Oct 2020, 01:12
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20300
Location: In your JS exploiting you and your system
revolution 15 Oct 2020, 03:19
fasmFUN wrote:
this one:
mov eax, bb(n,2,3)

is complex because it should be evaluated to several instructions
What do you need it to assemble to?

This?
Code:
mov eax,bbn
mov eax,bb2
mov eax,bb3    
In fasm this type of thing can be done with irp
Code:
irp v,n,2,3 {
  mov eax,bb#v
}    
You could also wrap it in a macro to override mov.

Show us what you want to do and it can probably be done.
Post 15 Oct 2020, 03:19
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 15 Oct 2020, 09:50
Correct me if I'm wrong, but I suspect this thread is actually about inline macros.
Post 15 Oct 2020, 09:50
View user's profile Send private message Visit poster's website Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 17 Oct 2020, 16:29
revolution wrote:
fasmFUN wrote:
this one:
mov eax, bb(n,2,3)

is complex because it should be evaluated to several instructions
What do you need it to assemble to?

This?
Code:
mov eax,bbn
mov eax,bb2
mov eax,bb3    
In fasm this type of thing can be done with irp
Code:
irp v,n,2,3 {
  mov eax,bb#v
}    
You could also wrap it in a macro to override mov.

Show us what you want to do and it can probably be done.

no ,
very SIMPLE example
from this->
mov [a],bb(n,2,3)+1
to this->
push n,2,3
call bb
add eax,1
mov [a], eax

and even more HL
a = bb(n,2,3)+1


also in if statement

if bb(n,2,3)+1>1 then ...
Post 17 Oct 2020, 16:29
View user's profile Send private message Reply with quote
fasmFUN



Joined: 25 May 2019
Posts: 15
fasmFUN 17 Oct 2020, 16:37
Tomasz Grysztar wrote:
Correct me if I'm wrong, but I suspect this thread is actually about inline macros.


thank you very much very interesting.
now i need to look for such examples.
Post 17 Oct 2020, 16:37
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 17 Oct 2020, 19:04
fasmFUN wrote:
no ,
very SIMPLE example
from this->
mov [a],bb(n,2,3)+1
to this->
push n,2,3
call bb
add eax,1
mov [a], eax

and even more HL
a = bb(n,2,3)+1


also in if statement

if bb(n,2,3)+1>1 then ...

So, why are you asking low-level language to be a high-level language? I guess, choosing the right tool for each set of requirements is the way to go.
Post 17 Oct 2020, 19:04
View user's profile Send private message Visit poster's website Reply with quote
Furs



Joined: 04 Mar 2016
Posts: 2493
Furs 18 Oct 2020, 12:26
fasmFUN wrote:
revolution wrote:
fasmFUN wrote:
this one:
mov eax, bb(n,2,3)

is complex because it should be evaluated to several instructions
What do you need it to assemble to?

This?
Code:
mov eax,bbn
mov eax,bb2
mov eax,bb3    
In fasm this type of thing can be done with irp
Code:
irp v,n,2,3 {
  mov eax,bb#v
}    
You could also wrap it in a macro to override mov.

Show us what you want to do and it can probably be done.

no ,
very SIMPLE example
from this->
mov [a],bb(n,2,3)+1
to this->
push n,2,3
call bb
add eax,1
mov [a], eax

and even more HL
a = bb(n,2,3)+1


also in if statement

if bb(n,2,3)+1>1 then ...
Sounds like C with inline asm is what you want.
Post 18 Oct 2020, 12:26
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.