
        h u g i   s i z e   c o d i n g   c o m p e t i t i o n   # 4

                         infofile by adok^hugi - v1.0


Hi all.

Now  let's  come  to  the fourth compo  in  this  Hugi Size Coding Competition
Series.  This  time  your task is to  write  an  expression evaluator, like we
already  discussed  it on the compo  mailinglist before the beginning of compo
#3.

Sorry  for  the  quite long delay of this  info  file.  The reason was that we
hadn't  fixed  all  details of this  compo  (floating points or integers? also
exponents  and square roots? etc.) when  VaVa sent me his expression evaluator
as an example program for this compo.

It took some time till the exact rules were settled and VaVa's example program
was  adjusted  to  them. In the last  minute,  another bug was found in VaVa's
program. So Guillermo Sais and INT-E quickly coded their own example programs,
and we fixed the bug in VaVa's program.

Well, here we go now!

--------------------------------- [the task] ---------------------------------

Thanks go to IOPL who was the first to suggest this task.

Your task is to write a command-line based, mathematical expression evaluator.
that means for example, that if you call the expression evaluator this way:

entry (3+2)*5

It will output to stdout (i.e screen or, if redirected, to a file):

25

and exit.

As always, the smallest program wins.

---

Your  program works only with SIGNED LONG (32bit) INTEGERS. If the result is a
value  with  decimals,  the decimal digits  will  be  omitted. (For this short
compo, caluclating with floating-point values would be too expensive.)

In case of doubt, the usual rules of algebra apply.

Your program has to understand:

- the following operators: + - * /
- the parantheses: ( )
- unary minus: e.g. -2, -(2+3), 2*(-3), (-3)*2
- unary plus:  e.g. +2, +(2+3), 2*(+3), (+3)*2

The  usual rules apply: first evaluate the expressions in brackets, then * and
/, then + and -.

The sign applies to the next number. Example: 2-0+1:
From the left to the right, you calculate 2-0+1 = 3.
From the right to the left, you calculate 1-0+2 = 3.

Mul/Div-expressions:
Since we calculate with integers only, it is necessary that we calculate from
the left to the right. For instance: 4*5/2 = (4*5)/2 = 20/2 = 10.
On  the  other hand, from the right to the  left: 4*(5/2) = 4*(2.5) = 4*2 = 8.
That would be wrong.

If  the user forgets to set enough  parantheses, the program can not calculate
the result correctly.

After  calculating,  the  program  shall output  ONLY  the  result  to screen,
converted  to characters, and exit. The output shall work like in the included
example  programs. That means: No + sign in front of a positive result, and no
0's or other characters in front of the first digit.

For the output, a routine or interrupt has to be chosen that makes it possible
to redirect the output to a file when the user calls the program with

entry <expression> > <filename.ext>

For example, Interrupt 21h Function 2 can do that.

---

Some details:

Nesting Level: Only a maximum of six parantheses levels has to be processed.

If an overflow or underflow occurs, the program cannot compute correctly.

You  have  to  use the 64 bits division  opcode,  which takes one 64 bit value
(edx:eax) and one 32 bit value. Otherwise problems would arise if you divide a
high number by a small one, e.g. 5000000/2.

Since a division by 0 automatically exits the program, it doesn't have to care
about that.

Expressions like "5*(-2)" or "(-2)*5" have to be processed correctly.

The  program  need not be able to  process things like "1-+-2" (multiple unary
operator without parantheses) -> that's faulty input.

In the input, no spaces will be used between numbers and operators.

Time limit: The calculation time must not exceed one minute on a Pentium 200.

Furthermore, your entry must...
                            ...have the filename entry.com.
                            ...work in Windows95 dos box.
                            ...work at least on my PC.
                            ...exit without crashing when regular input.
                            ...not depend on its filename.
                            ...not use any extern files.

All instructions till .586 (Pentium) can be used.

  !! Please check if your program fits to all rules before submitting it !!

You  can  use  test.bat  for easy  checking  if  your program works correctly.
test.bat  starts your program with some example caluclations and compares them
with the correct results. I will check your entries with the same program.

(In  theory,  it's  possible  write programs that only produce correct results
for the calculations in test.bat. Therefore I mentioned  all  these  rules  so
that  you  can  also test the programs with other expressions according to the
rules.)

--------------------------------- [example] ----------------------------------

The  example  programs by INT-E and Guillermo  Sais are attached together with
their  Pascal/C sources in the file  examples.zip.  They show exactly how your
program should work.

-------------------------------- [submission] --------------------------------

You have to send me

() the sourcecode of your entry
() the executable of your entry

so that I can analyse and evaluate your entry.

The sourcecode should be able to be assembled with tasm, nasm or a386.

Send your entries to:
                         hugi@netway.at

It  would be best if you could send me  your entry as early as possible. Then I
can  inform  you  about bugs, if I find  them,  and you have enough time to fix
them.  Attention: if I find no bugs,  this doesn't automatically mean that your
entry is bug-free.

You can submit updates to your entries all the time till the deadline.

Entries  that do not agree with these rules will be disqualified. Their coders
will  be informed about the mistake, and they can re-submit a bugfixed version
unless the compo is over.

If  the  compo  is over and a hidden  flaw  is  found in one of the originally
accepted  entries  by  the jury or the  public,  the  best older entry of this
competitor that fits all the rules will qualify instead.

------------------------------- [pre-results] --------------------------------

The  current pre-results of this compo  will be released on the compo-homepage
and always updated after receiving a new entry. In this way I hope to make the
compo exciting.

compo-homepage url:
                         http://home.pages.de/~hugi-compo/

--------------------------------- [schedule] ---------------------------------

Sep.    4, 1998                   compo starts
Oct.   16, 1998, 11:59 pm cet     deadline for entry submission, compo is over
Oct.   17, 1998                   entries and beta results will be released,
                                  start of public judgement
Oct.   23, 1998, 11:59 pm cet     end of public judgement
Oct.   24, 1998                   final results will be released

----------------------------- [public judgement] -----------------------------

After  the  entries and the beta results  will  have been released, the public
judgement  starts. During this week you can  discuss and object to the entries
that   seem   to  break  some  rule.   Please  send  your  objections  to  the
compo-mailinglist (see below). The jury (see the next paragraph) will check if
your  objections  are according to the rules.  If  they are, the invalid entry
will be disqualified.

--------------------------------- [the jury] ---------------------------------

All entries will be checked by me. Nobody else will get to see them before the
deadline.   After   the  deadline  all  entries   will   be  released  at  the
compo-homepage  together  with  the beta results.  In  this  week, the 'public
judgement' week, people can discuss and object to the entries.

To check whether the objections are right - and for no other purpose -, a jury
will  be formed, consisting of me and two other people that I'll select during
the compo.

Jury  members  have  to  act  objectively.  They  can't  change  any  rules or
disqualify  entries by themselves. Therefore  it's no difference whether these
people take part in the compo, too, or not.

The juries of the previous compos consisted of:

() compo 1: altair, cydo, adok
() compo 2: nop, cydo, adok
() compo 3: maxx, guillermo sais, adok

---------------------------------- [prizes] ----------------------------------

I'm sorry if i disappoint you, but there are no material prizes. Everything is
just  a  matter of honor and fame.  Moreover, the 30 best competitors will get
points  and be listed in the 'world  league table of assembly' situated at the
compo-homepage.  Reaching  a good place at a  compo and even more in the world
league  table of assembly is a good visiting-card and recommendation for every
competitor!

------------------------------- [mailinglist] --------------------------------

A  mailinglist was created at the beginning  of June. Its purpose is to inform
about  new  compo and provide a discussion  forum  for the competitors. At the
moment there are about 110 subscribers.

To  subscribe send a mail  to hugi-compo-subscribe@makelist.com. You'll get an
automatically  generated  mail which confirms  your  subscription within a few
hours.  Then  you  start  getting the mails  the  others  have  posted to this
mailinglist.

Mails for the list have to be sent to hugi-compo@makelist.com.

If you want to unsubscribe, send a mail to hugi-compo-unsubscribe@makelist.com

--------------------------------- [contact] ----------------------------------

send your entries to:
                                         hugi@netway.at        [adok/hugi]
compo-homepage
(pre-results, world league table, etc.)
                                         http://home.pages.de/~hugi-compo/
subscribe to the mailinglist:
                                         hugi-compo-subscribe@makelist.com

------------------------------------------------------------------------------

Thanks for reading this info file! I'm looking forward to your participation!

                                              - adok^hugi, September 4th, 1998

Special  thanks to  INT-E, Guillermo Sais, Maxx, IOPL, Stefan, Carsten, Klaus,
VaVa and the other mailinglist subscribers.
