flat assembler
Message board for the users of flat assembler.
Index
> Main > Conditional equates |
Author |
|
LocoDelAssembly 07 May 2005, 18:17
Well I found that conditional equates is not possible in this link http://board.flatassembler.net/topic.php?t=525
But I can't use "=" because I can't put ".r1 = ebx", so what can I do to make conditionals equates? Code: .r1 EQU esi .r2 EQU ebx .r3 EQU edi if hDC eq ebx .r1 EQU ebx .r2 EQU esi else if hDC eq edi .r1 EQU edi .r3 EQU esi else if ~ hDC eq esi mov .r1, hDC end if hDC is a param of a macro The final values after this code are: .r1 EQU edi .r2 EQU esi .r3 EQU esi There is another way to do this? |
|||
07 May 2005, 18:17 |
|
LocoDelAssembly 08 May 2005, 18:10
Here is the new code:
Code: macro B1 \{ .r1 EQU ebx .r2 EQU esi \} macro B2 \{ .r1 EQU edi .r3 EQU esi \} ifeq hDC, ebx, B1 ifeq hDC, edi, B2 if ~hDC in <.r1, .r2, .r3> mov .r1, hDC end if purge B2 purge B1 But it's still problematic if hDC is a param like "[mem]". It's possible to fix it? P.S.: This code is for an inline proc implemented as a macro |
|||
08 May 2005, 18:10 |
|
LocoDelAssembly 08 May 2005, 22:27
Sorry, I forgot to say the error that FASM throws.
When hDC is [mem] says "Error: extra characters on line" but if I comment "purge ifeq#name1" of your macro it works perfect but ifeqname1 will still defined. It's a bug in FASM? |
|||
08 May 2005, 22:27 |
|
Tomasz Grysztar 09 May 2005, 08:46
When hDC is [mem], so becomes the name1, and that line becomes:
Code: purge ifeq[mem] what is of course bad syntax for "purge" and causes an error. So the conditional preprocessing trick won't help you here, since it works only with simple symbols without any special characters, and you need the condition checking that is provided only at assembly time (sorry for guiding you into wrong direction). I suggest you to redesign the structure of your code, to something like: Code: .r1 equ esi .r2 equ ebx .r3 equ edi if hDC eq ebx .r1 equ ebx .r2 equ esi your_macro restore .r1 restore .r2 else if hDC eq edi .r1 equ edi .r3 equ esi your_macro restore .r1 restore .r3 else if ~ hDC eq esi mov .r1, hDC your_macro end if restore .r1 restore .r2 restore .r3 where "your_macro" would containt the code where you actually use the .r1-.r3 constants. |
|||
09 May 2005, 08:46 |
|
LocoDelAssembly 09 May 2005, 17:08
Yeah, that code works fine I just modified it a little because if hdc = esi the macro is not assembled. Thank you for your solution it's looks nice since I need less macros than the previous one and works if hDC is [mem]
You say "purge" does not support "[]" but I can define a macro like "abc[def]" without problems and use it. How can I undefine such macro if "purge" can't? I not need to define a macro like "abc[def]", I'm only curious. |
|||
09 May 2005, 17:08 |
|
Tomasz Grysztar 09 May 2005, 17:21
This line:
Code: macro abc[def] defines the macro called "abc" with group parameter called "def" (see fasm's manual). So to undefine it you would just use "purge abc". It's just a concidence that you got valid macro definition with hDC equal to [mem]. |
|||
09 May 2005, 17:21 |
|
Tomasz Grysztar 09 May 2005, 17:26
Actually I think that even better solution might be something like (just an example):
Code: macro your_macro .r1,.r2,.r3 { ; ... } if hDC eq ebx your_macro ebx,esi,edi else if hDC eq edi your_macro edi,ebx,esi else if ~ hDC eq esi mov .r1, hDC your_macro esi,ebx,edi end if |
|||
09 May 2005, 17:26 |
|
LocoDelAssembly 10 May 2005, 13:30
Actually I read the manual but I thought a space between the name of macro and the arguments was always required
Yep, your new solution is less complex and compact, pity that leaves me like an idiot because solutions like that I must have been able to do it without help . Sorry for ask you this things, I'm not new in assembly programming but programming with macros is my first time Thanks |
|||
10 May 2005, 13:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.