flat assembler
Message board for the users of flat assembler.
Index
> Main > return value for macro |
Author |
|
khanh1984 17 Jul 2009, 08:22
Dear Tomasz,
I've think of very simple idea to implement this feature. in macro we will add another type such as: word macro sizeof Structure { macro inside here return value } So when fasm encounters the macro above, it realizes that this macro is different from normal macro 'cause it has type 'word' in front. Then it decides to implement a normal macro of random name with same code inside, it will calculate all the value based on that macro. Finally, after have return value, it simplies define a constant with the name sizeof structure to that value. What do you think about my idea. Please post your opinion. |
|||
17 Jul 2009, 08:22 |
|
Fanael 17 Jul 2009, 08:33
Tomasz, please don't implement inline macros in FASM!
|
|||
17 Jul 2009, 08:33 |
|
khanh1984 17 Jul 2009, 09:39
Fanael,
What do mean by inline macro ??? I only know inline asm in high-level language and why do you think it is bad??? please give your answer in more detail? |
|||
17 Jul 2009, 09:39 |
|
Fanael 17 Jul 2009, 12:35
Tomasz Grysztar wrote: No, inlining the macros is something against the fasm's concept. The macro in fasm is just a special kind of "mnemonic", which gets converted into chain of other lines by preprocessor. Just like each assembly language instruction spans one line, the macroinstruction spans one line. |
|||
17 Jul 2009, 12:35 |
|
bitRAKE 17 Jul 2009, 13:43
Here are a couple way to implement return values:
Code: macro sizeof structure { local ..xyz virtual at 0 ..xyz structure sizeof.return = $ - ..xyz end virtual } macro sizeof return,structure { local ..xyz virtual at 0 ..xyz structure return = $ - ..xyz end virtual } Last edited by bitRAKE on 18 Jul 2009, 23:47; edited 2 times in total |
|||
17 Jul 2009, 13:43 |
|
Azu 18 Jul 2009, 03:49
Here you go
macro return value{ mov eax,value ret } Last edited by Azu on 18 Jul 2009, 18:15; edited 1 time in total |
|||
18 Jul 2009, 03:49 |
|
Borsuc 18 Jul 2009, 18:01
@Azu: shouldn't you reverse the name & parameter?
|
|||
18 Jul 2009, 18:01 |
|
LocoDelAssembly 18 Jul 2009, 18:27
bitRAKE's code needs a little adjustment, it is better to use "local ..xyz" to not interfere with the caller scope.
|
|||
18 Jul 2009, 18:27 |
|
khanh1984 23 Jul 2009, 06:44
bitRake:
I understand your macro but for the command like this: mov eax, sizeof structure how your macro fits in this situation. I mean when fasm encounters the line above, it will replace sizeof structure with your macro but the above like is one line command, your macro is 2 line so how you will be sure that Fasm will replace only sizeof.return value in that "mov" instruction. |
|||
23 Jul 2009, 06:44 |
|
bitRAKE 23 Jul 2009, 13:56
FASM doesn't support inline macros, and I'm not attempting to solve inline (one line) macro problem. Use two lines in source code. Example, http://board.flatassembler.net/topic.php?t=10472
|
|||
23 Jul 2009, 13:56 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.