Voting

Category

assembly language

Bookmarking

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

Language HLA

(High Level Assembly)

Date:10/04/05
Author:Nathan Baker
URL:n/a
Comments:2
Info:http://webster.cs.ucr.edu/AsmTools/HLA/index.html
Score: (3.28 in 60 votes)
program bottles;
#include( "stdlib.hhf" )

// HLA version of the "99 Bottles of Beer" song
// Cross-platform:  Linux console or Windows console
// Get HLA here:  http://webster.cs.ucr.edu/AsmTools/HLA/index.html

begin bottles;

mov( 99, cx );
forever

    if ( cx = 1 ) then

        stdout.puts( "One bottle of beer on the wall, one bottle of beer." nl );
        stdout.puts( "Take one down and pass it around, " );
        stdout.puts( "no more bottles of beer on the wall." nl nl );
        stdout.puts( "No more bottles of beer on the wall. No more bottles of beer..." nl );
        stdout.puts( "Go to the store and buy some more... 99 bottles of beer for the wall." nl);
        break;
    
    else;
    
        stdout.puti16( cx );
        stdout.puts( " bottles of beer on the wall, " );
        stdout.puti16( cx );
        stdout.puts( " bottles of beer." nl );
        stdout.puts( "Take one down and pass it around, " );
        dec( cx );
        if ( cx = 1 ) then
            stdout.puts( "one bottle of beer on the wall." nl nl );   
        else;
            stdout.puti16( cx );
            stdout.puts( " bottles of beer on the wall." nl nl );
        endif;

    endif;

endfor;

end bottles;

Download Source | Write Comment

Alternative Versions

Comments

>>  harrypiel said on 04/06/07 18:08:13

harrypiel quick, write one low-level before that frog barges in and spouts his usual crap again :p

>>  Nathan said on 05/17/07 22:29:45

Nathan Well, to really get "low-level", one would have to write it as a "unit" and write their own library routines. But here is an example that gets pretty close:

program bottles;

#include( "stdlib.hhf" )

?@nodisplay := true;

?@noalignstack := true;



// HLA version of the "99 Bottles of Beer" song

// Showing "Low-Level" or "Traditional" coding style

// Cross-platform: Linux console or Windows console



static



s00 :string := "One bottle of beer on the wall, one bottle of beer.";

s01 :string := "Take one down and pass it around, ";

s02 :string := "no more bottles of beer on the wall.";

s03 :string := "No more bottles of beer on the wall. No more bottles of beer...";

s04 :string := "Go to the store and buy some more... 99 bottles of beer for the wall.";

s05 :string := " bottles of beer on the wall, ";

s06 :string := " bottles of beer.";

s07 :string := "Take one down and pass it around, ";

s08 :string := "one bottle of beer on the wall.";

s09 :string := " bottles of beer on the wall.";



begin bottles;



mov ( 99, ecx );



mainloop:



cmp ( ecx, 1 );

jne singmain;



pushd ( s00 );

call stdout.puts;

call stdout.newln;

pushd ( s01 );

call stdout.puts;

call stdout.newln;

pushd ( s02 );

call stdout.puts;

call stdout.newln;

call stdout.newln;

pushd ( s03 );

call stdout.puts;

call stdout.newln;

pushd ( s04 );

call stdout.puts;

call stdout.newln;

jmp _exit;



singmain:



pushd ( ecx );

call stdout.puti32;

pushd ( s05 );

call stdout.puts;

pushd ( ecx );

call stdout.puti32;

pushd ( s06 );

call stdout.puts;

call stdout.newln;

pushd ( s07 );

call stdout.puts;

dec ( ecx );



cmp ( ecx, 1 );

jne morebottles;



pushd ( s08 );

call stdout.puts;

call stdout.newln;

call stdout.newln;

jmp mainloop;



morebottles:



pushd ( ecx );

call stdout.puti32;

pushd ( s09 );

call stdout.puts;

call stdout.newln;

call stdout.newln;



jmp mainloop;



_exit:



end bottles;

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: