flat assembler
Message board for the users of flat assembler.
Index
> Main > fasm vs fasmg: minimal program text |
Author |
|
Grom PE 17 Sep 2016, 11:24
Just for fun, write the smallest possible source code that, when assembled, produces the exact lyrics of the 99 bottles of beer song.
Output should be 11885 bytes, MD5: 6805cea174ee0ff44092d0d7cf6dfa8f. My result is 300 bytes for fasm: Code: e fix equ w e ' on the wall' rept 100 n:0{reverse b e `n c e b s e 's' match=n,1\{s e ''\}match=n,0\{b e 'no more' c e 'No more'\}v e ' bottle',s,' of beer' x e v,w,'.',10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,'.',10}db 'Go to the store and buy some more, 99',x Code: w=' on the wall' rept 100 rept 1,n:100-% b=`n c=b s='s' if n=1 s='' else if n=0 b='no more' c='No more' end if v equ ' bottle',s,' of beer' x equ v,w,'.',10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,'.',10 end rept end rept db 'Go to the store and buy some more, 99',x Can you make it smaller? Which assembler will win in the end?
|
|||||||||||
17 Sep 2016, 11:24 |
|
Grom PE 17 Sep 2016, 14:07
Ah, very nice! 300 bytes for fasmg, it's a tie now!
|
|||
17 Sep 2016, 14:07 |
|
revolution 17 Sep 2016, 15:00
One less byte for the fasm version. Change in line 4 only:
Code: e fix equ w e ' on the wall' rept 100 n:0{reverse b e`n c e b s e 's' match=n,1\{s e ''\}match=n,0\{b e 'no more' c e 'No more'\}v e ' bottle',s,' of beer' x e v,w,'.',10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,'.',10}db 'Go to the store and buy some more, 99',x |
|||
17 Sep 2016, 15:00 |
|
revolution 17 Sep 2016, 15:03
Two more bytes excised from the fasm version. Remove the escaping backslashes from the opening {
Code: e fix equ w e ' on the wall' rept 100 n:0{reverse b e`n c e b s e 's' match=n,1{s e ''\}match=n,0{b e 'no more' c e 'No more'\}v e ' bottle',s,' of beer' x e v,w,'.',10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,'.',10}db 'Go to the store and buy some more, 99',x |
|||
17 Sep 2016, 15:03 |
|
Tomasz Grysztar 17 Sep 2016, 20:24
A bit more squeezed fasmg version:
Code: t='' w=' on the wall' rept 100 b='no more' c='No more' rept %%-%,n b=`n c=b end rept s='s' if %=99 s='' end if v equ ' bottle',s,' of beer' x equ v,w,'.',10 db t,c,v,w,', ',b,v,'.',10 t equ 'Take one down and pass it around, ',b,x,10 end rept db 'Go to the store and buy some more, 99',x |
|||
17 Sep 2016, 20:24 |
|
revolution 17 Sep 2016, 21:18
fasm 293 bytes:
Code: _ fix equ w _ ' on the wall' rept 100 n:0{reverse b _`n c _`n s _ 's', match=n,1{s _\}match=n,0{b _ 'no more' c _ 'No more'\}v _ ' bottle',s#' of beer' x _ v,w,46,10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,46,10}db 'Go to the store and buy some more, 99',x |
|||
17 Sep 2016, 21:18 |
|
revolution 17 Sep 2016, 21:34
fasm 291 bytes:
Code: _ fix equ w _ ' on the wall' rept 100 n:0{reverse b _`n c _`n s _`s, match=n,1{s _\}match=n,0{b _ 'no more' c _ 'No more'\}v _ ' bottle',s#' of beer' x _ v,w,46,10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,46,10}db 'Go to the store and buy some more, 99',x |
|||
17 Sep 2016, 21:34 |
|
Tomasz Grysztar 17 Sep 2016, 22:08
fasmg, 283 bytes:
Code: t='' w=' on the wall' rept 100 b='no more' c='No more' rept %%-% b=`% c=b end rept s='s' if %=99 s='' end if v equ ' bottle',s,' of beer' x equ v,w,46,10 db t,c,v,w,', ',b,v,46,10 t equ 'Take one down and pass it around, ',b,x,10 end rept db 'Go to the store and buy some more, 99',x |
|||
17 Sep 2016, 22:08 |
|
Grom PE 18 Sep 2016, 07:47
Used Tomasz's amazing trick with double rept to shorten fasm version to 286 bytes:
Code: _ fix equ w _ ' on the wall' rept 100 m{b _ 'no more' c _ 'No more' rept 100-m n{b _\`n c _ b\}s _`s, match=m,99{s _\}v _ ' bottle',s#' of beer' x _ v,w,46,10 if $ db 'Take one down and pass it around, ',b,x,10 end if db c,v,w,', ',b,v,46,10}db 'Go to the store and buy some more, 99',x |
|||
18 Sep 2016, 07:47 |
|
DOS386 23 Sep 2016, 17:50
COOL.
http://board.flatassembler.net/topic.php?t=5411 http://99-bottles-of-beer.net/language-fasm-1109.html (formatting is strange, damn TAB's) |
|||
23 Sep 2016, 17:50 |
|
revolution 23 Sep 2016, 18:18
DOS386 wrote: http://board.flatassembler.net/topic.php?t=5411 |
|||
23 Sep 2016, 18:18 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.