flat assembler
Message board for the users of flat assembler.

 Index > Compiler Internals > Code can't be generated because of calculating order?
Author
l4m2

Joined: 15 Jan 2015
Posts: 648
l4m2
Code:
if a1<a2
a=1
else
a=0
end if

if b1<b2
b=1
else
b=0
end if

b1: ; 0
if a=0
nop
end if
b2: ; 0

a1: ; 0
if b=0
nop
nop
end if
a2: ; 2

There exist solution but code can't be generated.
27 Dec 2016, 11:05
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17074
revolution
fasm does not guarantee to find all solutions.

IIRC the general solution would require on the order of O(2^N) iterations to solve. The algorithm fasm uses does not try all possibilities, it uses short cuts and assumptions. Otherwise for more complex code fasm might never find a solution within the lifetime of the universe.
27 Dec 2016, 11:56
l4m2

Joined: 15 Jan 2015
Posts: 648
l4m2
Code:
if a=1
a=1
else
a=0
end if

if b=1
b=1
else
b=0
end if

if c=1
c=1
else
c=0
end if

if (a>0 & (a=0 | b=0) & (c>0 & b>0)) | f>0
f=0
else
f=1
end if

so (a>0 & (a=0 | b=0) & (c>0 & b>0)) must be 1?
27 Dec 2016, 14:00
l4m2

Joined: 15 Jan 2015
Posts: 648
l4m2
Code:
if a<64
a=a+1
else
a=a
end if

It makes "66 passes". I tested and got that there's at most 100 passes. Can I modify it in fasmw?
Quote:
In the command line you can also include -m option followed by a number, which
specifies how many kilobytes of memory flat assembler should maximally use. In case
of DOS version this options limits only the usage of extended memory. The -p option
followed by a number can be used to specify the limit for number of passes the assembler
performs. If code cannot be generated within specified amount of passes, the assembly
will be terminated with an error message. The maximum value of this setting is 65536,
while the default limit, used when no such option is included in command line, is 100.
It is also possible to limit the number of passes the assembler performs,
27 Dec 2016, 14:05
l4m2

Joined: 15 Jan 2015
Posts: 648
l4m2
Code:
display 48+a
a = 6
if t<3
a = 8
end if
t = 7

a is only given the value 6 but the a=8 makes it uncomilable
27 Dec 2016, 14:22
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 17074
revolution
Also note that sometimes there is more than one solution, and fasm will stop when it finds one. So other solutions might exist, but fasm won't find them.

BTW: Using the search function you might be able to find a few older threads where this has all been covered before.
27 Dec 2016, 15:45
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum