A82: PUSH/POP Contest Over...


[Prev][Next][Index][Thread]

A82: PUSH/POP Contest Over...




Thank you to all who participated in the PUSH/POP contest.  Here are the
top two winners:

3rd Place:
  Would have been Josh Cunningham, had he sent in his entry.

2nd Place:
  CrASH_Man wins second...barely.  His entry perfectly matched the person's
in 1st, but didn't follow all of the rules.

1st Place goes to (drumroll please):
...
...
...
...
...
  JL (Macross Software)!!!  The coding is superb!  Total optimization of
all the requested routines.  JL gets, not only his name in TAZM's credits
as winning 1st in this contest, but he gets to automatically beta test TAZM
before it's released!  Here is his perfect, winning entry of only 435 clock
cycles and 45 bytes!

| Mnemonic  | Commands                                          |CC|Bytes
+-----------+---------------------------------------------------+--+-----
| PUSH A    | dec sp\ push af\ inc sp                           |23|3
+-----------+---------------------------------------------------+--+-----
| POP A     | ex (sp),hl\ ld a,l\ pop hl                        |33|3
+-----------+---------------------------------------------------+--+-----
| PUSH B    | dec sp\ push bc\ inc sp                           |23|3
+-----------+---------------------------------------------------+--+-----
| POP B     | ex (sp),hl\ ld b,l\ pop hl                        |33|3
+-----------+---------------------------------------------------+--+-----
| PUSH C    | push bc                                           |11|1
+-----------+---------------------------------------------------+--+-----
| POP C     | ex (sp),hl\ ld c,l\ pop hl                        |33|3
+-----------+---------------------------------------------------+--+-----
| PUSH D    | dec sp\ push de\ inc sp                           |23|3
+-----------+---------------------------------------------------+--+-----
| POP D     | ex (sp),hl\ ld d,l\ pop hl                        |33|3
+-----------+---------------------------------------------------+--+-----
| PUSH E    | push de                                           |11|1
+-----------+---------------------------------------------------+--+-----
| POP E	    | ex (sp),hl\ ld e,l\ pop hl                        |33|3
+-----------+---------------------------------------------------+--+-----
| PUSH F    | push af                                           |11|1
+-----------+---------------------------------------------------+--+-----
| POP F     | ex (sp),hl\ ld h,a\ ex (sp),hl\ pop af            |52|4
+-----------+---------------------------------------------------+--+-----
| PUSH L    | push hl                                           |11|1
+-----------+---------------------------------------------------+--+-----
| POP L     | ex de,hl\ ex (sp),hl\ ld d,l\ pop hl\ ex de,hl    |41|5
+-----------+---------------------------------------------------+--+-----
| PUSH H    | dec sp\ push hl\ inc sp                           |23|3
+-----------+---------------------------------------------------+--+-----
| POP H     | ex de,hl\ ex (sp),hl\ ld e,l\ pop hl\ ex de,hl    |41|5
+-----------+---------------------------------------------------+--+-----
  Total:                                                        435|45


For those of you wondering why I bothered making this contest in the first
place, here is the reasoning:

1)  When TAZM loads, it looks for the data table containing all of the
information needed to assemble a file correctly.  Once found, it loads it
into memory and processes it.
2)  Part of that information sets up how the IDEAL mode part of TAZM is
supposed to work.  This includes saving and restoring registers, making
sure nothing is destroyed.
3)  This is where the contest came in:  Single registers might save more
clock cycles (in large IDEAL mode lines of code) than saving and restoring
only the 16-bit registers.  Some people might find the additional commands
quite useful.

There are several situations that I can think of where 8-bit reg. saving
and restoring is EXTREMELY useful.  Sprite routines, multiple depth
addressing ("ld hl,[a+b*[[de+[[hl]]]]]" would need 8-bit reg. saves and
restores to minimize clock cycles...this is an exaggerated example, but
gets the point across), and I'm sure there are a few others.  Also, IDEAL
mode will be able to discern when pushing and popping the 16-bit reg.
instead of the 8-bit will be the better option.  Again, congratulations to
JL and his superb job at winning this contest!


           Thomas J. Hruska -- shinelight@crosswinds.net
Shining Light Productions -- "Meeting the needs of fellow programmers"
                  http://www.shininglightpro.com/