My attempt at building a Mandelbrot sets program for the ZX81 in Assembly.
PROG : 16509
D-FILE: 18082
VARS : 18875
E-LINE: 18876
STKBOT: 18881
STKEND: 18881
9999 means line number
PRINT means treat as KEYWORD P
1 REM /M**MBS MC***SLR/2022**
30208 LN
F?LN EúJ5 M.RND60RNDU.RNDE0RND:
CALL ) RNDLN ?CALL DEF PROC
LOOP DATA YZ5 LN TO DPOKE M2
RND63RNDU.RNDE0RND:Z) LN L
ERR MSGS :ERR MSGS ) ?LN 7
ERR MSGS M5RND66RNDYERR MSGS 5
SAVE M8RND69RNDöRNDVAL õ:JLN API
U5RNDDEF PROC GOSUB OFF6RNDU8RND
E9RNDLN ?CALL PRINT U2RND
DEF PROC LET GOSUB OFF3RNDLN L
ERR MSGS MERND6FRNDJ5 MBRND6C
RNDAT :/VAL LN NOSTALGIC CALL UB
RNDDEF PROC GOSUB OFFCRNDYCALL 5
?LN 7ERR MSGS PRINT U2RND
DEF PROC LET GOSUB OFF3RNDLN L
ERR MSGS MHRND6IRNDJ5 MKRND6L
RNDMNRND6ORNDö?VAL UKRNDELRND
DEF PROC GOSUB OFFLRNDLN L
ERR MSGS PRINT FAST UNRNDEORND
DEF PROC GOSUB OFFORNDLN L
ERR MSGS DEF PROC LOOP DATA
LPRINT LET LN 7ERR MSGS
DEF PROC LOOP DATA UERNDEFRNDLN
?CALL FAST PRINT UNRNDDEF PROC
GOSUB OFFORNDUKRNDELRNDLN L
ERR MSGS :RND) LN LERR MSGS
DEF PROC LOOP DATA UHRNDEIRNDLN
?CALL MNRND6ORNDLET LPRINT MKRND
6LRNDDEF PROC GOSUB OFFLRNDLN L
ERR MSGS PRINT FAST UNRNDEORND
DEF PROC GOSUB OFFORNDLN L
ERR MSGS DEF PROC LOOP DATA
LPRINT LET LN ?CALL :INKEY$)
LN $CALL AT AND 1PIASN 1PIYñM3
PI/!õTAB ?INKEY$JM3PIAT VAL õY/)
DEF PROC LN FPIAT VAL õY-±
DEF PROC LN FPIUBRNDECRND:Z)
LN ?CALL MBRND6CRNDAT $TAB
ERROR INKEY$VAL U8RNDE9RND:Z)
LN 7ERR MSGS M8RND69RNDAT VAL õ:
JLN 4PIAT õTAB :INKEY$5;;LN
ELSE CALL U.RNDE0RND:CALL ) (LN
?CALL M.RND60RND: ) ?LN $CALL
AND LEN RNDLN ?CALL ?WRNDñJM3PI
/õYñM3PI?ACS ?""CHR$ RNDLIST ?
ACS ?""CHR$ KLIST - ?ACS ZCHAR K
ò-ñ?ACS ZDEF PROC Kô?ACS INT
WHILE STR$ E£RND7?RC÷)5 ;X4
UNPLOT ) WHEN ;SGN U3PIBASN 9
CALL ?RC(XC,XC8INPUT ÷?TAN SIN ?
TAN ACS ·?TAN INT ?TAN ACS ??
TAN NOT ?TAN ACS *?TAN ?RC(XC,XC
8INPUT ÷?TAN ·?TAN ACS SIN ?TAN
??TAN ACS INT ?TAN *?TAN ACS
NOT ?TAN OR LN ERROR ?Kò OR
TAN INT COPY 6CLR STACK CALL
LN NOSTALGIC CALL ECLR STACK
CALL F?P4PAUSE TAN E£RND7J:/ö4?7
(UNPLOT 7$4PLOT TAN CHAR NEW ?W
IF LCALL ?PRINT LN 7ERR MSGS AT
INPUT COS INPUT COS DEF PROC
ACS SNEW ?LEN :(KòJTAN ?PLOT ?·
TAN ?PZ""?NEW ?W?PAUSE HCALL ?N
""?STAN CHAR NEW ?4ó?FOR TAN W
IF ?ERR MSGS ?NEW ?ASN ?
ERR MSGS WIF COS CALL ?DIF ;
ERR MSGS LN CLR STACK ERR MSGS C
.SQR VAL LN <ERR MSGS ACS 4
GOSUB RESEQ SGN ?SQR NEW ?
RETURN WACS 1SQR 7TAN ?NEW ?
RETURN ACS 0ACS 1SQR G""8""WTAN
PLOT ?5 TAN LN CLR STACK
ERR MSGS CNSQR VAL LN <ERR MSGS
)DEF PROC Y /CHAR GOSUB DELETE
SGN ?SQR ?PKLCOS ?·PRINT ?XC>
ACS 5ACS (GOSUB CLR STACK ABS R
ERR MSGS ACS 5ñ GOSUB DRAW ¸·
WHILE LET ?3TAN ?GOSUB DELETE 4ó
NEW TAN ñ KCHR$ INPUT WHILE J
+?3=LINE ?/ASN DACS ñ*)COS Kö
GOSUB ERR MSGS ACS ùINKEY$FOR R3
RETURN >**?TAN ?P4IF LCRUN W·4
NEXT ?N?4òSCOS FTAN ñ RACS ,
ACS .ACS /ACS ;X4PRINT TAN CHAR
?INPUT DEF PROC ???CALL INPUT
??CALL CHAR ?NEW CCHAR NEW ?C
PROTECT WIF )DPOKE ?NEW ?
DEF PROC COS WIF COS CALL ?NEW ?
±CHR$ ZKòJTAN RETURN ?S÷?PLOT ?5
TAN CNEW ?CPRINT ERR MSGS
EDIT FAST STR$ LN BDPOKE JACS 8
FOR AT GOSUB DRAW EXP AT ùEXP
3AT ?COS ZACS 0ACS 1WW·CABS 3X
TAN ?NEW ?COS WIF ,DPOKE JTAN ?P
?""?NEW ?4ôXLINE ?TAN WIF 8
DPOKE ?TAN ?FOR TAN ?-
NOSTALGIC PUSH ·SN·SQ·ST·SW·SZ·S
PI·SDPOKE ·S ?NEW RETURN ·SEDIT
·S·SEXIT ·SINDENT ·SDATA ·SUSER
·SBREAK ACS .***DUP TAN D?KòùºD?
KòùºD?KòùºD?KòùºD?KòùºD?KòùºD?Kò
ùºWHILE ?NEW RETURN D?KóùEXP D?
KóùEXP D?KóùEXP D?KóùEXP D?Kó
ùEXP D?KóùEXP D?KóùEXP D?Sú
ACS .READ SQR ùSQR 0""=TAN =ACS
.READ SQR ùSQR 0TAN DEF PROC
FOR YZ5 CHAR D·?*?CHAR NEW ?
ASN ?ERROR WIF ³ERROR ?NEW ?4ôX
LINE ?TAN WIF ?ERROR ACS T?NEW ?
LEN Z)KòJTAN RETURN ?S÷?PLOT ?5
TAN R: GOSUB DELETE K£XCOS ;D
ACS )£GOSUB DELETE Kñ$VAL PRINT
LN TERROR SGN AT ºPAUSE OERROR X
LINE ?CNEW ?CTAN J<READ Y ,
WHILE 3XCHAR ?LN DATA ERROR ACS
)VAL LN DATA ERROR ACS )D?;¸
LPRINT BREAK PUSH ñ ?GOSUB
DRAW TAN LN NOSTALGIC ERROR LN
ONERROR LN DPEEK ERROR ACS )D?
COS ;¸**GOSUB DELETE /TAN ?NEW ?
CUWIF ?ERROR JTAN ?NCOS ?FOR
TAN ?P?""?NEW ?C9WIF LERROR ?
TAN
2 RAND USR VAL "16514"