flat assembler
Message board for the users of flat assembler.

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

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 672
l4m2 27 Dec 2016, 11:05
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.
Post 27 Dec 2016, 11:05
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19491
Location: In your JS exploiting you and your system
revolution 27 Dec 2016, 11:56
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.
Post 27 Dec 2016, 11:56
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 672
l4m2 27 Dec 2016, 14:00
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?
Post 27 Dec 2016, 14:00
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 672
l4m2 27 Dec 2016, 14:05
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,
Post 27 Dec 2016, 14:05
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 672
l4m2 27 Dec 2016, 14:22
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
Post 27 Dec 2016, 14:22
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 19491
Location: In your JS exploiting you and your system
revolution 27 Dec 2016, 15:45
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.
Post 27 Dec 2016, 15:45
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-2023, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.