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 Terse

Date:04/20/05
Author:Anonymous
URL:n/a
Comments:2
Info:http://www.terse.com
Score: (2.79 in 34 votes)
\\\\\\\\
\ Beer \
\\\\\\\\
\
\   Program to print the lyrics to "99 Bottles of Beer on the Wall"
\   Runs under any version of DOS, 176 byte .COM file.
\
\   Written in TERSE by jim-neil@digital.net (Jim Neil).  TERSE is
\   an x86 specific language that has the same level of control as
\   assembly, with the look-and-feel and ease-of-use of a HLL.
\
\   For more information on TERSE, visit the TERSE website at:
\                      http://www.terse.com

main Group code,data;
Assume cs:main,ds:main;
O Equ <Offset main:>;

code Segment byte;
Org 0100h;

data Segment byte;
  ' m0 =" Bottle$";
  ' m1 =" of Beer on the Wall";
  ' nl =(10,13,'$');
  ' m2 =" of Beer", =(10,13);
  ' m3 ="Take one down and pass it around", =(10,13,'$');
data EndS;

Beer Proc;
  cx = 99;                      \ cx = number to do.
  {                             \ for cx = 99..1, do...
    dx = O(nl); ah = 9; !21h;   \ new line.
    al = cl; =.Bottles;         \ print number and "Bottle(s)".
    dx = O(m1); ah = 9; !21h;   \ output lyric line 1.
    al = cl; =.Bottles;         \ print number and "Bottle(s)".
    dx = O(m2); ah = 9; !21h;   \ output lyric lines 2-3.
    al = cl-; =.Bottles;        \ print number - 1 and "Bottle(s)".
    dx = O(m1); ah = 9; !21h;   \ output lyric line 4.
  }-.;                          \ loop till done...
  !20h;                         \ return to DOS.
Beer EndP;

\\\\\\\\\\\
\ Bottles \
\\\\\\\\\\\
\
\   Bottles prints "n Bottle(s)", controling plural based on the
\   value of n passed in al.
\
\   Entry Conditions:
\       al = n.
\       ah = Scratch;
\       dx = Scratch;
\
\   Exit Conditions:
\       ax = scratch.
\       dx = scratch.

Bottles Proc;
  =ax; =.BinDec;                \ print number of beers.
  dx = O(m0); ah = 9; !21h;     \ output "bottle".
  ax=; al - 1 ? <>              \ if not 1...
  { dl = 's'; ah = 2; !21h; };  \ make it plural.
  .=;                           \ and, return...
Bottles EndP;

\\\\\\\\\\
\ BinDec \
\\\\\\\\\\
\
\   BinDec prints a binary number (0-63h) in al to the screen
\   in decimal with leading zero supression.
\
\   Entry Conditions:
\       ah = scratch.
\       al = number to convert.
\       dx = scratch.
\
\   Exit Conditions:
\       ax = scratch.
\       dx = scratch.

BinDec Proc Near;
  "*; ax + '00'; dh = al;       \ split and convert, dh = save LSB.
  ah - '0' ? <>                 \ if MSB is non-zero...
  { dl = ah; ah = 2; !21h; };   \ then, output MSB.
  dl = dh; ah = 2; !21h;        \ output LSB.
  .=;                           \ and return...
BinDec EndP;

code EndS;
End Beer;

Download Source | Write Comment

Alternative Versions

Comments

>>  Cheryl said on 06/08/05 01:35:11

Cheryl This is the most awesome version of this program I've ever seen. The author of TERSE taught me everything I know about floating point one night after the greatest sex I ever had!!!

>>  Anthony Williams said on 07/25/06 19:14:07

Anthony Williams I don't know which is odder: the actual beer code or the first viewer comment. :-P

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: