• Welcome to Jose's Read Only Forum 2023.
 

Jumping into an END IF Block

Started by Theo Gottwald, October 08, 2010, 10:55:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Theo Gottwald

I have just found myself to code a MACRO like this:



REGISTER R01 as LONG

MACRO AGS_SP(P1,P2,P3)
Macrotemp Labx
if ismissing(P1) then goto Labx
S03=Trim$(P1):R01=Len(S03)
if (R01>0) then
R01=T06.SB
SetBit(R01,P2)
T06.P3=S03
T06.SB=R01
else
Labx:
R01=T06.SB
             ClearBit(R01,P2)
T06.SB=R01
T06.P3=""
end if
END MACRO


I could have done it in another way, less optimized.

but this way seems completely "legal" to me, as in PB, the "END IF" in the resulting compiled ASM Code is just an adress. Means there is nothing why not to jump into an END IF Block.

Just wanted share this with you. Anybody else also done this?

Charles Pegge

#1
Hi Theo,

I do that sometimes as well.

One solution is to use another goto :)

I find that this arrangement makes the code a little easier to maintain and clarifies the logic. Essentially what you have is an inline function called Labx and you mark its end boundary with nLabx. In future this might evolve into a conventional out-of-line function, and the required code transform would be simpler.


MACRO AGS_SP(P1,P2,P3)
Macrotemp Labx
if ismissing(P1) then goto Labx
S03=Trim$(P1):R01=Len(S03)
'
if (R01>0) then
R01=T06.SB
SetBit(R01,P2)
T06.P3=S03
T06.SB=R01
       goto nLabx
end if
'
Labx:
R01=T06.SB
            ClearBit(R01,P2)
T06.SB=R01
T06.P3=""
nLabx:
'
END MACRO


Theo Gottwald

Thats a good Point, Charles.
Another GOTO would also solve the Problem.
While internally, after compile,
both versions will be all the same, because this is just what the ELSE will be compiled to, a Jump.