flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Tower of Hanoi

Author
Thread Post new topic Reply to topic
quiveror



Joined: 20 Jun 2003
Posts: 34
quiveror 11 Jun 2006, 10:56
This is how I waste my time during long holiday. Change no_disk to 16 to make fasm produce 65535 lines of output Laughing

Code:
no_disk fix 5
iterator equ
rept no_disk x { iterator equ x }
macro define_solve {
    macro solve src,dst \{
        match x,iterator \\{
            temp equ iterator
            restore iterator 
            define_solve
            match =a =b,src dst \\\{ solve a,c \\\}
            match =a =c,src dst \\\{ solve a,b \\\}
            match =b =a,src dst \\\{ solve b,c \\\}
            match =b =c,src dst \\\{ solve b,a \\\}
            match =c =a,src dst \\\{ solve c,b \\\}
            match =c =b,src dst \\\{ solve c,a \\\}
            purge solve
            display 'move a disk from ',\\`src,' to ',\\`dst,13,10
            define_solve
            match =a =b,src dst \\\{ solve c,b \\\}
            match =a =c,src dst \\\{ solve b,c \\\}
            match =b =a,src dst \\\{ solve c,a \\\}
            match =b =c,src dst \\\{ solve a,c \\\}
            match =c =a,src dst \\\{ solve b,a \\\}
            match =c =b,src dst \\\{ solve a,b \\\}
            purge solve
            iterator equ temp
            restore temp
        \\}
    \}
}
define_solve
solve a,c
purge solve,define_solve
rept no_disk { restore iterator }
restore iterator
    
Post 11 Jun 2006, 10:56
View user's profile Send private message Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
daluca 20 Aug 2006, 06:11
well I tried with 16 and it just give me an Error: out of memory message
even with the maximum memory :65536
Post 20 Aug 2006, 06:11
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 20 Aug 2006, 09:18
65536 isn't a maximum, you can write there 700000 or so if you wish.
Post 20 Aug 2006, 09:18
View user's profile Send private message Visit poster's website Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
daluca 21 Aug 2006, 01:31
oh i didn't know that: is it measured in bytes or kilobytes?
Post 21 Aug 2006, 01:31
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 21 Aug 2006, 07:09
65536 means kilobytes so its 64MB. 700MB would be 716800
Post 21 Aug 2006, 07:09
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 21 Aug 2006, 13:54
Hmm, I had to set the memory to 20485760 to get 16 disks. If it were KB it would be 20GB (previously 10GB); I doubt that that's possible!
Post 21 Aug 2006, 13:54
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8349
Location: Kraków, Poland
Tomasz Grysztar 21 Aug 2006, 14:06
If you set too large value, the lower amount is actually allocated. Trying anything more than 4 GB makes no sense at all, the 32-bit addressing space wouldn't be able to contain it.
You may experiment also with the "-m" switch of command line version, as the latest releases show you how much memory got really allocated.
PS.600000 kilobytes was enough for me to get 16 disks.
Post 21 Aug 2006, 14:06
View user's profile Send private message Visit poster's website Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 21 Aug 2006, 20:51
wow that's amazing! pity i dunno how it works Laughing

As Tomasz said, 600MB Shocked Exclamation
Post 21 Aug 2006, 20:51
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 21 Aug 2006, 21:15
I probably ran out of swap space Confused
Post 21 Aug 2006, 21:15
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 22 Aug 2006, 07:14
Smile maybe it can be optimized to take less! Tomasz - you know the internals - are there any alternative commands that by replacing eat up less memory (even if they are i.e. slower)?
Post 22 Aug 2006, 07:14
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
daluca 23 Aug 2006, 20:33
could be included in the compilation result display,along with
the time,passes and number of bytes, the actual amount of memory
that was required to assemble the files?
Post 23 Aug 2006, 20:33
View user's profile Send private message 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.