What I know so far about ZX80 BASIC with 4K ROM
Posted: Tue Apr 04, 2017 1:52 pm
Sinclair ZX80 BASIC (4K ROM)
General I/O
The ZX80 BASIC has a limited intepreter which lacks many keywords and has only upper-case characters and an inversed version of those upper-case characters. Its character set is non-ASCII compliant, and generally will only read and write to the screen and cassette tape. There are no ways to draw to the screen without the enchanced ZX81 ROM unless one PRINTs to the screen, or works out where the DFILE (screen location) is in RAM and POKEs individual bytes to the screen. The recent ZXPand allows your ZX80 to read and write to an SD card, although this requires a special kit for the ZX80. An emulator such as EightyOne will simulate a real ZX80 with a ZXPand.
Program that prints
Sub routines
Variables
Like other 8-bit BASIC interpreters, the $ after a variable name declares a string and without it an integer is declared.
Loops
Or if you don't want to count up in steps of 1 then
Reading the keyboard
Please note there is no variant of INKEY$ or GET on the Sinclair ZX80 with 4K ROM.
Handling floating point numbers
Well, this is a tough one but let's assume that you want to print prices of items that are priced from £0.01p through to £327.67p, here is one way of doing it:
Basically, do them maths in integers, print your results divided by 100, pass your M variable to a string and shift the string left one character based on the value of M until you get to your pence. Or if M<10 then print a leading zero. I'm sure that you can think of a better solution to break the 327.67 barrier with this above symbolic listing.
Booleans
The ZX80 returns -1 if true or 0 if false. In order to do a not equals, one must use the following:
10 LET A$="1"
20 LET B$="2"
30 IF NOT A$=B$ THEN PRINT "NOT EQUALS"
40 IF A$=B$ THEN PRINT "EQUALS"
Animation
This is not really possible without using machine code as the screen is switched off whilst the BASIC interpreter computes. You will only get a static screen when waiting for a keyboard input with INPUT.
Color [SIC] text/graphics
The ZX80 has only a monochrome display
Obfuscating and minimising listings
The ZX80 does not accept BASIC minimisation or multi-statemented lines, like:
White spaces are automatically added when typing in your listing, and there are no keyword abbreviations. BASIC keywords are tokenized.
Standard input/output
This wasn't even a thing in 1980, so standard in could mean reading from the keyboard to a varibale or from a cassette player (or the virtual equivalent) - and stardard out could mean writing to the screen, or storing data to a variable, or recording data to a cassette tape (or again virtual equivalent).
Unconditional loops
Yes, the GO TO keyword exists.
Object Orientation
Err...
General I/O
The ZX80 BASIC has a limited intepreter which lacks many keywords and has only upper-case characters and an inversed version of those upper-case characters. Its character set is non-ASCII compliant, and generally will only read and write to the screen and cassette tape. There are no ways to draw to the screen without the enchanced ZX81 ROM unless one PRINTs to the screen, or works out where the DFILE (screen location) is in RAM and POKEs individual bytes to the screen. The recent ZXPand allows your ZX80 to read and write to an SD card, although this requires a special kit for the ZX80. An emulator such as EightyOne will simulate a real ZX80 with a ZXPand.
Program that prints
Code: Select all
10 PRINT "HELLO MUM"
Code: Select all
10 PRINT "HELLO ";
20 GO SUB 100
30 STOP
100 PRINT "MUM"
110 RETURN
Code: Select all
10 LET A$="HELLO "
20 LET B$="MUM"
30 PRINT A$;B$
40 LET X=100
50 LET Y=200
60 PRINT X,Y
Loops
Code: Select all
10 FOR I=0 TO 10
20 PRINT I,;
30 NEXT I
Code: Select all
10 LET I=0
20 PRINT I,;
30 LET I=I+2
40 IF I<10 THEN GO TO 20
Code: Select all
10 INPUT A$
20 PRINT "YOU TYPED THE FOLLOWING STRING:"
30 PRINT A$
40 INPUT A
50 PRINT "YOU ENTERED THE FOLLOWING INTEGER:"
60 PRINT A
Handling floating point numbers
Well, this is a tough one but let's assume that you want to print prices of items that are priced from £0.01p through to £327.67p, here is one way of doing it:
Code: Select all
10 INPUT M
20 LET M=ABS(M)
30 LET S$="."
40 PRINT M/100;S$;
50 LET R$=STR$(M)
60 IF M<10 THEN PRINT "0";
70 IF M>99 THEN LET R$=TL$(R$)
80 IF M>999 THEN LET R$=TL$(R$)
90 IF M>9999 THEN LET R$=TL$(R$)
100 PRINT R$
Booleans
The ZX80 returns -1 if true or 0 if false. In order to do a not equals, one must use the following:
10 LET A$="1"
20 LET B$="2"
30 IF NOT A$=B$ THEN PRINT "NOT EQUALS"
40 IF A$=B$ THEN PRINT "EQUALS"
Animation
This is not really possible without using machine code as the screen is switched off whilst the BASIC interpreter computes. You will only get a static screen when waiting for a keyboard input with INPUT.
Color [SIC] text/graphics
The ZX80 has only a monochrome display
Obfuscating and minimising listings
The ZX80 does not accept BASIC minimisation or multi-statemented lines, like:
Code: Select all
10 PRINT "HELLO MUM ";: GO TO 10
Standard input/output
This wasn't even a thing in 1980, so standard in could mean reading from the keyboard to a varibale or from a cassette player (or the virtual equivalent) - and stardard out could mean writing to the screen, or storing data to a variable, or recording data to a cassette tape (or again virtual equivalent).
Unconditional loops
Yes, the GO TO keyword exists.
Object Orientation
Err...