Voting

Category

real language

Bookmarking

Del.icio.us Digg Diigo DZone Earthlink Google Kick.ie
Windows Live LookLater Ma.gnolia Reddit Rojo StumbleUpon Technorati

Language Parrot

Date:04/20/05
Author:Jonathan Scott Duff
URL:n/a
Comments:0
Info:http://www.parrotcode.org/
Score: (3.01 in 116 votes)
Here's a version of 99 bottles in Parrot assembler
(http://www.parrotcode.org/)

# parameterized bottles on the wall 
# Jonathan Scott Duff duff@pobox.com
#
# If arguments are given on the command line, the first is how
# many bottles (defaults to 99), and the second is of what
# (defaults to beer).

.macro print4 (a,b,c,d)
        print .a
        print .b
        print .c
        print .d
.endm

        set I0, P0[1]                   # how many
        set S0, P0[2]                   # of what?

        ne S0, "", BOTCHK
        set S0, "beer"

BOTCHK:
        gt I0, 0, N_BOTTLES             # make sure the count > 0
        set I0, 99

N_BOTTLES:
        .print4(I0," bottles of ",S0," on the wall,\n")
        .print4(I0," bottles of ",S0,",\n")
        print "Take one down, pass it around,\n"
        dec I0
        lt I0, 2, ONE_BOTTLE
        .print4(I0," bottles of ",S0," on the wall.\n\n")
        branch N_BOTTLES             # keep on drinking

ONE_BOTTLE:
        .print4(I0," bottle of ",S0," on the wall.\n\n")

        .print4(I0," bottle of ",S0," on the wall,\n")
        .print4(I0," bottle of ",S0,",\n")
        print "Take one down, pass it around,\n"
        .print4("No more bottles of ",S0," on the wall.\n\n", "")

        print "*Buuurrp*\n"
        end
# THE END

Download Source | Write Comment

Alternative Versions

Comments

Download Source | Write Comment

Add Comment

Please provide a value for the fields Name, Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.

Please don't post large portions of code here! Use the form to submit new examples or updates instead!

Name:

eMail:

URL:

Security Code:
  
Comment: