flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Author |
|
revolution 09 Jan 2024, 05:53
The define directive followed by the name of constant and then the value, is the alternative way of defining symbolic constant. The only difference between define and equ is that define assigns the value as it is, it does not replace the symbolic constants with their values inside it. |
|||
![]() |
|
pfranz 09 Jan 2024, 22:25
Thank you, I wonder how I missed that paragraph.
Is it possible to define functions in FASM, like deffunc StupidSum(x) = x+5 mov al, StupidSum(3) which would equate mov al, 8 ? I think that in fasmg this may be achieved with "element" ... ? |
|||
![]() |
|
revolution 10 Jan 2024, 04:51
You can make a macro for mov to parse the arguments.
Code: macro mov args& { match reg =, =StupidSum =( num =), args \{ mov reg, num + 5 rept 0 \{\} rept 1 \{ mov args \} } mov eax,StupidSum(3) mov ecx,7 |
|||
![]() |
|
ProMiNick 10 Jan 2024, 08:17
I never seen before such sequence
Code: rept 0 \{\} rept 1 \{ why message with incomplete macro not displayed? when match in false state part "rept 0 \{" is ignored, but how it is parsed in case of positive match? count of open brackets mismatch to count of closed ones. |
|||
![]() |
|
Roman 10 Jan 2024, 09:14
Why not do this?
Code: Summ equ 5 mov eax, 3+Summ mov eax, 10/Summ mov eax, 5+(Summ*2-4) |
|||
![]() |
|
Roman 10 Jan 2024, 09:18
I get Idea.
EQU or some New equ must know what been before. Code: Ww equ2 :+5 ;using without macros and match W2 equ2 :-4*2 mov eax, 4 Ww In : we get 4 4+5 mov eax, Ww ; eax=5 mov eax, [ebx Ww] ; eax, [ebx+5] mov eax, [edx W2] ;eax, [edx-4*2] Last edited by Roman on 10 Jan 2024, 09:31; edited 1 time in total |
|||
![]() |
|
revolution 10 Jan 2024, 09:31
No need for equ2 since equ does exactly the same.
Code: Ww equ +5 mov eax, 4 Ww ; 4 +5 |
|||
![]() |
|
Roman 10 Jan 2024, 09:32
Its nice.
|
|||
![]() |
|
macomics 10 Jan 2024, 10:37
ProMiNick wrote: how this logic acts? Code: macro mov args& { match reg =, =StupidSum =( num =), args \{ mov reg, num + 5 rept 0 \\{\} rept 1 \{ mov args \} } |
|||
![]() |
|
revolution 10 Jan 2024, 10:49
There is no typo in the code I posted.
|
|||
![]() |
|
macomics 10 Jan 2024, 11:03
revolution wrote: There is no typo in the code I posted. |
|||
![]() |
|
revolution 10 Jan 2024, 11:10
There is no problem with fasm either. It works as intended. There was nothing to fix.
|
|||
![]() |
|
revolution 10 Jan 2024, 11:17
To gain a better understanding of the code, remember that the opening braces don't need to be escaped. I only escape them for readability. So you only need to consider the closing braces.
|
|||
![]() |
|
macomics 10 Jan 2024, 11:19
Here is your option
Code: match reg =, =StupidSum =( num =), args \{ mov reg, num + 5 rept 0 \{\} Here is my option Code: match reg =, =StupidSum =( num =), args \{ mov reg, num + 5 rept 0 \\{\} That is, in your version, the closing bracket for rept 0 will be the bracket for macro, and in my version, the bracket for rept 1. Or take the trouble to explain the logic of working with incomplete blocks. revolution wrote: To gain a better understanding of the code, remember that the opening braces don't need to be escaped. I only escape them for readability. So you only need to consider the closing braces. |
|||
![]() |
|
revolution 10 Jan 2024, 11:21
There are no incomplete blocks. There is no bug in fasm parsing.
|
|||
![]() |
|
revolution 10 Jan 2024, 12:14
Perhaps it help to realise that extraneous open braces are ignored in a block like this:
Code: rept 0 {{{ {{{{ {{{{{{{{{{{ } |
|||
![]() |
|
ProMiNick 10 Jan 2024, 20:36
Try to guess: incomplete macro? illegall syntax?
Code: match =a,a { match =b,b { match =c,c { match =d,d { match =e,e { rept 0 {}}}}} display 'x<>y' \}\}\}\}\}\\\\\\\\\}\\\\\\\\}\\\\\\\}\\\\\\}\\\\\}\\\\}\\\}\\}\} } succesfully compiled, just not display 'x<>y'. I could assume that match differs from any other preprocessor block (any enclosed in curvy brackets) - any preprocessor block started inside of successfull match block could be ended after end of parent block. so in above example previously closed all matches in same order as they started and rept 0 closed by last curvy bracket not prepended by \, because at that moment it become not nested - all parents are closed. Tomasz, that is not a bug - is a good bug, even best pleasant bug - a feature. But could thou explain it or atleast make that feature documented. moreover we could manage order of closed blocks (that is useless but we could): Code: match =a,a { match =b,b { match =c,c { match =d,d { match =e,e { rept 0 {\\\\}}\\}}} display 'x<>y' \}\}\}\}\}\\\\\\\\\}\\\\\\\\}\\\\\\\}\\\\\\}\\\\\}\\\\}\\\}\\}\} } |
|||
![]() |
|
revolution 10 Jan 2024, 21:46
ProMiNick wrote: Try to guess: incomplete macro? illegall syntax? ProMiNick wrote: succesfully compiled, just not display 'x<>y'. Works as intended. You asked for no repetitions, you got no repetitions. You only have to consider the closing braces. Each closing brace that is encountered is the end point for that macro block. The code I posted has two blocks. The first "match" block, and the second "rept 1" block. The first "match" block, if matched, will output a final "rept 0" to suppress the second "rept 1" block. |
|||
![]() |
|
ProMiNick 10 Jan 2024, 21:59
that isn`t answered why syntaxes of successful match differ from unsucessfull one(and from all preprocessor blocks) or anybody could bring example where else parent preprocessor block closed before its descendant, its descendant closed outer of parent and that everithing not caused incomplete macro.
|
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.