flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
JohnFound 04 Dec 2010, 07:16
in your first example, "equ" works in preprocessing stage and the assembler never can see the "label" X (it is not label but symbolic constant) it can see only the string "edi+1" replaced in the text of the source.
On the other hand, all labels are numbers once defined, so in your second example the assembler will see the label X, not the text "edi+1". |
|||
![]() |
|
Rahsennor 04 Dec 2010, 10:10
![]() Code: label x at edi+1 if x eqtype edi+1 ; fails! display 'with label',13,10 end if if edi+1 eqtype edi+1 ; same address, but now it works display 'without label',13,10 end if Code: label x at edi+1 db x-edi ; works db edi+1-edi ; same value: fails ![]() EDIT: To elaborate, say I want to make a macro that takes an address as an argument. That macro must decide if it can save the address directly with dd or if it must use an alternative encoding. How do I do it? |
|||
![]() |
|
Tomasz Grysztar 04 Dec 2010, 10:44
This is related to how parser sees the source. Unless in a special context (after the AT operator, or inside the square brackets), "edi+1" is seen as two separate expressions. "edi" - register, and "+1" - a numerical expression. That's why this works:
Code: if eax 4 eqtype edi+1 display 'register and expression' end if Code: push edi+1 So the fact that this: Code: db edi+1-edi As I wrote earlier, AT and PTR operators (and the square brackets, which are the same thing as PTR) provide a special context where "numerical" expressions starting with registers are allowed. Thus: Code: if at eax 4 eqtype at edi+1 display 'Not anymore!' end if label x at edi+1 if at x eqtype at edi+1 display 'And this one is OK' end if Last edited by Tomasz Grysztar on 04 Dec 2010, 10:46; edited 1 time in total |
|||
![]() |
|
baldr 04 Dec 2010, 10:45
Rahsennor wrote: To elaborate, say I want to make a macro that takes an address as an argument. That macro must decide if it can save the address directly with dd or if it must use an alternative encoding. How do I do it? |
|||
![]() |
|
Rahsennor 04 Dec 2010, 11:18
Merci beaucoup! It makes sense now.
"if at edi+1 eqtype at 1" still passes, making it useless for my purpose. It was a silly purpose anyway. ![]() @baldr: that is some hack. Nice. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.