The aim is to fill the screen with pixels, and set all attributes to 255. the code is simple, and enclosed below for each language.
Spoiler: Forth is pretty good! I wonder if it was ever used to write commercial Spectrum software?
Results (Time taken):
basic : 72.50secs
forth : 1.50secs
assembly: 0.04secs
Disclaimer:
For each language, the most simple/obvious approach was chosen. The general intent was to compare languages by implementing a loop with 6912 iterations each setting a single memory location (although it's debatable that a Z80 LDIR instruction is exactly that).
There are ways each language's implementation could be optimised. E.g. the Z80 implementation would be far quicker with an unrolled loop of PUSHes into display memory. If the aim is to set all pixels to 1 and all attributes to White, then a quicker BASIC implementation might be 24x instructions PRINTing a string of 32 UDG characters (or INVERTed spaces) with INK, PAPER and BRIGHT set. But that might be considered cheating
CODE:
Code: Select all
; Z80 Assembly
; LDIR tstates = (21*6911)-5 = 145126 : approx 0.04secs
ld hl,16384
ld de,16385
ld (hl),255
ld bc,6911
ldir
ret
Code: Select all
( forth)
: FILLIN 23296 16384 DO 255 I ! LOOP ;
FILLIN
Code: Select all
10 REM BASIC
20 FOR i=16384 to 23295: POKE i,255: NEXT i
run