Hugi Size Coding Competition 12 - The Prime Number Finder Compo

Welcome!

After a recreational break we resume the competition series. Originally
it had been planned to make the objective of the task to write the
smallest possible analogue clocks, but we didn't manage to agree on the
exact rules. We already had a beta rules set and a test suite, but then
some people raised the opinion the rules set was too complex. Thereupon
another poll was held and a tasks was chosen that did not afford an
extensive rules set: prime numbers finding.

Basic Outline

Your program gets a decimal value, n, via the command line. It then has
to find the n-th prime number and output it to stdout. As always, your
program has to be written in x86 Assembler, and as the competition is
about size optimizing, it has to be as small as possible to win.

Steps

1. An entry reads a decimal number from its command line.
   * The number will be in the range of 0...1000000 decimal
     (hex 0...F4240).
   * The number will always be a positive integer or 0 (zero).
   * An empty commandline should be treated as 0 (zero).
   * You can assume that the commandline will be always either empty or
     contain a valid number.
   * You can assume that there are no extra zeroes in the commandline
     parameter (i.e. 0012 is not valid, only 12 is), and that there is
     only one whitespace between "entry.com" and the commandline
     parameter.

2. Calculate this n-th prime number, where:
   * n = 0 => null: 0
   * n = 1 => 1st prime number: 2
   * n = 2 => 2nd prime number: 3
   * n = 3 => 3rd prime number: 5
   * n = 4 => 4th prime number: 7
   * n = 5 => 5th prime number: 11
   * n = 6 => 6th prime number: 13
   * n = 7 => 7th prime number: 17
   * ... etc ...
   * n = 1000000 => 1,000,000th prime number

3. Print the n-th prime number as decimal to STDOUT.
   * The decimal number is padded to 10 digits with "0"s.
   * There is a normal newline character pair 13, 10 decimal (hex 0D 0A)
     after the decimal number.
   * An entry ONLY prints the n-th prime number, not all the primes
     before it, and/or those after it.
     - e.g. ENTRY 6 would give: 0000000013
     - e.g. ENTRY 0 would give: 0000000000
     - e.g. ENTRY would give: 0000000000

4. Terminate cleanly.

Time Limit

The program must not take longer than 90 seconds on my computer (P3, 600
MHz).

Test Suite & Example Program

An example program and a test suite are included in this pack. Both have
been made by meph (Guido Hahn). I will use the same test suite in order
to check your entries.

Keep checking the Hugi Size Coding Competition website for updates of
the test suite.

Schedule

Aug 14, 2000               Compo starts.
Sep 30, 2000 11:59 pm CET  Deadline for entry submission.
Oct 01, 2000               Entries and beta results will be released.
                           Start of Public Judgement.
Oct 07, 2000 11:59 pm CET  End of Public Judgement.
Oct 08, 2000               Final results will be released.

Entry submission

Submit your entries only to Adok (hugi@netway.at). As a neutral
organizer he will test your entry and update the preliminary results on
the website.

You can send updates of your entry as often as you want.

Nobody but Adok will get to see any entry before the submission
deadline. After the deadline all entries will be released at the website
together with the 'beta' results. In this week, the 'public judgement'
week, people can discuss and object to entries which seem not to match
the rules in the Discussion Board.

Prizes

There are no materialistic prizes. The Hugi Size Coding Competitions are
designed to appeal to the fun factor in all you creative coders out
there. You will recieve the satisifaction, fame and honour of seeing
your name up there in lights with some of the best code optimizers in
the world.

The 30 best competitors will gets points and will be listed in the World
League Table of Assembly. Reaching a good place in the compo and in the
World League table of 80x86 size-coders is an excellent visting-card, a
recommendation of your skills, your imagination and your enjoyment at
pushing the boundaries of 80x86 coding.

Closing Words

Credits for this text: TAD (steps) and Adok (rest). Thanks to meph for
the test suite and example program. Also thanks to all the other people
who were involved in the discussion of this task.

We're looking forward to your participation!

Adok/Hugi (hugi@netway.at) & co.
