Pascal for ZX81

Discussion about ZX80 / ZX81 Software
christoph
Posts: 14
Joined: Sun Mar 27, 2022 1:32 pm
Location: Oschersleben

Re: Pascal for ZX81

Post by christoph »

So on the annual team Meeting this year I got the compiler to work with a ZXpand and a cassette. Interesting is, that it uses the ROM plot routine and is as slow as BASIC when plotting. If you type in the Sieve of Erathostenes, then the program will need about 8 to 10 Secs to calculate everything. Note: When writing the program in BASIC and compiling it with MCoder II, then the program takes about 1/2 of a second to calculate all numbers...

Also try the following program:

Code: Select all

PROGRAM FIB(INPUT,OUTPUT);
VAR I,N: INTEGER;

FUNCTION FIB(N:INTEGER);
BEGIN
  IF N=0 THEN FIB:=0;
  IF N=1 THEN FIB:=1;
  IF N>1 THEN FIB:=FIB(N-1)+FIB(N-2);
END;

BEGIN
   WRITELN("HOW MANY NUMBERS?");
   READ(N);
   FOR I:=1 TO N DO
     WRITELN(I,"TH FIB.NUM IS ",FIB(I));
END.
So with recursion it seems to be sadly terribly slow. But iterative it is extremely fast.
Sadly I did not manage to get the full 32k in the ZXpand+ to work. I poked the RAMTOP with POKE 16389,192 like the manual said and then typed CONFIG "M=H" and then started the Compiler. In edit mode it gives me ERROR=1 meaning: RAMTOP is set wrong?? Has someone a hint for me?

Greetings
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: Pascal for ZX81

Post by Moggy »

How fast is Pascal with this Fibonacci program?
Toddy Forth-79 will work out print and scroll the first 46 numbers of the sequence in about 3 seconds in slow mode and about 1/2 a second in fast mode.

Just curious about the speed difference between the 2 programs.
christoph
Posts: 14
Joined: Sun Mar 27, 2022 1:32 pm
Location: Oschersleben

Re: Pascal for ZX81

Post by christoph »

Hey Moggy, sure I will test it tomorrow (hopefully :) ) and then post the results here :)
Greetings
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Pascal for ZX81

Post by mrtinb »

christoph wrote: Sun Mar 27, 2022 6:43 pm So on the annual team Meeting this year I got the compiler to work with a ZXpand and a cassette.
So you only use the ZXpand for 32k RAM, and use the cassette as file storage?
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
christoph
Posts: 14
Joined: Sun Mar 27, 2022 1:32 pm
Location: Oschersleben

Re: Pascal for ZX81

Post by christoph »

Yes, sadly I have to use the Cassette as a File Storage (but strangely with the right cassette this works just perfect, some compiled code reads in in about 3 - 4 seconds) Pascal itself is loaded from SD and so this loading time is skipped. I still wonder, why the 32k do not work properly..
christoph
Posts: 14
Joined: Sun Mar 27, 2022 1:32 pm
Location: Oschersleben

Re: Pascal for ZX81

Post by christoph »

Hey Moggy,
so today it did some testing and Partial Pascal needs for the Iterative Method for calculating 40 fibonacci numbers about 10 Seconds (together with printing them ... even the numbers exceed 16 bit but this is not the problem), but with the recursive Method you get the following problem: After 12 Minutes I stopped to test it, because it only got to the 22th Fibonacci number :roll: Alright Recursion in pascal is somewhat doomed...

With this in mind, we will see two potential problems: Writing a useful program in Partial Pascal is now limited. Take for example the Game of Go. I once wrote an algorithm to determine the Liberties of a group and did it iterative (with a Stack) and recursive. Because of the Size of the board (19x19) the Stack has to be rather large and we have about 4k of Program space, even if you can compile the code, then you get a problem with memory space... now if you do it recursive then you get out of time :mrgreen: ....
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: Pascal for ZX81

Post by Moggy »

Thanks for this Christoph. :D

It is a shame that partial Pascal cannot do more because I think it is good to have other languages for the Zeddy and try a different way of working.

It is also a shame you cannot access the full 32 k of the ZXpand which for example H4th can do ( although it still uses tape load and save. )
Hopefully someone with the skills to do it could take it forward like Kmurta and Roganjosh have done with Forth79 and make it a really useful language.


Thanks again for taking timeout with this.

Moggy.
User avatar
Vorticon
Posts: 69
Joined: Tue Mar 01, 2022 1:14 pm

Re: Pascal for ZX81

Post by Vorticon »

christoph wrote: Mon Mar 28, 2022 10:45 am Take for example the Game of Go. I once wrote an algorithm to determine the Liberties of a group and did it iterative (with a Stack) and recursive. Because of the Size of the board (19x19) the Stack has to be rather large and we have about 4k of Program space, even if you can compile the code, then you get a problem with memory space... now if you do it recursive then you get out of time :mrgreen: ....
Did this evolve into a full Go program? Was it for the Zeddy?
christoph
Posts: 14
Joined: Sun Mar 27, 2022 1:32 pm
Location: Oschersleben

Re: Pascal for ZX81

Post by christoph »

Vorticon wrote: Tue Mar 29, 2022 1:37 pm
Did this evolve into a full Go program? Was it for the Zeddy?
Hello Vorticon,
sadly no... I got it somewhat working under Turbo Pascal (together with a stupid AI). So the Go program itself is more of a Goban for two players, I still have the Source :) and also I still trying to build up a working Go program (but this is all like my other projects in a big bag and comes sometimes up)..
Greetings
User avatar
Vorticon
Posts: 69
Joined: Tue Mar 01, 2022 1:14 pm

Re: Pascal for ZX81

Post by Vorticon »

christoph wrote: Hello Vorticon,
sadly no... I got it somewhat working under Turbo Pascal (together with a stupid AI). So the Go program itself is more of a Goban for two players, I still have the Source :) and also I still trying to build up a working Go program (but this is all like my other projects in a big bag and comes sometimes up)..
Greetings
GO is a super hard game to create an AI for. Google did create a powerful AI for it using self-learning https://youtu.be/WXuK6gekU1Y but that might be a bit much for the Zeddy ;)
Post Reply