flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
BAiC 31 Dec 2012, 22:53
I am using the 'defined' operator/command (with the ~ operator) to conditionally initialize the first of potentially many variable-style labels.
when only one variable is defined then FASM doesn't register its' presence. this macro starts the code: .init.firstCallb is a unique, forward-referenced variable that is defined in the second macro (indeed all 4 labels are defined in the second macro) Code: macro ORB.Fx.Header dot { ali 12, 16 dw (dot # .end.code - dot)/8 dw dot # .init.firstCallb - dot dw dot # .lastCall - dot dw dot # .function - dot } this is the segment of code that declares the only '.init' and therefore the only '.init.firstCall': Code: mov r9d, Color.white cal m.base.2to10l, .init the following is the macro that reads the non-existant '.init.firstCall' and generates the unique '.init.firstCallb' variable. Code: macro ORB.Fx.Footer dot { if ~defined dot # .init.firstCall dot # .init.firstCallb = dot dot # .lastCall = dot else dot # .init.firstCallb = dot # .init.firstCall dot # .lastCall = dot # .init end if dot # .function = dot # .f virtual at $ rali dot, line dot # .end.code: end virtual } finally; this is the definition of the described "cal" macro. Code: macro cal dst, lab;lab is the '.init' in 'cal m.base.2to10l, .init' { if lab eq call dst else if ~ defined lab db 0xE8 ; the op code for CALL rel32 lab = $ ; .init lab # .firstCall = $ ; generating .init.firstCall dd ((dst) and (1 shl (32-bits.ll) - 1)) } I omitted the rest of the "cal" macro in the post. the full macro for "cal" begins on line 419 of 'PseudoInstructions.asm' in the set of files I'll upload next.
_________________ byte me. |
|||||||||||
![]() |
|
revolution 31 Dec 2012, 23:00
|
|||
![]() |
|
revolution 31 Dec 2012, 23:37
BAiC wrote: revolution:both of your examples involve FASM being incapable of generating the code at all... |
|||
![]() |
|
BAiC 01 Jan 2013, 00:39
revolution: FASM generated the code I gave it but the constants were wrong.
but anyway... nevermind; I've switched my code over to a token method which is working as needed. only took a few minutes to replace "if ~ defined lab" with "if lab = -1" .. and adding a "lab = -1" to the first macro (the header section). |
|||
![]() |
|
l_inc 01 Jan 2013, 16:50
BAiC
Quote:
You should clearly understand, that the only situation this condition can be true is when the label lab is defined somewhere below this condition. And that happens exactly when you use the macro cal more than once. |
|||
![]() |
|
BAiC 02 Jan 2013, 16:33
l_inc: it's easy to say something is obvious after the result is clearly visible.
|
|||
![]() |
|
l_inc 02 Jan 2013, 18:29
BAiC
I answered, because you asked a question and you didn't show, that you got an answer and understood your mistake. Your question was still open and there was no "after". |
|||
![]() |
|
BAiC 03 Jan 2013, 19:26
l_inc: regardless of your intentions the words you used did not describe anything new.
|
|||
![]() |
|
l_inc 03 Jan 2013, 20:24
BAiC
You asked for an explanation of a situation you experienced. I gave it. If the explanation wasn't new for you, you shouldn't have asked. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.