flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
DimonSoft 11 Jul 2020, 19:44
Cgtk wrote: Hello, I need to implement a construction like this using fasm macros: First of all note that you mix preprocessor and compiler stuff. In this particular case you’ll have an endless recursion. Still, the general idea is the following: write a macro that defines your macro and call it before recursive call of the macro itself. For your case, it would look something like: Code: macro def_recursion { macro recursion \{ random 1, 2; min, max if random_result = 2 def_recursion recursion end if \} } def_recursion |
|||
![]() |
|
Cgtk 11 Jul 2020, 21:18
Thanks!
|
|||
![]() |
|
Roman 12 Jul 2020, 12:22
And how use this macro ?
|
|||
![]() |
|
DimonSoft 12 Jul 2020, 15:51
Roman wrote: And how use this macro ? |
|||
![]() |
|
Cgtk 19 Jul 2020, 19:46
Hello again, I'm trying to implement a recursion construct like this
Code: macro big_macros{ macro num_1 param1 \{ random 1, 2 if param1 = 1 if randnum = 2 num_2 end if end if \} macro num_2 \{ num_1 0 ; error here \} } start: big_macros The compiler throws the error: "illegal instruction" What is wrong? Last edited by Cgtk on 20 Jul 2020, 10:35; edited 1 time in total |
|||
![]() |
|
DimonSoft 19 Jul 2020, 21:20
DimonSoft wrote: First of all note that you mix preprocessor and compiler stuff. |
|||
![]() |
|
Cgtk 20 Jul 2020, 10:02
DimonSoft wrote:
I am writing macros on fasm for the first time and don't know how to do it properly. Could you tell me how you can implement a macro similar in functionality to the macro that I described in the post earlier? |
|||
![]() |
|
revolution 20 Jul 2020, 10:07
There is a problem here:
Code: marco big_macros{ Also use backslash \ to escape the curly brackets, not forward slash / |
|||
![]() |
|
Cgtk 20 Jul 2020, 10:34
revolution wrote: There is a problem here: Oh, thank you, fixed the post with the code. Unfortunately this is just my typo in the example and the compiler is not swearing because of this. |
|||
![]() |
|
revolution 20 Jul 2020, 10:42
Works for me.
Code: 1 passes, 0 bytes. |
|||
![]() |
|
Cgtk 20 Jul 2020, 11:09
Try to compile this
|
|||||||||||
![]() |
|
DimonSoft 20 Jul 2020, 11:13
Build your source code with Ctrl+F8 if you use FASMW IDE, then feed the fas-file to PREPSRC tool in the %FASM%\TOOLS\WIN32 directory (easily buildable from the source code). PREPSRC might give you sense of what is going on.
|
|||
![]() |
|
Cgtk 20 Jul 2020, 11:25
DimonSoft wrote: Build your source code with Ctrl+F8 if you use FASMW IDE, then feed the fas-file to PREPSRC tool in the %FASM%\TOOLS\WIN32 directory (easily buildable from the source code). PREPSRC might give you sense of what is going on. I can't compile my code. The compiler throws the error: "illegal instruction". |
|||
![]() |
|
revolution 20 Jul 2020, 11:34
Cgtk: Please reduce your code from the 55kB you posted there. Just post the necessary parts showing the problem.
|
|||
![]() |
|
Cgtk 20 Jul 2020, 11:52
revolution wrote: Cgtk: Please reduce your code from the 55kB you posted there. Just post the necessary parts showing the problem.
|
|||||||||||
![]() |
|
Cgtk 20 Jul 2020, 11:58
DimonSoft wrote: Build your source code with Ctrl+F8 if you use FASMW IDE, then feed the fas-file to PREPSRC tool in the %FASM%\TOOLS\WIN32 directory (easily buildable from the source code). PREPSRC might give you sense of what is going on. Sorry for a very stupid question, but what should I submit as an input and output file? |
|||
![]() |
|
revolution 20 Jul 2020, 12:04
There is still a lot of extraneous stuff in there, but the error output shows that you are calling gen_trash_func from within itself.
You need to regenerate the macro within itself if you want to do a recursive call. See the fasm win32ax.inc code for how allow_nesting does it. |
|||
![]() |
|
Cgtk 20 Jul 2020, 12:15
Thank you, I will definitely look at it.
|
|||
![]() |
|
DimonSoft 20 Jul 2020, 13:35
Cgtk wrote:
The fas-file you got as the input and any file name as output (it will be a text file with step-by-step explanations of what preprocessor sees and how does it (pre)process it). |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.