Z1a - BASIC Quick Reference
The BASIC editor is similar to those on 8-bit Sinclair machines. Program lines are entered or edited at the bottom of the screen. In the program listing, the >
indicator shows the current line, and can be moved with the cursor up/down keys. The Z1a's EDIT key is used to retrieve the current line for editing.
Each program line should start with a line number between 1 and 9999. A program line without a line number will be executed immediately on entry.
Each program line consists of one or more statements separated by :
, and starts with one of the keywords listed below.
You can play with Z1a BASIC in the emulator.
Keyword | Description |
---|---|
CIRCLE x,y,r | Draws a circle centered at x,y with radius r. |
CLEAR | Removes all BASIC variables from memory. |
CLS | Clears the screen. |
COPY | Not yet implemented. |
CURSOR n | As a keyword, sets the current cursor colour to n. |
DATA | Not yet implemented. |
DELETE f | Deletes the file named f from the IDE device. |
DIR | Lists the files on the IDE device. |
DOKE m,n | Writes a 16-bit value n to memory addresses m and m+1. |
DRAW x,y | Draws a line from the last point plotted, x pixels to the right and y pixels down; negative numbers draw left or up. |
FILL | Not yet implemented. |
FOR i=x TO y | Starts a loop; statements between here and NEXT will be executed repeatedly, with i starting at x, and increasing by 1 each time until it reaches y. |
FOR i=x TO y STEP z | As above, but i increases or decreases by z each time round the loop. |
FORMAT s | Formats the IDE device and gives it the name s. This will delete all files currently stored on the device. |
GOSUB n | Diverts execution to program line n, until a RETURN statement is encountered. |
GOTO n | Diverts execution to program line n. |
HELP | Not yet implemented. |
IF c THEN xxx | If c is not zero, execute the program statements xxx. |
IF c THEN xxx ELSE yyy | If c is not zero, execute the program statements xxx, otherwise execute the program statements yyy. |
INK n | As a keyword, sets the foreground colour to n. |
INPUT s | Allows the user to input a string, to be assigned to variable s. Strings and numbers will be displayed as prompts. Multiple variables may be input in a single statement. Separators may be used as in PRINT statements. To display a variable's current value as a prompt, put brackets around its name. |
LET x=y | Assigns the value y to a variable named x. |
LIST | Displays the BASIC program listing. |
LLIST | Not yet implemented. |
LOAD f | Loads the file named f from the IDE device. |
LPRINT | Not yet implemented. |
MONITOR | Runs the machine code monitor. |
NEW | Deletes the BASIC program and variables. |
NEXT i | As a keyword, marks the end of a FOR loop. |
OUT p,n | Writes the byte n to the output port p. |
PAPER n | As a keyword, sets the background colour. |
PAUSE | Waits until the user presses a key. |
PAUSE n | Waits until n/60 of a second have passed, or the user presses a key. |
PLOT x,y | Draws a point x pixels across and y pixels down from the top-left corner of the screen. |
POKE m,n | Writes an 8-bit value n to memory address m. |
PRINT xxx | Displays the specified information on the screen. xxx is any series of numeric or string values, separated by ; or , or ' . ; has no other effect. , moves the print position to the next 7-character-wide column, ' moves the print position to the start of the next line. |
PRINT AT y,x | Use AT y,x in a PRINT statement to move to row y, column x, measured in 6x8 pixel character squares from the top-left corner of the screen. |
RANDOMISE n | Sets the random number generator seed to n. |
READ | Not yet implemented. |
REM xxx | Indicates a human-readable comment xxx, which is ignored during program execution. |
RENAME f,s | Renames the file f to the new name s (not yet implemented). |
RESTORE | Not yet implemented. |
RETURN | Diverts program execution to the point after the last GOSUB statement was encountered. |
RUN | Starts executing the BASIC program at the first line. |
RUN n | Starts executing the BASIC program at line n. |
SAVE f | Saves the current BASIC program with filename f. |
SEE | Sets the foreground colour to white, background colour to black, and resets the hardware scroll registers. |
SLIDE n | Copies memory from address &n0000 to the screen. |
SNAP n | Copies memory from the screen to address &n0000. |
STOP | Terminates execution of the BASIC program. |
BASIC functions return a value, either numeric or string:
Function | Description |
---|---|
ABS n | If n is negative, returns its positive equivalent, otherwise returns n. |
x AND y | If x is non-zero and y is non-zero, returns y, otherwise returns zero. |
ASC s | Returns the 8-bit code representing the first character of the string s. |
CHR$ n | Returns a string containing the character represented by the byte value n. |
CURSOR | As a function, returns the current cursor colour. |
DEEK n | Reads a 16-bit value from memory addresses m and m+1. |
FREE | Returns the amount of free memory available to BASIC. |
IN p | Reads a byte from input port p. |
INK | As a function, returns the current foreground colour. |
INKEY$ | Reads whichever key is currently pressed. If none, returns an empty string. |
LEFT$(s,n) | Returns the first n characters of string s. |
LEN s | Returns the length of string s. |
LOWER$ s | Returns a lower-case version of the string s (not yet implemented). |
MID$(s,x,y) | Returns y characters, starting at position x, from string s. |
NEXT i | As a function, returns 0 if the loop is in its final iteration, otherwise returns 1. |
NOT n | Returns 1 if n is zero, otherwise returns 0. |
x OR y | If x is not zero, returns x; if x is zero, returns y. |
PAPER | As a function, returns the current background colour. |
PEEK m | Reads a byte from memory address m. |
POINT(x,y) | Returns the colour of the point x pixels across and y pixels down. |
RGB(r,g,b) | Returns a colour value for the specified red, green, and blue components; each should be in the range 0-7. |
RIGHT$(s,n) | Returns the last n characters of string s. |
RND | Returns a random 32-bit signed integer, ie between -2,147,483,648 and 2,147,483,647. |
SGN n | Returns -1, 0, or 1 depending on whether n is negative, zero, or positive. |
SQR n | Returns the integer square root of n. |
STR$ n | Returns a string representation of the number n (not yet implemented). |
UPPER$ s | Returns an upper-case version of string s (not yet implemented). |
USR m | Executes machine code from address m, returns the value of the CPU's BC register pair. |
VAL s | Returns the numeric interpretation of string s. The string may contain operators and variable names, but not named functions. |
Operators are characters which perform functions. Comparison operators currently only work on numbers, not strings.
Operator | Description |
---|---|
-x | Prefix for negative numbers. |
&x | Prefix for hexadecimal literals. |
%x | Prefix for binary literals. |
x+y | Addition, or string concatention. |
x-y | Subtraction. |
x*y | Multiplication. |
x/y | Integer division. |
x%y | Integer remainder (result has same sign as dividend). |
x=y | Returns 1 if x and y are equal, otherwise returns 0. |
x<>y | Returns 1 if x and y are not equal, otherwise returns 0. |
x<y | Returns 1 if x is less than y, otherwise returns 0. |
x>y | Returns 1 if x is greater than y, otherwise returns 0. |
x<=y | Returns 1 if x is less than or equal to y, otherwise returns 0. |
x>=y | Returns 1 if x is greater than or equal to y, otherwise returns 0. |