Some quality time with your 8800c (or clone, or genuine)

Discuss construction, troubleshooting, and operation of the Altair 8800c computer

Some quality time with your 8800c (or clone, or genuine)

Postby BillO » March 25th, 2022, 2:54 pm

Here is a little program I originally wrote back in the late 80's on VAX BASIC.

It a solution to the Towers of Hanoi for an arbitrary number of disks that utilizes the concept of recursion. The solution it generates is the absolute minimum number of moves for a given number of disks. It was a little different when written in VAX BASIC because VAX BASIC supports local data spaces for subroutines and hence allows for true recursion. I re-wrote it for MBASIC and implemented the recursion through using a temporary variable and shifting values around before and after the recursive calls (to line 190).

In the following code T is the temporary variable. S is the source tower, D is the destination tower. See if you can figure out how it works.. and have some fun.

Code: Select all
10 FOR X=0 TO 20:PRINT:NEXT X
20 PRINT "*********************"
30 PRINT "*                   *"
40 PRINT "*  TOWERS OF HANOI  *"
50 PRINT "*                   *"
60 PRINT "*********************"
70 PRINT
75 K=0
80 INPUT "NUMBER OF DISKS";J
90 S=1:B=2:D=3:N=J+1
100 GOSUB 190
105 PRINT K;" MOVES REQUIRED"
110 END
190 N=N-1
200 IF N=1 THEN GOSUB 300:GOTO 240
210 T=B:B=D:D=T:GOSUB 190:T=D:D=B:B=T:N=N+1
220 GOSUB 300
230 T=S:S=B:B=T:GOSUB 190:T=B:B=S:S=T:N=N+1
240 RETURN
300 PRINT "MOVE";S;"TO";D;
305 K=K+1
315 PRINT
320 RETURN
BillO
 
Posts: 136
Joined: November 11th, 2020, 6:29 am

Re: Some quality time with your 8800c (or clone, or genuine)

Postby AltairClone » March 26th, 2022, 11:06 pm

Cool! I used to love writing recursive programs to solve puzzle games.
AltairClone
Site Admin
 
Posts: 632
Joined: April 5th, 2013, 10:55 am

Re: Some quality time with your 8800c (or clone, or genuine)

Postby Wayne Parham » March 27th, 2022, 10:58 pm

That's very cool, Bill. I'm anxious to run it, as well as the other "Hanoi-2" version you uploaded recently.

Speaking of VAX BASIC, find below an archive of BASIC programs. They're mostly David Ahl's 1970s programs (which is why I referenced VAX BASIC) but I modified them to run using Microsoft 8K BASIC. I tested all of them on a Synertek System's Sym-1, which is a 6502 machine from the 1970s. It's a lot like the KIM-1. The 8K BASIC for the 6502 had no trig functions, so a few programs have a call to a machine-language patch that provides trig. Those can be commented out when running on the Altair. But other than that, they should all run. I've tested a few of them on my Altair clone like Conway's Life program, Buzzwords, Poetry, Eliza, etc.

I've played around with the C compiler, but haven't done much beyond "Hello World" kind of stuff. I had hoped to port some C code that runs on my Sym-1, but the K&R compiler on the Altair is just a little too old. I didn't use many modern constructs in the Sym-1 code - after all, it's a 6502 and it's pure C code - but it does use some ANSI C functions and that's not far enough back on the Wayback Machine. So I need to roll my sleeves up and look into that a little more later.

Beyond that, I'm putting together an 8800c, with parts from Mike. So after a few weeks or a month or two, I should be able to save and load files on floppy, just like the good 'ol days.
Wayne Parham
 
Posts: 240
Joined: March 18th, 2022, 3:01 pm

Re: Some quality time with your 8800c (or clone, or genuine)

Postby BillO » March 28th, 2022, 6:23 am

Thanks Wayne. It should be fun going through those!
BillO
 
Posts: 136
Joined: November 11th, 2020, 6:29 am


Return to Altair 8800c

Who is online

Users browsing this forum: No registered users and 6 guests

cron