flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Why it falls?..

Author
Thread Post new topic Reply to topic
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 28 Dec 2004, 12:37
Hello, everybody!

Please, explain me, why FASMW just falls when compiling this code:

macro PowerOf2 value
{
power_of_2 = 0
range = 1
enable_getpower_of_2
getpower_of_2 value
purge getpower_of_2
display 'power of 2 = ',power_of_2+48,13,10
display 'range = ',range+48,13,10
}

macro enable_getpower_of_2
{
macro getpower_of_2 value
_open
if (range < value)
power_of_2 = power_of_2 + 1
range = range * 2
enable_getpower_of_2
getpower_of_2 value
purge getpower_of_2
end if
_close
}

_open fix {
_close fix }

PowerOf2 6

Is it because IF compiled after macro expansion -> unlimited recursion?

Thanks.

_________________
Flat Assembler is the best!
Post 28 Dec 2004, 12:37
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 29 Dec 2004, 12:06
Quote:
Is it because IF compiled after macro expansion -> unlimited recursion?

Yes, exactly. You've got the infinite recursion and this causes the stack overflow - the result may vary depending on how your operating system handles stack overflows, since fasm interfaces currently don't do own exception handling.
Post 29 Dec 2004, 12:06
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.