Personal Computer World magazine: an 8080 puzzle and "Z80 is dead"

From: Jim Battle <frustum_at_pacbell.net>
Date: Sat Aug 4 03:07:52 2001

At 10:10 AM 8/3/01 +0100, Paul Williams wrote:
>...
> Here is a little puzzle to test your readers' 8080 machine ingenuity:
>
> "Imagine you possess an 8080 with 64K bytes of read/write memory
> which you want to clear. Write a program that sets all 65536 bytes
> to zero."

         ORG 0010h
         LXI SP, 0000h
         LXI H, 0000h
         PCHL

         ORG 0000h
         PUSH H
         PCHL

start running at 0010h. It sets SP and HL to 0000h, then jumps to 0000h.

The code at 0000h pushes HL; the first time, it cause 0FFFFh and 0FFFEh to
be written to 00h.

PCHL is a one byte opcode that jumps back to 0000h. I guess RST 0 would
work too.

Eventually, 0003 and 0002 are written, so far so good. Then in the last
iteration, 0001 and 0000 are written. The final PCHL may or may not
execute, depending how the 8080 overlaps fetch and execute for that pair of
instructions. Either way, it works.

Everything after that is NOPs, and PC just goes around and around...

It took about 60 seconds to figure out this puzzle. It took about 10
minutes to write it up and make sure it works.

Next!

-----
Jim Battle == frustum_at_pacbell.net
Received on Sat Aug 04 2001 - 03:07:52 BST

This archive was generated by hypermail 2.3.0 : Fri Oct 10 2014 - 23:33:31 BST