February/March 1980, Issue 6

Page 24 of 38

The problem is to move the rings from X to Z (using Y) by transferring one ring at a time from one pole to another, such that a larger ring is never placed on top of a smaller ring.

A recursive solution is:–

LET Move N from A to C using B
Move N-1 from A to B using C
Take top ring from A to C
Move N-1 from B to C using A $)

The solution is then a call to ‘Move N from X to Z using Y’. The solution is easily seen to be intuitively correct – ‘Take’ represents the action of moving a single ring. We can easily see that for N rings, the routine nests to a depth N, and Take is called 2N times.

I have sent a program for inclusion in the INMC library that runs on a minimal NASCOM and neatly demonstrates the correctness of the routine. It moves one ring for each press of any key.

In the program BC, DE, HL points at the ‘poles’ and N is stored in A.

It is arranged that BC, DE, HL always point at the top ring of a pole.

This program is also an excellent demonstration of the power of the Z80, I am able to keep all the variables in registers, thus saving on both execution time and storage space.

SOFT SPOTS (continued from page 8)

However, we hear that ZEAP 2.0 has been produced by the producers of ZEAP 1, and that it is a great improvement over the original. It has many useful features such as sorted symbol table. Also it wilt be available in either RAM (at 1000H) or ROM (at D000H) versions. It obviously makes better use of memory to run ZEAP in EPROM. It runs in 4K.

Zeap 2.0 runs only with Nas-sys, since it was designed for Nascom 2 owners, but it will of course run on a Nascom 1 fitted with Nas-sys. A version called ZEAP 1.2 has similar features and runs under Nas-bug.

Details such as price, and trade in offers for owners of ZEAP 1 will be available soon, so please don’t write to us.

Just a simple little test (no prizes). What command can you enter to make Nas--sys un-resettable?

This is an OCR’d version of the scanned page and likely contains recognition errors.

Page 24 of 38