Skip to content

Docs #985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 22, 2025
Merged

Docs #985

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions docs/about.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# About


## About the ZX BASIC Project
## About the Boriel BASIC Project

ZX BASIC is a [BASIC](http://en.wikipedia.org/wiki/BASIC) ''cross compiler''.
It will compile BASIC programs (in your PC) for your [ZX Spectrum](http://en.wikipedia.org/wiki/Sinclair_ZX_Spectrum).
ZX BASIC is an <abbr title="Software Development Kit">SDK</abbr> entirely written in [python](http://www.python.org).
The SDK is implemented using the [PLY](http://www.dabeaz.com/ply/) (Python Lex/Yacc) compiler tool.
It translates BASIC to Z80 assembler code, so it is easily portable to other Z80 platforms (Amstrad, MSX).
Other non Z80 targets could also be available in the future.
Boriel BASIC (formerly known as _ZX BASIC_ and _Boriel ZX BASIC_) is a [BASIC](https://en.wikipedia.org/wiki/BASIC) ''cross compiler''.
It will compile BASIC programs (in your PC) for your [ZX Spectrum](https://en.wikipedia.org/wiki/Sinclair_ZX_Spectrum).
Boriel BASIC is an <abbr title="Software Development Kit">SDK</abbr> entirely written in [python](https://www.python.org).
The SDK is implemented using the [PLY](https://www.dabeaz.com/ply/) (Python Lex/Yacc) compiler tool.
It translates BASIC to Z80 assembler code, so it is easily portable to other Z80 platforms (Amstrad CPC, MSX).
Other non-Z80 targets could also be available in the future.

ZX BASIC syntax tries to maintain compatibility as much as possible with
[Sinclair BASIC](http://en.wikipedia.org/wiki/Sinclair_BASIC), it also have many new features, mostly taken from
[FreeBASIC](http://www.freebasic.net/wiki) dialect.
Boriel BASIC syntax tries to maintain as much compatibility as possible to that of
[Sinclair BASIC](https://en.wikipedia.org/wiki/Sinclair_BASIC), but it also has many new features, mostly taken from
[FreeBASIC](https://www.freebasic.net/wiki) dialect.

### Platform Availability
Since it is written in python, it is available for many platforms, like Windows, Linux and Mac.
You only need to have python installed on these. For windows, there also is an installable (.MSI) _compiled_
version, which does not need python previously installed.

Boriel BASIC is available _natively_ for Windows (32bit and 64bit) and Linux (x64). For other platforms (i.e. Mac OS)
you will need to have Python 3.12+ installed in your computer and download the version _with Python scripts_ from
the [Archive](archive.md) page.
6 changes: 3 additions & 3 deletions docs/abs.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
## Syntax


```
```basic
ABS(numericExpression)
```


## Description

Returns the absolute value of the given argument.
Argument must be a numeric expression. Returned value has the same type as the input argument.
Argument must be a numeric expression. The returned value has the same type as the input argument.

## Examples


```
```basic
REM Absolute value
LET a = -1
PRINT "Absolute value of a is "; ABS(a)
Expand Down
6 changes: 3 additions & 3 deletions docs/archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Source Code
You can checkout the latest source code from the repository.
See [https://github.com/boriel-basic/zxbasic](http://github.com/boriel/zxbasic) for instructions on how to clone the
See [https://github.com/boriel-basic/zxbasic](http://github.com/boriel-basic/zxbasic) for instructions on how to clone the
repository (git).


## Latest Version
You can contribute to ZX BASIC by reporting possible bugs or improvement suggestions at the
[forum](http://www.boriel.com/forum) or in social media.

Latest stable version is <span style="color: green;">**1.18.1**</span>.
The latest stable version is <span style={{color: "green"}}>**1.18.1**</span>.
Click on the desired icon below to download the package suitable for your platform:

* [<img src="https://zxbasic.readthedocs.io/en/docs/img/win32.png" alt="win32zip" width="32px"/>
Expand All @@ -36,7 +36,7 @@ in your system).

### What's new
To check out what's new on every version, have a look at the
[Changelog](https://github.com/boriel/zxbasic/blob/master/Changelog.md) file.
[Changelog](https://github.com/boriel-basic/zxbasic/blob/master/CHANGELOG.md) file.

## Older versions
This is the official ZX Basic archive. If you require an older ZX BASIC version, please have a look
Expand Down
4 changes: 2 additions & 2 deletions docs/dim.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A [type](types.md) is a name for the kind of data (`Integer`, `Byte`, `String`,
DIM <variable_name>[,<variable_name>...] [AS <type>] [= <value>]
```

Where _<type>_ can be one of **INTEGER**, **BYTE**, **FLOAT**, etc.
Where `<type>` can be one of **INTEGER**, **BYTE**, **FLOAT**, etc.
See the list of [available types](types.md). If type is not specified, **FLOAT** will be used, unless you use
a suffix (usually called _sigil_) like `$` or `%`.

Expand Down Expand Up @@ -46,7 +46,7 @@ Declaring a variable that has already been referenced in previous lines will res

### Examples of variable declarations

```
```basic
REM Declares 'a' as a 16 bit signed integer variable
DIM a AS INTEGER

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/4inarow.bas.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 4 in a Row

Program: 4inarow.bas
## Program: 4inarow.bas

This program first appeared in MicroHobby ZX Spectrum Spanish magazine. It has a
nice AI in BASIC that plays smartly against the human in only 16Kb!

```
```basic
0 REM From MicroHOBBY magazine, Num. 18, page 27 :')
1 BORDER 1: PAPER 1: INK 7: CLS : PRINT AT 10,10; FLASH 1;"STOP THE TAPE": PAUSE 200
5 DIM M(8,6): DIM p,pp,n as FLOAT
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/circle.bas.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Circle.Bas

```
Program: circle.bas
```
## Program: circle.bas

```

```basic
REM Sample circle drawing without using the CIRCLE command

DIM i, r, x, y, q as FLOAT
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/clock.bas.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Clock.Bas

```
Program: clock.bas
```
```
## Program: clock.bas

```basic
REM From the ZX Spectrum MANUAL
REM A Clock program

Expand Down
7 changes: 3 additions & 4 deletions docs/examples/clock2.bas.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Clock2.Bas

```
Program: clock2.bas
```
```
## Program: clock2.bas

```basic
REM From the ZX Spectrum MANUAL
REM A Clock program

Expand Down
7 changes: 3 additions & 4 deletions docs/examples/colors.bas.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Colors.bas

```
Program: colors.bas
```
```
## Program: colors.bas

```basic
REM From the ZX Spectrum 48K Manual

DIM m, n, c AS BYTE
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/fact.bas.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Fact.bas

```
Program: fact.bas
```
```
## Program: fact.bas

```vbnet
REM Factorial recursive test

function fact(x as ulong) as ulong
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/flag.bas.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Flag.bas

```
Program: flag.bas
```
## Program: flag.bas

```
```basic
5 REM union flag (from the ZX Spectrum Manual)

7 DIM n AS UInteger: REM Needed to avoid overflow at line 530
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/fractal.bas.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Fractal.bas

```
Program: fractal.bas by @Britlion
```
## Program: fractal.bas
by @Britlion


```
```vbnet
# define width 256
# define height 192

Expand Down
7 changes: 3 additions & 4 deletions docs/examples/freregustav.bas.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# FrereGustav.bas

```
Program: freregustav.bas
```
```
## Program: freregustav.bas

```basic
REM Frere Gustav, from the ZX Spectrum 48K Manual, Chapter 19

PRINT "Frere Gustav"
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/lines.bas.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Lines.bas

```
Program: lines.bas
```
## Program: lines.bas

```
```basic
5 REM From the ZX Spectrum manual on Drawing primitives
6 DIM x1, y1, x2, y2, c as Integer

Expand Down
6 changes: 2 additions & 4 deletions docs/examples/snake.bas.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Snake.Bas

```
Program: snake.bas
```
## Program: snake.bas

```
```basic
1 REM ********************************************************************
2 REM ZXSnake by Federico J. Alvarez Valero (2003-02-05)
10 REM This program is free software; you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion docs/fastcall.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ The above function, when called with `whatLetter(<value>)` will return the `<val
`"A Man, A Plan, A Canal, Panama"`.

### Notes
* Note that the A register already contains <value> when the inline assembly is reached.
* Note that the A register already contains `<value>` when the inline assembly is reached.
* Note that we do NOT need to put a ret opcode on the end of the assembly. The compiler will do that for us.
2 changes: 1 addition & 1 deletion docs/for.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Clearly, since the largest value a byte can hold is 255, it's not possible for i
The variable will "wrap around" to 0 and as a result, the loop will not ever terminate.
This can happen in much more subtle ways when `STEP` is used.
There has to be "room" within the variable type for the iterator to exceed the terminator when it is being
incremented by <step> amounts.
incremented by `<step>` amounts.

For example, this loop will neved end

Expand Down
8 changes: 4 additions & 4 deletions docs/identifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Identifiers shown in bold are taken from the Sinclair BASIC (beware their meanin
* [CONST](const.md)
* **[CONTINUE](continue.md)** **(statement)**
* **[COS](cos.md)** **(function)**
* **[DECLARE](declare.md)** **<modifier>**
* **[DECLARE](declare.md)** **(modifier)**
* **[DIM](dim.md)** **(statement)**
* [DO](do.md) **(statement)**
* **[DATA](data.md)** **(statement)**
Expand Down Expand Up @@ -79,7 +79,7 @@ Identifiers shown in bold are taken from the Sinclair BASIC (beware their meanin
* **[PAPER](paper.md)** **(statement)**
* **[PAUSE](pause.md)** **(statement)**
* **[PEEK](peek.md)** **(function)**
* **[PI](pi.md)** **<constant>**
* **[PI](pi.md)** **(constant)**
* **[PLOT](plot.md)** **(statement)**
* **[POKE](poke.md)** **(statement)**
* **[PRINT](print.md)** **(statement)**
Expand All @@ -91,8 +91,8 @@ Identifiers shown in bold are taken from the Sinclair BASIC (beware their meanin
* **[RND](rnd.md)** **(function)**
* **[SAVE](load.md)** **(statement)**
* **[SGN](sgn.md)** **(function)**
* [SHL or <<](shl.md) (operator)
* [SHR or >>](shl.md) (operator)
* [SHL or &lt;&lt;](shl.md) (operator)
* [SHR or &gt;&gt;](shl.md) (operator)
* **[SIN](sin.md)** **(function)**
* **[SQR](sqr.md)** **(function)**
* [StdCall](stdcall.md)
Expand Down
21 changes: 13 additions & 8 deletions docs/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
**IF** is a very powerful control flow sentence that allows you to _make decisions_ under specified conditions.

## Syntax
```
IF expression [THEN] sentences [: END IF]

```basic
IF expression [THEN] sentences [: END IF]
```

or

```
```vbnet
IF expression [THEN]
sentences
[ELSEIF expression [THEN] sentences]
Expand All @@ -19,15 +20,17 @@ or
END IF

```

### Examples
```

```basic
IF a < 5 THEN PRINT "A is less than five" ELSE PRINT "A is greater than five"
```


Sentences might be in multiple lines:

```
```vbnet
If a < 5 Then
Print "A is less than five"
a = a + 5
Expand All @@ -37,8 +40,10 @@ End If
```


Since **IF** is a _sentence_, it can be nested; however, remember that _every_ **IF** _must be closed with_ **END IF** when the line is split after **THEN** (mutiline **IF**):
```
Since **IF** is a _sentence_, it can be nested; however, remember that _every_ **IF** _must be closed with_
`END IF` when the line is split after **THEN** (mutiline **IF**):

```vbnet
If a < 5 Then
Print "A is less than five"
If a > 2 Then
Expand All @@ -57,7 +62,7 @@ End If
In the example above, you see that nesting an **IF** inside another one could be somewhat verbose and error prone. It's better to use
the **ELSEIF** construct. So the previous example could be rewritten as:

```
```vbnet
If a < 5 Then
Print "A is less than five"
If a > 2 Then
Expand Down
Binary file added docs/img/zxbasic_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading