Primes by Trial Division - Sinclair ZX-80 BASIC

20 August 2016

On the ZX-80, one must use LET for assignment, pause when the screen is "full", and do without either INTeger or MODulus! So this version must rely on the use of integer-only division results for calculating a remainder explicitly and use PRINT; so that all the results fit on the screen at once.

Trying to use FOR/NEXT as the Applesoft version did results in stack exhaustion after a handful of results. Since there is no other kind of loop available in ZX-80 BASIC, we must make do with only GO TO—one final peculiarity (though irrelevant) is the tokenization of GO TO, where other BASICs use GOTO.

10 DIM P(99)
20 LET C=2
30 LET F=0
40 PRINT C;
50 LET P(F)=C
60 IF F=99 THEN GO TO 160
70 LET F=F+1
80 LET C=C+1
90 LET I=0
100 LET R=C-(C/P(I))*P(I)
110 IF R=0 THEN LET I=F+1
120 IF I>F THEN GO TO 80
130 LET I=I+1
140 IF I=F THEN GO TO 40
150 GO TO 100
160 STOP

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026

Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Primes Benchmark Source

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Primes Benchmark Results

Other BASICs

Applesoft BASIC

Atari 2600 BASIC

BBC BASIC

Commodore BASIC

DRI Personal BASIC

HP BASIC/V

IBM 5100 BASIC

IBM PC BASIC

PICK/BASIC

Rocky Mountain BASIC

Sinclair ZX80 BASIC

Spectravideo Compumate

TI 99/4 BASIC

TRS-80 Level 1 BASIC

V-Tech Laser 50

VAX BASIC

Structured BASIC

Amiga BASIC

Dartmouth True BASIC

Microsoft QuickBASIC

Microware Basic09

Topaz S-BASIC