99 bottles of beer: Difference between revisions

(99 Bottles with Algae language)
Line 695:
const nl = "\n"
 
// PrintReserve two1024 digits,bytes usein the value in.bss asection
var x 1024
 
// Write two digits, based on the value in a
fun printnum
b = a
loopa >= 10
break (a < 10)
a /= 10
// modulo is in the d register after idiv
Line 705 ⟶ 707:
a += 48 // ASCII value for '0'
print(chr(a))
break
end
a = b
Line 723 ⟶ 724:
 
// N, "bottles of beer on the wall, "
print(x = bottle)
print(x += plural)
print(x += ofbeer)
print(x += wall)
print(x += sep)
break print(a < 10x)
 
// Retrieve and print the number
Line 733 ⟶ 735:
printnum()
 
// N, "bottles of beer.\nTake one down and pass it around,"
print(x = bottle)
print(x += plural)
print(x += ofbeer)
print(x += dotnl)
print(x += takedown)
 
print(nlx)
// "Take one down and pass it around,"
print(takedown)
 
// N-1, "bottles of beer on the wall."
stack -> a
a--
 
// Store N-1, used just a few lines down
a -> stack
printnum()
print(bottle)
 
// Retrieve N-1
stack -> a
 
// Write an "s" if the count is not 1
a != 1
print(plural)
end
// Write the rest
print(ofbeer)
print(wall)
print(dotnl)
 
// BlankWrite the rest + a blank line
print(nl)x = ofbeer
print(x += wall)
print(x += dotnl)
breakx += nl
print(sepx)
 
// Skip to the top of the loop while the counter is >= 2
Line 771 ⟶ 775:
a = 1
printnum()
print(x = bottle)
print(x += ofbeer)
print(x += wall)
print(x += sep)
print(l_nox)
 
// "1 bottle of beer."
a = 1
printnum()
print(bottle)
print(ofbeer)
print(dotnl)
 
// "Take one down and pass it around,"
print(takedown)
 
// "bottle of beer. Take one down and pass it around,"
// "no more bottles of beer on the wall."
print(l_no)
print(more)
print(wall)
print(dotnl)
 
// Blank line
print(nl)
 
// "No more bottles of beer on the wall,"
print(u_no)
print(more)
print(wall)
print(sep)
 
// "no more bottles of beer."
print(l_no)
print(more)
print(dotnl)
 
// "Go to the store and buy some more,"
print(store)x = bottle
print(x += ofbeer)
print(x += dotnl)
print(x += takedown)
x += l_no
print(x += more)
print(x += wall)
print(x += dotnl)
print(u_no)x += nl
print(more)x += u_no
x += more
print(x += wall)
x += sep
x += l_no
x += more
print(x += dotnl)
x += store
print(l_nox)
 
// "99 bottles of beer on the wall."
a = 99
printnum()
 
print(bottle)
// "bottles of beer on the wall."
print(plural)
print(ofbeer)x = bottle
print(wall)x += plural
print(dotnl)x += ofbeer
x += wall
x += dotnl
print(morex)
end
end
Anonymous user